Can I reference fields in a PRTF as an array in RPGLE

Posted on 2009-04-30
Medium Priority
Last Modified: 2012-06-27
I have a AS400 print file with fileds like FLD01, FLD02, FLD03, FLD04, FLD05... where I need to move data from fields TXT01, TXT02, TXT03, TXT04, TXT05...
Currently this is being done with a EVAL for each field and I would like to use arrays and a single EVAL statment.  Any Ideas as to how to do this?
Question by:tom

Expert Comment

ID: 24273411
Yes, you can set them up in an array.

What you do is create a data structure with the array and the fields overlaying the array.

*************** Beginning of data **************
D                 DS                            
D  FLDAR                         7S 0 DIM(10)  
D   FLD0                  1      7S 0          
D   FLD1                         7S 0          
D   FLD2                         7S 0          
D   FLD3                         7S 0          
D   FLD4                         7S 0          
D   FLD5                         7S 0          
D   FLD6                         7S 0          
D   FLD7                         7S 0          
D   FLD8                         7S 0          
D   FLD9                         7S 0          
D I               S              3  0          
  For I = 1 to 10;                          
    FLDAR(I) = I * (I + 1);                    
  *INLR = *ON;                                    
LVL 36

Accepted Solution

Gary Patterson earned 1500 total points
ID: 24276586
You can define each set of fields in a DS, and move from one DS to the other, provided the field lengths are the same.

- Gary Patterson

D  FLD            DS                            
D   FLD0                         9A          
D   FLD1                         9A          
D   FLD2                         9A          
D   FLD9                         9A
D   TXT           DS                            
D    TXT0                        9A          
D    TXT1                        9A          
D    TXT2                        9A          
D    TXT9                        9A         
  TXT = FLD;                                               

Open in new window


Author Closing Comment

ID: 31576590

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the below post we have mentioned the best hosting type for startups. Also, check out some of the superlative web hosting companies that are proposing affordable web hosting solutions to host your startup website.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month16 days, 19 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question