7.27.3 DEF_MAP_EX and Calling a Procedure in a Service Program

When a DEF_MTH_EX does specify an ENTRYPOINT, it means that the external method being called is a procedure in a service program.

Only a maximum of one DEF_MAP_EX can specify FOR(*RESULT), as there can only be one return value for a procedure in a service program, but there can be none as not every procedure in a service program has a return value.

When a DEF_MAP_EX is used with such an associated DEF_MTH_EX these rules apply:

  • The FOR value controls both what is mapped to and from RDML and whether a parameter is passed by value or by reference.

  • In the case of *INPUT, the value is mapped from RDML before calling the external method and the parameter is passed by value.

  • In the case of *BOTH, the value is mapped from RDML before calling the external method, the parameter is passed by reference and the value is mapped back to RDML variables after calling the external method.

  • In the case of *OUTPUT, the parameter is passed by reference and the value is mapped back to RDML variables after calling the external method.

Important Note

TYPE(*SIGNED) FOR(*INPUT) is not supported. The IBM i operating system does not support C using its equivalent to RPG Signed passed by value to an RPG signed parameter.

Example 1

Define an argument that is a time to be passed in *USA format by value to a procedure:

Def_Map_Ex Name(CloseTime) For(*INPUT) Type(*TIME) Format(*USA)

Example 2

Define the result value that is a null-terminated string of maximum length of 999 characters not counting the null terminator for a procedure:

Def_Map_Ex Name(Conditions) For(*RESULT) Type(*VARCHAR) Length(999) Format(*NTS)

Example 3

Define an argument that is a float that will be passed back from a procedure:

Def_Map_Ex Name(Tolerance) For(*OUTPUT) Type(*FLOAT) Length(4)
  • No labels