|
Hi all, I have the following procedure in a service program that would be called quite a few times from different programs. How can I improve this procedure for performance? I am a little worried about how the ReasonDS is declared. Basically I need an Array of the Datastructure that the procedure can return. I also need to be able to look up this array with @RsnCode as the key. * Array of Data structures to hold reason code details D ReasonDS DS 5400 D @RsnCode 2A Dim(200) D @Charge 9 2 Dim(200) D @Weight 9 0 Dim(200) D @Units 7 0 Dim(200) P BilUtil_getReasonTotals... P B Export D BilUtil_getReasonTotals... D PI LikeDS(ReasonDS) D @prPlant_ 3 0 Value D @prBillTo_ 5 0 Value D @prBillDate_ D Value D @prInvoice_ 5 0 Value * Return Data structure D tempReasonDS DS LikeDS(ReasonDS) * Local variables D @Count S 2 0 Inz(*Zeros) D @tCount S 2 0 Inz(*Zeros) D @Century S 2 0 Inz(*Zeros) D @BillDt S 6 0 Inz(*Zeros) /free If Not %Open(BMCTOTL4); Open BMCTOTL4; EndIf; If Not %Open(BHCTOTL1); Open BHCTOTL1; EndIf; @Century = DateUtil_getCentury(@prBillDate_); @BillDt = %Dec(%Char(@prBillDate_:*YMD0):6:0); // First check if record exists in current SetLL (@prPlant_:@prBillTo_:@prInvoice_:@Century:@BillDt) BMCTOTL4 ReadE (@prPlant_:@prBillTo_:@prInvoice_:@Century:@BillDt) BMCTOTL4 DoW Not %EoF(BMCTOTL4); // Accumulate all charges per reason code for this custom @tCount = %LookUp(BTREA:@RsnCode); If @tCount <> 0; tempReasonDS.@Charge(@tCount) += BTTDO; tempReasonDS.@Weight(@tCount) += BTTLB; tempReasonDS.@Units(@tCount) += BTTUN; Else; @Count += 1; tempReasonDS.@RsnCode(@Count) = BTREA; tempReasonDS.@Charge(@Count) = BTTDO; tempReasonDS.@Weight(@Count) = BTTLB; tempReasonDS.@Units(@Count) = BTTUN; EndIf; ReadE (@prPlant_:@prBillTo_:@prInvoice_:@Century:@BillDt) BMCTOTL4; EndDo;
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.