Reputation: 2009
Note this code:
DCL-S PGM1_PARM1 CHAR(10) INZ('param val ')
DCL-PR @PROGRAM1 EXTPGM('PGM1');
PARAM1 CHAR(10);
END_PR;
@PROGRAM1(PGM1_PARM1);
Program will always be called with the same param. I tried adding INZ
to parameter declaration in DCL-PR
but compiler started to yell at me about invalid INZ
keyword.
Is there a way to set default calling value to DCL-PR
?
Upvotes: 0
Views: 397
Reputation: 3674
If you want callers to be able to call your program without passing the parameter, add OPTIONS(*NOPASS) to the parameter in the prototype. To test whether the parameter was passed, code like this in the code for the program itself:
DCL-S PARAM1 CHAR(10) INZ('param val ');
DCL-PI @PROGRAM1;
PARAM1_PASSED CHAR(10) OPTIONS(*NOPASS);
END_PI;
if %parms >= %parmnum(PARAM1_PASSED);
PARAM1 = PARAM1_PASSED;
... or just ignore it if you don't care what they passed
endif;
Now callers can just code
@PROGRAM1();
Upvotes: 2