News
Abstract
RPG enhancement delivered through PTFs in the spring of 2023. New built-in functions %PASSED and %OMITTED
Content
You are in: RPG Cafe > RPG Cafe: Spring 2023: Parameter built-in functions %PASSED and %OMITTED
Short URL: https://ibm.biz/rpgcafe_spring_2023_parm_bifs
Spring 2023: Parameter built-in functions %PASSED and %OMITTED
- %PASSED: Test whether a parameter was passed, but not omitted
- %OMITTED: Test whether *OMIT was passed for a parameter
Details
%PASSED
Built-in function %PASSED(parameter_name) returns *ON when the parameter was passed and not omitted. When %PASSED(parameter_name) is true, the parameter is available to be used.
dcl-pi *n; p1 int(10) options(*omit); p2 varchar(20) const options(*nopass); p3 varchar(20) const options(*nopass : *omit); end-pi; // p1 is required, but *OMIT could be passed if %passed(p1); dsply ('Parameter p1 = ' + %char(p1)); else; dsply ('Parameter p1 is not available'); endif; // p2 is optional if %passed(p2); dsply ('Parameter p2 = ' + p2); else; dsply ('Parameter p2 is not available'); endif; // p3 is optional, and *OMIT could be passed if %passed(p3); dsply ('Parameter p3 = ' + p3); else; dsply ('Parameter p3 is not available'); endif;
Before %PASSED(parameter_name) was available, correctly coding to determine whether the parameter was passed required combinations of %PARMS, %PARMNUM, and %ADDR.
// Testing a parameter with OPTIONS(*NOPASS : *OMIT) // before %PASSED was available if %parms() >= %parmnum(p3) and %addr(p3) <> *null; dsply ('Parameter p3 = ' + p3); else; dsply ('Parameter p3 is not available'); endif;
%OMITTED
Built-in function %OMITTED(parameter_name) returns *ON when *OMIT was passed. When %OMITTED(parameter_name) is true, the parameter must not be used.
dcl-pi *n; p1 int(10) options(*omit); p2 varchar(20) const options(*nopass : *omit); end-pi; // p1 is required, but *OMIT could be passed if %passed(p1); dsply ('Parameter p1 = ' + %char(p1)); elseif %omitted(p1); dsply ('*OMIT was passed for parameter p1'); else; snd-msg *escape 'p1 is a required parameter but ' + 'no parameter was passed'; endif; // p2 is optional, and *OMIT could be passed if %passed(p2); dsply ('Parameter p2 = ' + p2); elseif %omitted(p2); dsply ('*OMIT was passed for parameter p2'); else; dsply ('No parameter was passed for p2'); endif;
. .
. .
PTFs for 7.4, and 7.5
7.4:
- ILE RPG compiler: 5770WDS SI83497
7.5:
- ILE RPG compiler: 5770WDS SI83480
- ILE RPG compiler, TGTRLS(V7R4M0): 5770WDS SI83496
The PTFs are also available with Db2 for i Fix Packs. See Db2 for IBM i 2023 PTF Group Schedule.
RDi support
A later update for RDi will support these enhancements.
Documentation
The 7.4, and 7.5 ILE RPG Reference and ILE RPG Programmer's Guide are updated with full information about these enhancements. Start at the "What's new since 7.4", or "What's new since 7.5" section in the Reference.
- What's new since 7.4? https://www.ibm.com/docs/en/ssw_ibm_i_74/rzasl/rpgrelv7r4post.htm
- What's new since 7.5? https://www.ibm.com/docs/en/ssw_ibm_i_75/rzasl/rpgrelv7r5post.htm
Was this topic helpful?
Document Information
More support for:
Rational Development Studio for i
Component:
IBM i, Programming ILE Languages
Software version:
7.4.0, 7.5.0 and future releases
Operating system(s):
IBM i
Document number:
6982093
Modified date:
11 May 2023
UID
ibm16982093