There are several useful system interfaces (APIs) provided on the IBM AS/400 system. These interfaces provide access to the properties of parameters passed to subprocedures. All of these interfaces begin with the letters CEE. When an API begins with these letters, it is bound into the program as an in-line function. This means that the actual code for the API is embedded into the program module; a call to the API is not generated.
When a subprocedure requirement calls for an optional parameter, or a variable-length parameter, the OPDESC keyword should be specified on the procedure name definition statement. This keyword is required on both the prototype and the procedure interface.
The OPDESC keyword causes additional information about each parameter to be passed to the called procedure. RPG IV does not provide conventional methods for accessing this information. Therefore, system interfaces must be called to retrieve the operational descriptions.
The basic operational description API is CEEDOD (Retrieve Operational Descriptor). This API has seven parameters (six of which are required). The sixth parameter is the one that is frequently used within RPG programs.
The naming for this API is generic to the AS/400 ILE runtime environment. It is possible to use an alternative name, however, to evoke this API. Rather than call CEEDOD directly using the CALLB(D) operation, a prototype for the API can be created and used to evoke the interface. That prototype can be named more clearly than the API name. A simple prototype for CEEDOD is shown in Figure 10.10.
.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++++++++++++ 0001 D GetOpDesc PR ExtProc('CEEDOD') 0002 D ParmPos 10I 0 Const 0003 D o_desctype 10I 0 0004 D o_datatype 10I 0 0005 D o_descinf1 10I 0 0006 D o_descinf2 10I 0 0007 D o_fieldlen 10I 0 0008 D o_errors 12A OPTIONS(*OMIT)
To call CEEDOD using the prototype shown in Figure 10.10, specify the CALLP operation with GETOPDESC specified for the procedure name. Figure 10.11 shows this technique using the MAKEUPPER user-written subprocedure.
Figure 10.11: Using operational descriptor.
See Appendix D for a complete listing of the examples used in this chapter.