|
Rob wrote: >I'm a different Rob, but I'll take a stab. Let's use a simple table: > >While this might be better in a lookup file, for the sake of our example let's assume we used a >compile time table. > >¦ D*Name++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++ >¦ DTABEMP 3A 0 DIM(4) PERRCD(1) CTDATA >¦ DTABPAY 7S 2 DIM(4) ALT(TABEMP) >¦ C*0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq.. >¦ C* The LOOKUP operation searches TABEMP for an entry that is equal to >¦ C* the contents of the field named EMPNUM. If an equal entry is >¦ C* found in TABEMP, indicator 09 is set on, and the TABEMP entry and >¦ C* its related entry in TABPAY are made the current elements. >¦ C EMPNUM LOOKUP TABEMP TABPAY 09 >¦ C* If indicator 09 is set on, the contents of the field named >¦ C* HRSWKD are multiplied by the value of the current element of >¦ C* TABPAY. >¦ C IF *IN09 >¦ C HRSWKD MULT(H) TABPAY AMT 6 2 >¦ C ENDIF > ... >** Employee table. First 3 digits are employee # Rest is rate. >0010000950 >0020000725 >0030001375 >0040001000 One minor point about alternating tables/arrays: Alternating format deals only with the loading of array/table values. The two arrays or tables have no relationship to each other other than that. In particular, the two tables specified in the LOOKUP opcode do not have to be tables defined in alternating format. (Also, you can even mix arrays and tables using alternating format.) Oh by the way, the preferred syntax for compile-time array/table data is: **CTDATA TABEMP Employee table. First 3 digits are employee # Rest is rate. 0010000950 0020000725 0030001375 0040001000 This way, you don't have to code the compile-time data in the same order as the array/table definition. Note that you can't mix the two styles of compile-time data definition in the same module. Once you use the **CTDATA syntax in a module, you can't use the ** syntax. (But then again, when you know about **CTDATA, why would you even think about using the old syntax?) (This was actually part of the IBM Corporate Standard for RPG during the S/38 RPG III days, but was never implemented until RPG IV!) Cheers! Hans Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
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.