Calling ILE procedures

You can follow these steps to prepare and call ILE procedures from your PASE for i programs.

When you call ILE procedures from your PASE for i programs, you should first prepare the procedure by enabling it for teraspace, converting text to the appropriate CCSID, and setting up variables and structures.

  1. Enable ILE procedures for teraspace

    All ILE modules that you call from PASE for i must be compiled with the teraspace option set to *YES. If your ILE modules are not compiled in this way, you will receive the MCH4433 error message (Invalid storage model for target program &2) in the job log for your PASE for i application.

  2. Convert text to appropriate CCSID

    Text being passed between ILE and PASE for i might need to be converted to the appropriate CCSIDs before being passed. Not doing such conversions causes your character variables to contain undecipherable values.

  3. Set up variables and structures
    To make calls to ILE from your PASE for i programs, you need to set up variables and structures. You must ensure that the required header files are copied to your AIX® system, and you must set up a signature, a result type, and an argument list variable:
    • Header files: Your PASE for i program should include the header files as400_types.h and as400_protos.h to make calls to ILE. The as400_type.h header file contains the definition of the types used for i5/OS system-unique interfaces.
    • Signature: The signature structure contains a description of the sequence and types of arguments passed between PASE for i and ILE. The encoding for the types mandated by the ILE procedure that you are calling can be found in the as400_types.h header file. If a signature contains fixed-point arguments shorter than 4 bytes or floating point arguments shorter than 8 bytes, your ILE C code needs to be compiled with the following pragma:
      #pragma argument(ileProcedureName, nowiden)

      Without this pragma, standard C linking for ILE requires 1- and 2-byte integer arguments to be widened to 4 bytes and requires 4-byte floating-point arguments to be widened to 8 bytes.

    • Result type: The result type is straightforward and works much like a return type in C.
    • Argument list: The argument list must be a structure with the correct sequence of fields with types specified by entries in the signature array. You can use the size_ILEarglist() and build_ILEarglist() APIs to dynamically build the argument list based on the signature.
To call ILE procedures from your PASE for i programs, make the following API calls in your code:
  1. Load the bound program into the ILE activation group that is associated with the procedure that started PASE for i. You use the _ILELOADX() API to do this.

    This step can be unnecessary if the bound program is already active in the activation group that started PASE for i. In this case, you can proceed to the _ILESYMX() step, using a value of zero for the activation mark parameter to search all symbols in all active bound programs in the current activation group.

  2. Find the exported symbol in the activation of the ILE bound program and return a 16-byte tagged pointer to the data or procedure for the symbol. You use the _ILESYMX() API to do this.
  3. Call the ILE procedure to transfer control from your PASE for i program to the ILE procedure. You use the _ILECALL() or _ILECALLX() API to do this.