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

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?
Thanks
tomAsked:
Who is Participating?
 
Gary PattersonConnect With a Mentor VP Technology / Senior Consultant Commented:
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         
                                              
C/FREE                                          
  TXT = FLD;                                               
 

Open in new window

0
 
rwardCommented:
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.

DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++
*************** 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                                              
D I               S              3  0          
C/FREE                                          
  For I = 1 to 10;                          
    FLDAR(I) = I * (I + 1);                    
  EndFor;                                      
                                               
  *INLR = *ON;                                    
0
 
tomAuthor Commented:
solved
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.