: !/bin/sh SDATE="$1" EDATE="$2" gtchfile="$3" BATCHID="all" ## Testing #SDATE="01/01/2012" #EDATE="31/01/2012" #gtchfile="gtch.unl" ###################################################################### MMYYYY=`SDATEtoMMYYYY $SDATE` echo "MMYYYY = [$MMYYYY]" billperiod=`MMYYYYtobillperiod $MMYYYY _` echo "$MMYYYY - billperiod = [$billperiod]" # run additional customer import csv creation if [ -f "invcde.excl_${billperiod}" ]; then . invcde.excl_${billperiod} fi ###################################################################### echo "gettbstransactionhierarchy:" echo " EXCLUDEINVBIT = $EXCLUDEINVBIT" echo " EXCLUDEBATCHIDBIT = $EXCLUDEBATCHIDBIT" tmp1file="/tmp/gtranshier_1_$$" tmp2file="/tmp/gtranshier_2_$$" rm -f "$tmp1file" rm -f "$tmp2file" rm -f "$gtchfile" IOFFSETDAYS="9" # convert EDATE to YYYYMMDD EYYYYMMDD=`awk -v "ADATE=$EDATE" -v "sep=" ' BEGIN { dd = 0 + substr(ADATE,1,2); mm = 0 + substr(ADATE,4,2); yyyy = 0 + substr(ADATE,7,4); YYYYMMDD = sprintf("%04d%s%02d%s%02d", yyyy, sep, mm, sep, dd); print YYYYMMDD exit }'` echo "EYYYYMMDD=[$EYYYYMMDD]" EYYYYMM=`echo "$EYYYYMMDD" | cut -c1-6` echo "EYYYYMM=[$EYYYYMM]" . tbsserver_vars # get required bill Periods from TBS invoice tables # based on InvoiceDate ( sqsh -S $server -D $dbname -U $username -P $password < dateadd(dd,$IOFFSETDAYS,'$EYYYYMMDD') and tInvoice.InvoiceDate <= dateadd(mm,1,dateadd(dd,$IOFFSETDAYS,'$EYYYYMMDD')) $EXCLUDEINVBIT $EXCLUDEBATCHIDBIT ORDER BY Period \go -m bcp SQLCMD0 ) | sed 's/\|$//' > "$tmp1file" #echo "2009/01" >"$tmp1file" # loop for each required bill Period cat "$tmp1file" | \ while read aperiod do echo "gettbstransactionhierarchy: aperiod=[$aperiod]" ################################### # get platinum invoice info from TBSdata gettranscusthier $EYYYYMMDD $IOFFSETDAYS "$aperiod" "$BATCHID" "/tmp/gtch$$" cat "/tmp/gtch$$" >>"$tmp2file" rm -f "/tmp/gtch$$" done sort -u "$tmp2file" >"$gtchfile" rm -f "$tmp1file" rm -f "$tmp2file" exit 0