|
Buck, It does a lot. Yours and Richards mail helped a lot. I have more or less understood the stuff. I have to try it out and get the thing sealed :) Thank you very much. Sunil ----- Original Message ----- From: "Buck Calabro" <Buck.Calabro@commsoft.net> To: <rpg400-l@midrange.com> Sent: Thursday, June 27, 2002 7:03 PM Subject: RE: Doubt on prerun time array And a doubt about batch job > Hi Sunil! > > >And I guess perrcd will come to place > >when we use compile time arrays right? > > Either compile time or prerun time tables/arrays will use PERRCD. That's > how we tell the compiler how many elements are on each input record. For > instance, you can define an array of month names like this: > > FPF2 IT F 80 DISK > D MON S 3 DIM(12) FROMFILE(PF2) > D PERRCD(1) > > and the file PF2 contains 12 records (12 elements, 1 on each record) > JAN > FEB > MAR > APR > MAY > JUN > JUL > AUG > SEP > OCT > NOV > DEC > > If you define the array this way: > > FPF3 IT F 80 DISK > D MON S 3 DIM(12) FROMFILE(PF3) > D PERRCD(12) > > then the file contains one record (12 elements, 12 on a record) > JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC > > >Has precompile type arrays and Tables runout of steam? > > Well, it depends a lot on what you intend to use them for. The big problem > is that it is difficult to change the size of the array without changing the > program. Imagine having a table of US States. Today (and since 1960) there > have been 50 states, so the table would have 50 elements. Imagine the > difficulty if Puerto Rico becomes a state. Now, every RPG program that has > the table of states needs to be changed! If we stored the names in a file > instead, then no code would have to change, only add the new state into the > file and all the programs work properly. > > >Also regrading my earlier doubts can you just > >explain significance what a table is? > >Is it related to the table that we can > >create using strsql? > > No. It is not related to an SQL table. > A table in RPG is a way to quickly store a small amount of data that you > refer to very often in the program. Often, this is for converting a code to > a meaningful name, like month abbreviations into the month name. > > FPF4 IT F 80 DISK > D TABABR S 3 DIM(12) FROMFILE(PF4) PERRCD(1) > D TABNAM S 20 DIM(12) ALT(TABABR) > c 'JUL' LOOKUP TABABR TABNAM 20 > c if %found > c... > > File PF4 looks like this > JANJanuary > FEBFebruary > MARMarch > APRApril > MAYMay > JUNJune > JULJuly > AUGAugust > SEPSeptember > OCTOctober > NOVNovember > DECDecember > > You might use this when a file contains month abbreviations, but you want to > print the full name on a report, or show it on the display. > > The other place tables are used is to see if data is 'in a list.' For > instance, if you were writing a program to print labels for cola bottles, > some states charge a bottle return deposit fee. So you put the states that > charge a fee in a table, and do a lookup. If the state you're working with > is in the table (don't care what element; it's only important to know that > it's in there somewhere) then print the fee: > > fPF5 IT F 80 DISK > d TABDeposit S 2 DIM(2) FROMFILE(PF5) > d PERRCD(1) > c 'NY' lookup TABDeposit 20 > c 20'Deposit!' dsply > c n20'No deposit' dsply > c 'CA' lookup TABDeposit 20 > c 20'Deposit!' dsply > c n20'No deposit' dsply > c seton LR > > PF5 contains: > NJ > NY > > Of course, you would use a field from your database instead of the literals > 'NY' and 'CA'. > Does this help? > --buck > _______________________________________________ > This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list > To post a message email: RPG400-L@midrange.com > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l > or email: RPG400-L-request@midrange.com > 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-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.