# batA96.awk by Dan Martin (DRM/CTG) Thu Jan 02 13:38:02 CST 1997 # Called by: SHELLS/batA96.sh # awk fields: # $1 = stk, $2 = amt, $3 = QUANTITY, # $4 = inv_keyword, $5 = inv_desc, $6 = inv_use, # $7 = inv_mfg_pn, $8 = inv_unit_cost, $9 = inv_last_unit_cost, # $10 = inv_unit_of_measur, $11 = inv_bal_on_hand, $12 = inv_max, # $13 = inv_min, $14 = inv_priority, $15 = inv_date, # $16 = inv_equip_no, $17 = inv_last_po_no, $18 = inv_last_po_date, # $19 = inv_last_act, $20 = inv_last_typ, $21 = poz BEGIN \ { ll = 85 # Line Length l5 = 0 # Length of $5 l6 = 0 # Length of $6 l16 = 0 # Length of $16 grt = 0 # Grand Total uz = "xxx" # The "Use" String deq = "xxx" # The Description & Use String # --------- # The below are all passed in from the shell: # bd = # Beginning PO Date # ed = # Ending PO Date # cat = # Category chosen by [ab]User # cty = # Use verage, ast, or

urchase Order cost? # dnu = "Y" # Include Desc & Use (Y/N) # num = # Number of Items in Category within PO Date-Range # top = # How many of num does [ab]User want on the Report # yak = # Dollar or Quantity Sorting (same as $3) if (cty == "P") yok = sprintf("Category \"%s\" using PO Costs:", cat) else if (cty == "A") yok = sprintf("Category \"%s\" using Average Costs:", cat) else if (cty == "L") yok = sprintf("Category \"%s\" using Last Costs:", cat) else yok = "HTHSIK" ctr(ll, yok); skip(2) printf("STOCK %s TOTALS FOR ALL POS CREATED BETWEEN \"%s\" AND \"%s\".\n", yak, bd, ed) if (yak == "DOLLAR") duh = "TL PO $$" else if (yak == "QUANTITY") duh = "TL PO QTY" else duh = "HTHSIK" printf("NOTE: Column \"XOR\" shows how many TIMES the Item was Ordered!\n\n") printf("STOCK NUMBER PRI %9s XOR KEYWORD", duh); spc(14) printf("MFG PART NUMBER\n") printf("-------------- --- --------- --- -------------------- ") printf("--------------------\n") } # main() {printf("%-14s %-3s %9.2f %3d %-20s %s", $1, $14, $2, $21, $4, $7) if (dnu == "Y") {l5 = length($5); l6 = length($6); l16 = length($16) if (l5 > 77) uz = sprintf("D: %s", substr($5,1,77)) else uz = sprintf("D: %s", $5) if ((l6 + l16) > 71) deq = sprintf("U: %s EQ: %s", $6, substr($16, 1, (71 - l6))) else deq = sprintf("U: %s EQ: %s", $6, $16) printf("\n%s\n", uz); printf("%s\n\n", deq) } else printf("\n") grt += $2 if (NR == top) exit } END \ {printf("\nThere are %d Items (of %d) in Category %s printed above.\n", top, num, cat) printf("The Total %s Value for the %d Items is: %d\n", yak, num, grt) } ## FUNCTIONS: # spc(n) slides n [more] spaces along the current line: function spc(n) {for (i = 0; i < n; i++) printf(" ")} # skip(n) jumps to the next line and skips down an additional (n-1) lines: function skip(n) {for (i = 0; i < n; i++) printf("\n")} # ctr(ll, str) centers and prints string "str" based on line-length "ll" function ctr(ll, str) {stl = length(str) lmr = int(((ll - stl)/2)) for (i = 0; i < lmr; i++) printf(" ") printf("%s\n", str) } # EOF batA96.awk