LN OELINVH, OELINVN, OELCUST, OELSLRP
FORMAT INCLUDE #OEGF, OPT="NONE" ! Include global flags defn.
FORMAT INCLUDE #OEFINVN, ! Include
OPT="NONE" ! inventory fmt.
LET FUNC$=MSG1$[0], ! Set: I/O function
CUSTC$=#OEGF.CUSTC, ! Cust code changed flag
SRC$=#OEGF.SRC, ! Sales rep code changed flag
INVENC$=#OEGF.INVENC, ! Inventory code changed flag
INVHD$=#OEGF.INVHC ! Invoice header delete flag
IF POS(FUNC$="AUD")=0 OR ! If not add/chng./del. or
CUSTC$="X" OR ! customer code changed or
SRC$="X" OR ! sales rep code changed or
INVENC$="X" THEN ! inventory code changed
LET MSG1$[0]="." ! Then set ok return status.
IF #OEFINVH.INV-PRINTED-FLAG = ! If invoice printed
LET MSG1$[0]="ERROR OEERM01" ! Print no mods allowed msg.
IF INVHD$="X" THEN ! If invoice header change
PRINT @(0,0),MSG2$[1], ! Show line items.
LET OEFINVD=MSG2$[0], ! Set new invoice detail record
DNEW = OEFINVD.INV-LEXTEN, ! line extension amount
TNEW = OEFINVD.INV-LTAX, ! line tax amount
QNEW = OEFINVD.INV-QTY, ! quantity
SRNEW$ = OEFINVD.SR-CODE, ! sales rep code
CCNEW$ = OEFINVD.CUST-CODE, ! customer code
ICNEW$ = OEFINVD.ITEM-CODE, ! inventory item code
OEFINVD= FMD("#OEFINVD"), ! Set old invoice detail record
DOLD = OEFINVD.INV-LEXTEN, ! line extension amount
TOLD = OEFINVD.INV-LTAX, ! line tax amount
QOLD = OEFINVD.INV-QTY, ! quantity
SROLD$ = OEFINVD.SR-CODE, ! sales rep code
CCOLD$ = OEFINVD.CUST-CODE, ! customer code
ICOLD$ = OEFINVD.ITEM-CODE ! inventory item code
IF FUNC$="U" THEN ! If update
LET DELTD = DNEW - DOLD, ! Set delta: dollars.
DELTQ = QNEW - QOLD, ! quantity.
DELTT = TNEW - TOLD ! tax.
LET DELTD = OEFINVD.INV-LEXTEN, ! Set line item: dollars
DELTQ = OEFINVD.INV-QTY, ! quantity
DELTT = OEFINVD.INV-LTAX ! tax
IF CVT(ICOLD$,128)="" THEN ! If old inventory item = space
LET ICOLD$=ICNEW$ ! Set it to new item
IF FUNC$="D" THEN ! If delete being done
LET DELTD =: * (-1), ! Reverse delta
IF DELTD OR DELTQ OR ! If dollars or qty or
SROLD$SRNEW$ OR ! sales rep code or
CCOLD$CCNEW$ OR ! customer code or
ICOLD$ICNEW$ THEN ! item code changed
IF (DELTD OR DELTQ) AND ! If dollars or qty changed &
INVHD$"X" THEN ! invoice header not being
OPEN LINK OELINVH ! Open invoice header link
LET OEFINVH.INV-NUM = ! Set invoice header
OEFINVD.INV-NUM ! invoice number.
UPDATE OELINVH "U" ! Update invoice
PROCESSING IS INVHUPDATE ! header amount.
CLOSE LINK OELINVH ! Close invoice header link
IF DELTD OR DELTQ OR ! If dollars or qty or
CCOLD$CCNEW$ THEN ! customer code changed
OPEN LINK OELCUST ! Open customer file link
LET OEFCUST.CUST-CODE = ! Set customer code
UPDATE OELCUST "U" ! Update old customer
PROCESSING IS CUSTUPDATE ! record
BUSY PROCESS CUST-BUSY ! Update format if busy
IF CCOLD$ CCNEW$ THEN ! If cust code was changed
LET OEFCUST.CUST-CODE = ! Set new customer
UPDATE OELCUST "U" ! Update new
CLOSE LINK OELCUST ! Close customer file link
IF DELTD OR DELTQ OR ! If dollars or qty or
SROLD$SRNEW$ THEN ! sales rep code changed
OPEN LINK OELSLRP ! Open sales rep file link.
LET OEFSLRP.SR-CODE = ! Set sales rep code
UPDATE OELSLRP "U" ! Update old sales
PROCESSING IS SLSRPUPDATE ! rep record.
IF SROLD$ SRNEW$ THEN ! If sales rep code changed
LET OEFSLRP.SR-CODE = ! Set new sales rep code
UPDATE OELSLRP "U" ! Update new
PROCESSING IS ! sales rep
CLOSE LINK OELSLRP ! Close sales rep file link
IF DELTD OR DELTQ OR ! If dollars or qty or
ICOLD$ICNEW$ THEN ! inventory code changed
OPEN LINK OELINVN ! Open inventory file link.
LET OEFINVN.ITEM-CODE = ! Set old inventory code
UPDATE OELINVN "U" ! Update old
PROCESSING IS INVENUPDATE ! inventory record.
IF ICOLD$ ICNEW$ THEN ! If inventory code changed
LET OEFINVN.ITEM-CODE = ! Set new inventory code
UPDATE OELINVN "U" ! Update new
PROCESSING IS ! inventory
CLOSE LINK OELINVN ! Close inventory file link.
LET MSG1$[0]="." ! Set ok return status.
INVHUPDATE ! Invoice header update
LET OEFINVH.INV-AMOUNT=: + DELTD +
LET OEFCUST = #OEFCUST ! Update the
DO CUSTUPDATE ! data record
LET #OEFCUST = OEFCUST ! format.
LET RETRY = "C" ! Continue with next directive
LET OEFCUST.CUST-SALES=: + DELTD ! customer
IF CCOLD$CCNEW$ THEN ! sales
LET OEFCUST.CUST-SALES=: - DNEW ! update.
CUSTUPDATE1 ! New customer
LET OEFCUST.CUST-SALES=: + DNEW ! sales update.
LET OEFSLRP.SR-SALES=: + DELTD ! rep record
IF SROLD$SRNEW$ THEN ! sales
LET OEFSLRP.SR-SALES=: - DNEW ! update.
SLSRPUPDATE1 ! New sales rep record
LET OEFSLRP.SR-SALES=: + DNEW ! sales update.