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:
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.
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:
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:
* PROCEDURE PROTOTYPE ) Inserted into D Get_Key PR 10 ) inline D-specs D Job_Date 7 0 VALUE ) D Job_User 10 VALUE ) * * USER_DEFINED FIELDS D Key_Date S 7 0 D Key_User S 10 D Enc_Val S 10 * * IN-LINE PROCESSING * * Use job date and user name as input parameters to Get_Key proc. C Move #ijdt Key_Date ) C Move #iusr Key_User ) Inserted into C Eval Enc_Val = Get_Key(Key_Date:Key_User) ) inline C-specs * ) * Return encoded value as parameter from user source function ) C Move Enc_Val #oadvn ) * ) * * PROCEDURE DEFINITION ) PGet_Key B ) *- - - - - - - - - - - - - - - - - - - -- - - - - - - * ) DGet_Key PI 10 ) D Job_Date 7 0 VALUE ) D Job_User 10 VALUE ) Inserted into * ) source after D Job_Date_Ptr S * ) all C-specs and D Job_Date_Char S 7 Based(Job_Date_Ptr) ) all system- D File_Key S 10 ) generated * ) procedure code C Move Job_Date Job_Date_Char ) C Eval File_Key = %Subst(Job_User:3:2) + ) C %Subst(Job_Date_Char:3:3) + ) C %Subst(Job_User:6:2) + ) C %Subst(Job_Date_Char:1:3) ) C Return File_Key ) P E )
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.
| Copyright © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |