accesssoln
Member
I'm very new to JDE development and I'm trying to calculate the average of a field (Amount-unit cost) by doing SUM((quantity available/total quantity available)*Price) for all the values of unit cost for a certain item number. This is being done in the level break footer section that breaks with a new 2nd Item number, and I'm doing this manually via ER and Table I/O because the built in JDE aggregate for average doesn't work for my purposes. In the level break footer -- do section I have the following code:
V4111A.Open
V4111A.SelectEnd While
V4111A.Close
RV Average Unit Cost = VA rpt_mn_AverageUnitCost
I'm trying to do: Select Quantity Available, Amount - Unit Cost from V4111A where 2nd Item Number = BC 2nd Item Number AND Business Unit = PO szCostCenter. But with the code above, it never goes into the CO_SUCCESS while loop. If I move the fetch next at the beginning of the while loop it spits out some numbers but it's not accurate. Am I missing something small or not understanding how table I/O works? Any help is greatly appreciated. Thank you!
V4111A.Open
V4111A.Select
BC 2nd Item Number (F4111)(LITM) = TK 2nd Item Number
PO szCostCenter = TK Business Unit
V4111A.Fetch NextPO szCostCenter = TK Business Unit
BC Quantity Available (F4111)(TRQT) <- TK Quantity Available
BC Amount - Unit Cost (F4111)(UNCS) <- TK Amount - Unit Cost
While SV File_IO_Status is equal to CO_SUCCESSBC Amount - Unit Cost (F4111)(UNCS) <- TK Amount - Unit Cost
VA sec_mn_CalcUnitMeasure = ([BC Quantity Available (F4111)(TRQT)]/[RV Total of Transaction Quantity])*[BC Amount - Unit Cost (F4111)(UNCS)]
VA rpt_mn_AverageUnitCost = [VA rpt_mn_AverageUnitCost]+[VA sec_mn_CalcUnitMeasure]
V4111A.Fetch Next
BC Quantity Available (F4111)(TRQT) <- TK Quantity Available
BC Amount - Unit Cost (F4111)(UNCS) <- TK Amount - Unit Cost
V4111A.Close
RV Average Unit Cost = VA rpt_mn_AverageUnitCost
I'm trying to do: Select Quantity Available, Amount - Unit Cost from V4111A where 2nd Item Number = BC 2nd Item Number AND Business Unit = PO szCostCenter. But with the code above, it never goes into the CO_SUCCESS while loop. If I move the fetch next at the beginning of the while loop it spits out some numbers but it's not accurate. Am I missing something small or not understanding how table I/O works? Any help is greatly appreciated. Thank you!