VC_USING Examples

Some correct examples of VC_USING commands follow.

Example 1: Accumulate real fields TOT01 -> TOT05 into virtual field TOTAL:

    C*

    C* VC_USING FIELDS(TOT01 TOT02 TOT03 TOT04 TOT05 TOTAL)

    C*

    C                     Z-ADDTOT01     TOTAL

    C                     ADD  TOT02     TOTAL

    C                     ADD  TOT03     TOTAL

    C                     ADD  TOT04     TOTAL

    C                     ADD  TOT05     TOTAL

Some points to note about this example are:

If this example virtual field code section was actually compiled into the file I/O module it would look something like this:

  * FIELD REPLACEMENT VALUES USED FOR THIS SECTION OF USER CODE

  *

  *  Field name as     Field name as in   Internal field name

  *in file definition  user RPG code      used as replacement

  *------------------  ----------------   ------------------

  *     TOT01              TOT01              @F0001

  *     TOT02              TOT02              @F0002

  *     TOT03              TOT03              @F0003

  *     TOT04              TOT04              @F0004

  *     TOT05              TOT05              @F0005

  *     TOTAL              TOTAL              @F0006

  *

 C                     Z-ADD@F0001    @F0006

 C                     ADD  @F0002    @F0006

 C                     ADD  @F0003    @F0006

 C                     ADD  @F0004    @F0006

 C                     ADD  @F0005    @F0006

Note how the VC_USING command has been replaced by a series of comments that detail exactly what effect it has on the following code. Also note how all fields listed in the VC_USING command have been replaced by their "internal" names in the actual code section.

Example 2: Accumulate real fields TOT01 -> TOT05 into virtual field FULLTOTAL:

   C*

   C* VC_USING FIELDS(TOT01 TOT02 TOT03 

   C*                 TOT04 TOT05 (FULLTOTAL FFFFFF))

   C*

   C                     Z-ADDTOT01     FFFFFF

   C                     ADD  TOT02     FFFFFF

   C                     ADD  TOT03     FFFFFF

   C                     ADD  TOT04     FFFFFF

   C                     ADD  TOT05     FFFFFF

Some points to note about this example are:

If this example virtual field code section was actually compiled into the file I/O module it would look something like this:

  FIELD REPLACEMENT VALUES USED FOR THIS SECTION OF USER CODE

  *

  *  Field name as     Field name as in   Internal field name

  *in file definition  user RPG code      used as replacement

  *------------------  ----------------   -------------------

  *       TOT01              TOT01              @F0001

  *       TOT02              TOT02              @F0002

  *       TOT03              TOT03              @F0003

  *       TOT04              TOT04              @F0004

  *       TOT05              TOT05              @F0005

  *       FULLTOTAL          FFFFFF             @F0006

  *

 C                     Z-ADD@F0001    @F0006

 C                     ADD  @F0002    @F0006

 C                     ADD  @F0003    @F0006

 C                     ADD  @F0004    @F0006

 C                     ADD  @F0005    @F0006

Again the VC_USING command has been replaced by a series of comments that detail exactly what effect it has had on the following code. Also note how all fields listed in the VC_USING command have been replaced by their "internal" names, particularly the name "FFFFFF".