: !/bin/sh # populate mobile config table from the Directory SDATE="$1" EDATE="$2" SDATE="01/03/2010" today=`date "+%d/%m/%Y"` infile="tbscustomerhierarchy.unl" echo "#............... ShipTo->Grp->Dept->Centre" #sort by... # ShipTo -> Grp -> Dept -> Centre sort -t'|' -k8,8 -k5,5 -k3,3 -k1,1 "$infile" | \ awk -F'|' ' function spit_wbd(level,levelname,descID,desc,nodedesc) { #print "level=" level " " levelname ": " "(" descID ") " desc " [" nodedesc "]" print "Bilmax21 Reports for " nodedesc #distid = distid_arr[level] if ( distid == "" ) { distid = (level * 10000) + 1 distid_arr[level] = distid } } { f = 0 CentreID = $(++f) CentreDesc = $(++f) DeptID = $(++f) DeptDesc = $(++f) GrpID = $(++f) GrpDesc = $(++f) CustID = $(++f) ShipTo = $(++f) FullName = $(++f) #print "ShipTo=" ShipTo " -> GrpID=" GrpID " -> DeptID=" DeptID " -> CentreID=" CentreID # wbd for ShipTo nodedesc = "(" ShipTo ")" FullNaem if ( ShipTo != last_ShipTo ) { spit_wbd(1,"ShipTo",ShipTo,FullName,nodedesc) } # wbd for GrpId nodedesc = nodedesc "->" "(" GrpID ")" GrpDesc if ( ShipTo != last_ShipTo || GrpID != last_GrpID ) { spit_wbd(2,"Grp",GrpID,GrpDesc,nodedesc) } # wbd for DeptID nodedesc = nodedesc "->" "(" DeptID ")" DeptDesc if ( ShipTo != last_ShipTo || GrpID != last_GrpID || DeptID != last_DeptID ) { spit_wbd(3,"Dept",DeptID,DeptDesc,nodedesc) } # wbd for CentreID nodedesc = nodedesc "->" "(" CentreID ")" CentreDesc if ( ShipTo != last_ShipTo || GrpID != last_GrpID || DeptID != last_DeptID || CentreID != last_CentreID ) { spit_wbd(4,"Centre",CentreID,CentreDesc,nodedesc) } } '