× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Nevermind... DUH

Michael Schutte



                                                                           
             "praveen gunda"                                               
             <praveen.gunda@gm                                             
             ail.com>                                                   To 
             Sent by:                  "RPG programming on the AS400 /     
             rpg400-l-bounces@         iSeries" <rpg400-l@xxxxxxxxxxxx>    
             midrange.com                                               cc 
                                                                           
                                                                   Subject 
             04/19/2006 12:42          How can I Improve this procedure... 
             PM                                                            
                                                                           
                                                                           
             Please respond to                                             
              RPG programming                                              
              on the AS400 /                                               
                  iSeries                                                  
             <rpg400-l@midrang                                             
                  e.com>                                                   
                                                                           
                                                                           




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;
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.