|
Well, I can't think of any way to avoid a long if statement, but you can make your code easier to read by using a procedure. I would do something like this: DBrnTotal DS QUALIFIED D BTAM59 LIKE(CMAM22) INZ(0) D BTAM01 LIKE(CMAM01) INZ(0) D BTAM02 LIKE(CMAM02) INZ(0) D BTAM03 LIKE(CMAM03) INZ(0) D BTAM04 LIKE(CMAM04) INZ(0) D BTAM05 LIKE(CMAM05) INZ(0) D BTAM06 LIKE(CMAM06) INZ(0) D BTAM07 LIKE(CMAM07) INZ(0) D BTAM08 LIKE(CMAM08) INZ(0) D BTAM09 LIKE(CMAM09) INZ(0) D BTAM10 LIKE(CMAM10) INZ(0) DBrnArray DS DIM(999) LikeDS(BrnTotal) D ChkBrnTotal PR N D BrnDS LikeDS(BrnTotal) /Free For Brn = 1 TO 999; If ChkBrnTotal(BrnArray(Brn)); // DO STUFF WITH SUBFIELDS; EndIf; EndFor; /End-Free P ChkBrnTotal B D ChkBrnTotal PI N D BrnDS LikeDS(BrnTotal) D Result S N /Free Eval Result = *OFF; If BrnDS.BTAM59 <> 0 OR BrnDS.BTAM59 <> 0 OR etc.......; Eval Result = *ON; Endif; Return Result; /End-Free P ChkBrnTotal E Joe Lee >>> sporter@xxxxxxxxxxxx 10/26/2004 13:50:07 >>> I saw a thread a while back that prompted me to convert my RPG III program to RPG IV to take advantage of some new features like ds array and the += operator. So far, it is looking very good. I have a 999 element array and got data into the subfields. Now I want to output any of those elements that are not all zeros. Is there a shortcut? (Using V5R2) DBrnTotal DS DIM(999) QUALIFIED D BTAM59 LIKE(CMAM22) INZ(0) D BTAM01 LIKE(CMAM01) INZ(0) D BTAM02 LIKE(CMAM02) INZ(0) D BTAM03 LIKE(CMAM03) INZ(0) D BTAM04 LIKE(CMAM04) INZ(0) D BTAM05 LIKE(CMAM05) INZ(0) D BTAM06 LIKE(CMAM06) INZ(0) D BTAM07 LIKE(CMAM07) INZ(0) D BTAM08 LIKE(CMAM08) INZ(0) D BTAM09 LIKE(CMAM09) INZ(0) D BTAM10 LIKE(CMAM10) INZ(0) ... Many additions into the subfields as I accumulate totals /FREE For Brn = 1 TO 999; If BrnTotal(Brn) <> *ZERO; // DO STUFF WITH SUBFIELDS; EndIf; EndFor; /END-FREE ... All 999 records show up. Any suggestions other than If BrnTotal(Brn).BTAM59 <> 0 OR BrnTotal(Brn).BTAM01 <> 0 OR ... etc P.S. Since I only have DIM(999) why did it not run with BRN as 3,0? I had it LIKE(my branch number field) but changed to 10I0 after the error. (Got "The target for a numeric operation is too small to hold the result" when it hit the For loop.) -- 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 mailing list archive is Copyright 1997-2025 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.