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

Posted on 2009-04-30
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
    LVL 4

    Expert Comment

    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 34

    Accepted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Suggested Solutions

    Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
    This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now