Hi reyeshe, thx for your help. I don't create POs or do any other Symix transactions, so I have no idea how these records came to be. I just do (a lot of) programming in support of Symix, such as reports & utilities.
Here is an excerpt from my report, hopefully I removed all the excess gobbletygook. It builds a temp table (ttReport) with aged PO data.
Note this line line: IF po.type = "B" AND vfLastVchVal = 0 THEN vfBalance = 0.
It's a total hack, representing what USUALLY happens, but not always. It applies well to blanket POs, but not well to regular POs. With it, this report and the Symix report agree within about $1000, against a total amount of about 1.3 million. I can see no logical reason to set a PO value to 0 when it doesn't = 0, but it's part of the pattern seen in the Symix report. I wish we had the source code for this report, I'd be all over that thing like white on rice - lol.
PROCEDURE BuildTempTable:
HIDE MESSAGE NO-PAUSE.
MESSAGE "Compiling report...".
DEF VAR vfBalance AS DECI NO-UNDO.
FOR EACH vendor NO-LOCK WHERE vcVendNum = "" OR vendor.vend-num = vcVendNum:
FIND vendaddr NO-LOCK WHERE vendaddr.vend-num = vendor.vend-num.
HIDE MESSAGE NO-PAUSE.
MESSAGE vendor.vend-num vendaddr.name.
FOR EACH po NO-LOCK WHERE po.vend-num = vendor.vend-num AND po.stat <> "C" AND (vcPoType = "A" OR vcPoType = po.type):
IF vcVendNum <> "" THEN DO:
HIDE MESSAGE NO-PAUSE.
MESSAGE "PO:" po.po-num.
END.
FOR EACH poitem NO-LOCK OF po WHERE poitem.stat <> "C":
IF poitem.qty-received - poitem.qty-voucher <> 0 THEN DO:
vfBalance = 0.
FOR EACH po-vch NO-LOCK WHERE po-vch.po-num = poitem.po-num AND po-vch.po-line = poitem.po-line AND po-vch.po-release = poitem.po-release:
IF po-vch.type = "R" THEN vfBalance = vfBalance + po-vch.item-cost * po-vch.qty-received.
ELSE IF po-vch.type = "W" THEN vfBalance = vfBalance - po-vch.item-cost * po-vch.qty-returned.
ELSE IF po-vch.type = "V" THEN vfBalance = vfBalance - po-vch.item-cost * po-vch.qty-vouchered.
ELSE IF po-vch.type = "A" THEN vfBalance = vfBalance + po-vch.item-cost * po-vch.qty-vouchered.
ELSE IF po-vch.type = "F" THEN vfBalance = vfBalance + po-vch.item-cost.
END.
IF po.type = "B" AND vfLastVchVal = 0 THEN vfBalance = 0.
CREATE ttReport.
ASSIGN
ttReport.VendNum = vendor.vend-num
ttReport.VendName = vendaddr.name
ttReport.PoNum = poitem.po-num
ttReport.PoLine = poitem.po-line
ttReport.PoRelease = poitem.po-release
ttReport.PoType = po.type
ttReport.QtyRecvd = poitem.qty-received
ttReport.QtyVouchered = poitem.qty-voucher
ttReport.QtyRecNotVch = poitem.qty-received - poitem.qty-voucher
ttReport.RecDate = poitem.rcvd-date
ttReport.UnVouchTot = vfBalance.
IF poitem.rcvd-date < (TODAY - 180) THEN ttReport.Aged180 = vfBalance.
ELSE IF poitem.rcvd-date < (TODAY - 120) THEN ttReport.Aged120 = vfBalance.
ELSE IF poitem.rcvd-date < (TODAY - 60) THEN ttReport.Aged60 = vfBalance.
ELSE IF poitem.rcvd-date < (TODAY - 30) THEN ttReport.Aged30 = vfBalance.
ELSE IF poitem.rcvd-date < (TODAY - 15) THEN ttReport.Aged15 = vfBalance.
ELSE ttReport.Aged0 = ttReport.UnVouchTot.
END.
END.
END.
END.
HIDE MESSAGE NO-PAUSE.
END.
Thx again for any light you can shed on this! -E.