: !/bin/sh # IYYYYMMDD env var must me set to which month # APERIOD env var must me set to which month # $1 will override IYYYYMMDD env var # $2 will override IOFFSETDAYS env var # $3 will override APERIOD env var # $4 will override BATCHID env var # $5 will override default outdir if [ -n "$1" ]; then IYYYYMMDD="$1" export IYYYYMMDD fi if [ -z "$IYYYYMMDD" ]; then echo "$0: Must set invoiced date IYYYYMMDD env var OR $0 yyyymmdd" exit 1 fi IYYYYMM=`echo "$IYYYYMMDD" | cut -c1-6` if [ -n "$2" ]; then IOFFSETDAYS="$2" export IOFFSETDAYS fi if [ -z "$IOFFSETDAYS" ]; then echo "$0: Must set invoiced date offset days IOFFSETDAYS env var OR $0 ndays" exit 1 fi if [ -n "$3" ]; then APERIOD="$3" export APERIOD fi if [ -z "$APERIOD" ]; then echo "$0: Must set bill Period date APERIOD env var OR $0 yyyy/mm" exit 1 fi if [ -n "$4" -a "$4" != "all" ]; then BATCHID="$4" BATCHIDBIT=" and ${transactiontable}.BatchID = $BATCHID" else BATCHID="all" BATCHIDBIT="" fi if [ -n "$5" ]; then outdir="$5" else #outdir="detail_${APERIOD}_${BATCHID}" #outdir="detail_${IYYYYMMDD}_${BATCHID}" outdir="detail_${IYYYYMM}_${BATCHID}" fi echo "$0: for $IYYYYMMDD, $IOFFSETDAYS, $APERIOD , batchid $BATCHID to outdir $outdir" . tbsserver_vars tbsbillingperiod="$APERIOD" echo "tbsbillingperiod=[$tbsbillingperiod]" YYYYMM=`echo "$tbsbillingperiod" | sed 's/\///'` echo "YYYYMM=[$YYYYMM]" #outfile="$0_${YYYYMM}_${BATCHID}.unl" #outfile="$0_${YYYYMM}" outfile="detail_${IYYYYMM}" #transactiontable="tFinalisedTransaction" transactiontable="tFinalisedTransaction${YYYYMM}" #echo "transactiontable=[$transactiontable]" #rm -r "${outdir}" #mkdir -p "${outdir}" #-------------------------------------------------------------- # Bilmax21 standard internal mobile call data format # first in sundry then folowed by.. # printf("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%d|%0.2f|\n", servicenumber, carrier, callclass, billperiod, sdate_str, btxt_stime_str, btxt_origin, btxt_destination, btxt_dialled, btxt_rate, dursecs, costinclgst) # RENT / OTHER / (also has CALL summary) #sdate_str = "CHARGE_DESC" #btxt_origin = "RENT" ( #cat < 0 --# and tElement.ID = tServiceType.RevenueElementID --# and tTransactionType.ID = tSupplierServiceCode.TransactionTypeID --# and tSupplier.ID = SupplierServiceCode.SupplierID AND tInvoice.InvoiceDate > dateadd(dd,$IOFFSETDAYS,'$IYYYYMMDD') AND tInvoice.InvoiceDate <= dateadd(mm,1,dateadd(dd,$IOFFSETDAYS,'$IYYYYMMDD')) $EXCLUDEINVBIT $EXCLUDEBATCHIDBIT $EXCLUDEINVBIT $EXCLUDEBATCHIDBIT --# and tServiceID.ServiceID = "0407-326077" \go -m bcp SQLCMD0 #) | tr "," ";" >$outfile #) | tr "," ";" | split -b1024m - $outfile ) | tr "," ";" | awk -F'|' -v"outfile=$outfile" -v"outdir=$outdir" ' { batchid = $1 serviceid = $6 var01 = $38 # cant have "/" in SID (re: filenames) gsub("/",".",serviceid) #ofile = outdir "/" outfile "_" batchid "_" serviceid "_" var01 ".unl" ofile = outdir "/" outfile "_" batchid "_" serviceid ".unl" if ( ofile != last_ofile ) { if ( last_ofile != "" ) close last_ofile last_ofile = ofile } print $0 >> ofile }' #29|29|1|27270|0430GTD|TQ|TELCO RENTAL&CALLS|VICTRACK|P|Feb_2008|Feb 29 2008 12:00AM||||Call|CALL||0|0.0000|13131|45|0|in|||||||||||| #cat $outfile find "$outdir" -type f -exec wc -l {} \; | sort -nr >"gd5.cnt"