: "batA96.sh by Dan Martin (DRM/CTG) Fri Dec 27 15:22:12 CST 1996" # Will show all Stock Ordered, for any Category, over any Period. # PREFERS existence of /tmp/cat.${HOMEBASE} which is # created daily SHELLS/cron_am.sh using SHELLS/bycat.sh # Temp Files f1=/u2/tmp/b1$$ eraser() { rm -f $f1 } # EOF eraser() trap ' echo "\n PROGRAM (\"$0\") CANCELLED!!\n"; eraser; sleep 2; exit 0' 2 cat << PAW =========< CATEGORY PURCHASE HISTORY - $plname >========= PAW phoo() { # Required Argument: $1 = A User-Abuse blabberie echo "\n $1" echo "\n This Program (\"$0\") has been Cancelled. Please try again.\n" eraser sleep 3 exit 0 } # EOF phoo() . /bin_drm/coddle # see internal documentation if [ -s "/tmp/cat.$SITE" ] then >$f1 awk -F"^" '{if ($1 > " ") print $1}' /tmp/cat.$SITE | pr -20t -w80 fi getit "$RN ENTER DESIRED CATEGORY CODE:$RO" ANY 3 if [ -s "/tmp/cat.$SITE" ] then awk -F"^" '{if ($1 == ans) print $1}' ans="$ans" /tmp/cat.$SITE >$f1 [ ! -s "$f1" ] && phoo "\tNO SUCH CATEGORY AS \"$ans\"!" fi tac="$ans" tput clear cat << PAW ======< CATEGORY $RN $tac $RO PURCHASE HISTORY - $plname >====== PAW mo=", inv_file" amo="AND m_pod_stk_no = inv_stk_no" getit ' Use verage, ast, or

urchase Order cost? (A/L/O):' ESL 3 1 case "$ans" in A) uuc="inv_unit_cost" ;; L) uuc="inv_last_unit_cost" ;; P) uuc="m_pod_unit_price"; mo='' ; amo='' ;; *) phoo "\tNO SUCH CHOICE AS \"$ans\" OFFERED!" ;; esac cty="$ans" echo getit ' Sort By total uantity or total ollars? (Q/D):' ESL 3 1 case "$ans" in Q) yak="QUANTITY"; ext="m_pod_quant_order" ;; D) yak="DOLLAR"; ext="($uuc * m_pod_quant_order)" ;; *) phoo "\tNO SUCH CHOICE AS \"$ans\" OFFERED!" ;; esac qod="$ans" echo getit ' PO BEGINNING Date (MMDDYYYY):' IDN 3 bds=$ans echo getit ' PO ENDING Date (MMDDYYYY):' IDN 3 eds="$ans" echo "\n\tWorking...\c" # dbaccess $SDB - << STOP 2>/dev/null # she's real quiet # dbaccess -e $SDB - << STOP 2>&1 | tee /tmp/drm # she's a screamer dbaccess $SDB - << STOP # she only whimpers SELECT m_pom_no mpo FROM m_po_m WHERE m_pom_date BETWEEN "$bds" AND "$eds" INTO TEMP klug; SELECT sup_m_pom_no spo FROM sup_mpom WHERE sup_m_pom_date BETWEEN "$bds" AND "$eds" INTO TEMP glug; SELECT mpo po, "A" wor FROM klug UNION SELECT spo, "B" FROM glug INTO TEMP plug; SELECT UNIQUE po FROM plug INTO TEMP slug; CREATE INDEX islug ON slug(po) ; DROP TABLE klug; DROP TABLE glug; DROP TABLE plug; SELECT m_pod_stk_no stk, $ext total FROM slug, m_po_d $mo WHERE po = m_pod_no $amo INTO TEMP hugg ; DROP INDEX islug ; DROP TABLE slug; CREATE INDEX ihugg ON hugg(stk) ; SELECT stk, SUM(total) amt, COUNT(*) poz FROM hugg GROUP BY stk INTO TEMP bugg ; DROP INDEX ihugg ; DROP TABLE hugg; CREATE INDEX ibugg ON bugg(stk) ; UNLOAD TO "$f1" DELIMITER "^" SELECT stk, amt, "$yak", inv_keyword, inv_desc, inv_use, inv_mfg_pn, inv_unit_cost, inv_last_unit_cost, inv_unit_of_measur, inv_bal_on_hand, inv_max, inv_min, inv_priority, inv_date, inv_equip_no, inv_last_po_no, inv_last_po_date, inv_last_act, inv_last_typ, poz FROM bugg, inv_file WHERE stk = inv_stk_no AND inv_cat = "$tac" AND inv_priority NOT IN ("O","DNR","WRO") ORDER BY amt DESC, stk ; DROP INDEX ibugg ; DROP TABLE bugg; STOP [ ! -s "$f1" ] && phoo "No Information Available for Category \"$tac\"!" # cp $f1 /tmp/batA96.dat # debuggerie num=`awk 'END {print NR}' $f1` bd=`echo $bds | # 04/29/1994 awk '{print substr($0,1,2) "/" substr($0,3,2) "/" substr($0,5,4)}'` ed=`echo $eds | # 04/29/1994 awk '{print substr($0,1,2) "/" substr($0,3,2) "/" substr($0,5,4)}'` echo " ======< CATEGORY $tac PURCHASE HISTORY - $plname >======\n" >$TNIRP tput clear cat << EYE ======< CATEGORY $RN $tac $RO PURCHASE HISTORY - $plname >====== There are "$num" Stock Items in Category "$tac" that were included on Purchase Orders dated between "$bd" and "$ed". Enter below how many of these Items the Report should contain (e.g., 15). EYE getit " INCLUDE HOW MANY OF THE $num ITEMS IN THE REPORT? (##):" PNO 3 top="$ans" # Feed this to awk to control point of exit echo getit ' INCLUDE DESCRIPTION, USE, & EQ INFO IN REPORT? (Y/N):' ESL 3 1 case "$ans" in Y) dnu="$ans" ;; *) dnu="N" ;; esac awk -F"^" -f $SPM/AWK/batA96.awk top="$top" num="$num" cat="$tac" \ bd="$bd" ed="$ed" yak="$yak" cty="$cty" dnu="$dnu" $f1 >>$TNIRP echo "\n END REPORT (ID: \"$0\") AS OF: `date`\n" >>$TNIRP $SPM/SHELLS/help_me.sh $TNIRP eraser # EOF batA96.sh