parameters passed from CL
to RPG
are passed by address. So any value placed in the parameter by the RPG
program will be returned to the CL
program.
here is a CL program calling RPG:
PGM
dcl &rtndate *char 10
/* call RPG program. RPG program sets &rtnDate parm to date of yesterday */
/* in *ISO format. */
call test0290r parm(&rtnDate)
SNDPGMMSG MSG('yesterday date:' *BCAT &RTNDATE)
ENDPGM
and the called RPG program:
** test0290r: return yesterdate as iso date.
h option(*srcstmt:*nodebugio)
** --------------------------- test0290r --------------------
** test0290r: return yesterdate as iso date.
dtest0290r pr extpgm('TEST0290R')
d outDate 10a
** --------------------------- test0290r --------------------
** test0290r: call open api using ifs_openNew.
dtest0290r pi
d outDate 10a
d ch80 s 80a varying
d yesterday_date s d
/free
yesterday_date = %date(%timestamp( )) - %days(1) ;
outDate = %char(yesterday_date:*iso) ;
*inlr = '1' ;
return ;
/end-free