Example 4: Getting Information from Another File

An invoice header file contains a customer number (CUSTNO). Add the customer name (CUSNAM) to this file as a virtual field.

The customer name must be extracted from the customer master file which is called CUSTMST.

Step 1 - Define the Virtual Fields

 

 

     Seq    Name__________ Description______________________

      10    CUSNAM         Customer name

 

 

Step 2 - Input RPG Section "File Specifications"

FCUSTMST IF  E           K        DISK

Step 3 - Input RPG Section "External Record Format or Field Renames"

I*

I* VC_USING FIELDS((CUSNAM $$$$$$))

I*

IRCUSTMST

I              CUSNAM                         $$$$$$

Step 4 - Input RPG Section "Calculations After Input from File"

>

C*

C* VC_USING FIELDS(CUSTNO CUSNAM)

C*

C                     MOVE *BLANKS   CUSNAM

C                     MOVEL'N/AVAIL' CUSNAM

C           CUSTNO    CHAINRCUSTMST             70    70=IGNORED

Note: