Previous Topic: Option T

Next Topic: Model Value YRP4SGN

RPGIV User Source

Functions generated with source type RP4 should include only user source of the type RP4. This user source lets you take advantage of some features of the RPGIV language that are not currently available in the CA 2E model generated source. An example is the use of pointer variables.

RPGIV user source must reside in QRPGLESRC. The rules for naming parameter variables in RPGIV user source are the same as for RPGIII user source. You can include all RPGLE specification types in the source member. CA 2E sorts the specification types into their appropriate positions within a program.

CA 2E codes the source in the normal order for RPGLE specifications, which is:

  1. H specification

    Any H specification lines that you add are placed after the default H specification lines generated for the owning function source. The H specifications are taken from the YRP4HSP and YRP4HS2 model values.

  2. F specifications
  3. D specifications
  4. I specifications
  5. C specifications
  6. O specifications
  7. P specifications, including any contained D and C specifications.
  8. Arrays

CA 2E treats the first RPG calculation specifications, which are not part of a subroutine, as the instance code. For repeated calls to an EXCUSRSRC function, CA 2E generates the code on every call to the function at the point indicated by the action diagram.

CA 2E automatically inserts into the ZZINIT subroutine any C specifications that follow a subroutine but are not part of a subroutine. The order of specification is:

  1. Instance (mainline) code C specifications
  2. C specifications for subroutines called by instance code
  3. Initialization C specifications

Note: In version 7.0, parameter fields (fields prefixed with #O, #I and #B) are recognized only in the Factor One, Factor Two, and Result positions of the RPGLE calculation specifications that are part of the instance code. They can be in upper, lower, or mixed case. They are not currently recognized in free-format expressions.

The following example shows an RPGIV function called Get Key that is defined into EXCUSRSRC Function another CA 2E standard function. The EXCUSRSRC function has three parameters:

IOB

Parameter

GEN name

I

Job date

JDT

I

User name

USR

O

Encoded file key

ABVN

The sample shows user source coded as a prototyped procedure with several distinct sections of code:

The user source procedure code does not need to conform to the CA 2E model naming conventions. Field names used only in the procedure can have the full 14-characters that the RPGIV language allows. Also, #I and #O must be within C specification lines and not within free-format expressions like the EVAL statement.