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:

  • In the external field rename section the $$$$$$ name has been used to cause the internal name of CUSNAM to be inserted at the correct point without replacing the CUSNAM value which must remain unchanged in this context.
  • A simpler solution to this example would be to create an access route from the invoice header file to the customer master file with a 1 to 1 relationship and define a predetermined join field on the access route to receive the customer name. For further information on access routes and predetermined join fields refer to What Is a Predetermined Join Field?.
  • No labels