With the introduction of ILE, HLLs can not only make external program calls and static procedure calls, but can also call MI instructions which expose bound program access interfaces to HLLs. In the documentation of the ILE RPG, MI instructions are often metioned as system-builtins.
IMHO, the benifits of using MI instructions in HLLs are the following:
Note that this subproject provides only usage examples of MI instructions for ILE CL, but does not provide copybooks for ILE CL. Although in V6R1, ILE CL programs began to have the ability to include other source members via the INCLUDE command, and in V7R1 the nested INCLUDE support was added to ILE CL. But it's a sorrow that we have no access to an IBM i server with V6R1 or V7R1 installed to test what we produce.
Contents
Or check them out from the project's svn repository like the following:
svn export https://i5toolkit.svn.sourceforge.net/svnroot/i5toolkit/rpg/ svn export https://i5toolkit.svn.sourceforge.net/svnroot/i5toolkit/cobol/ svn export https://i5toolkit.svn.sourceforge.net/svnroot/i5toolkit/cl/
/* * * @file t147.rpgle * * Test of _MATMATR1. Materialize HMC info. */ /if defined(*crtbndrpg) h dftactgrp(*no) /endif /copy mih-pgmexec /copy mih-spt d tmpl ds likeds(matmatr_hmc_t) d based(ptr) d ptr s * d len s 10i 0 d opt s 2a inz(x'0204') /free ptr = modasa(8); tmpl.bytes_in = 8; matmatr(tmpl : opt); len = tmpl.bytes_out; ptr = modasa(len); tmpl.bytes_in = len; matmatr(tmpl : opt); // check the returned HMC info *inlr = *on; /end-free /* * * The returned HMC info might be like the following: * @code * > EVAL TMPL.HMC_INFO.INFO(1):x 100 * 00000 486D6353 7461743D 313B4873 634E616D * 00010 653D3730 34324352 342A3036 37344542 * 00020 423B4873 63486F73 744E616D 653D6C6F * 00030 63616C68 6F73743B 48736349 50416464 * 00040 723D3132 372E302E 302E313B 48736341 * 00050 64644950 733D3B48 4D434164 64495076 * 00060 36733D3B ........ ........ ........ * @endcode * * Convert the above result into ASCII encoding, then the * result should be like the following: * 'HmcStat=1;... ...' */
To compile this program into a program object or a module object, use CL command CRTBNDRPG or CRTRPGMOD with the INCDIR parameter set to
INCDIR('/usr/local/include/rpg')
/* * * @file cbl005.cblle * * Test of: * - _MODASA * - _MATPGMNM */ process NOMONOPRC. id division. program-id. cbl005. environment division. configuration section. special-names. copy mih-lnktyp. data division. working-storage section. 01 ptr pointer. 01 asf-size pic 9(9) usage comp-4. 01 zer constant as x"00". linkage section. copy mih-pgmexec. copy mih-pgmmng. 01 pgm-info type matpgmnm-t. procedure division. main-pgm. move 80 to asf-size. call "_MODASA" using by value asf-size returning into ptr. call "_PROPB" using by value ptr by value zer by value asf-size. set address of pgm-info to ptr. move 80 to bytes-in of pgm-info. call "_MATPGMNM" using by reference pgm-info. display "i'm " function trimr (context-name of pgm-info) "/" program-name of pgm-info. see-you. stop run. * output * i'm LSBIN/CBL005
To compile this program into a program object or a module object, use CL command CRTBNDCBL or CRTCBLMOD with the INCDIR parameter set to
INCDIR('/usr/local/include/cobol')
/* Compile from a stream source file */ CRTBNDCBL PGM(ABC) SRCSTMF('/home/a-cobol-pgmr/my-cbl-src/abc.cblle') INCDIR('/usr/local/include/cobol') /* Compile from a source member */ CRTBNDCBL PGM(ABC) SRCSTMF('/qsys.lib/my_src.lib/cbl_src.file/abc.mbr') INCDIR('/usr/local/include/cobol')
/* * + * @file cl005.clle + * + * Test of the following system builtins: + * - _CTD (Compute Time Duration) + * + * Call this program like the following: + * CALL CL005 ('15.11.05' '11.10.03') + * + * The result should be: &DURATION = 040102. + */ PGM PARM(&EVENING &MORNING) DCL VAR(&EVENING) TYPE(*CHAR) LEN(8) /* end time */ DCL VAR(&MORNING) TYPE(*CHAR) LEN(8) /* start + time */ DCL VAR(&ISODURTMPL) TYPE(*CHAR) LEN(298) + VALUE(X'0000012A000100020002000000080008000+ 0000000000000000000000000000000000000000000+ 0000000000010000020000000000000000000000000+ 0180000008C00000015000000000000000000000000+ 0000000000000000000000000000000000000000000+ 0000000000000000000000000000000000000000000+ 0000000000000000000000000000000000000000000+ 0000000000000000000000000000000000000000000+ 0000000000000000000000000000000000040000001+ 8003C00000000000000000000000000000000000000+ 0000000000000000000000000000000000000000000+ 0000000000000000000000000000000000000000000+ 0000000000000000000000000000000000000000000+ 0000000000000000000000000000000000000000000+ 00') /* instruction template to compute + ISO time duration */ DCL VAR(&DURATION) TYPE(*DEC) LEN(6 0) CALLPRC PRC('_CTD') PARM((&DURATION *BYREF) + (&EVENING *BYREF) (&MORNING *BYREF) + (&ISODURTMPL *BYREF)) ENDPGM