News
Abstract
RPG enhancement for string parameters to numeric BIFs such as %DEC, %INT, and %FLOAT. New values for EXPROPTS to allow blanks, and allow thousands separators.
Content
You are in: RPG Cafe > Fall 2020: Numeric BIF enhancements
Short URL: https://ibm.biz/rpgcafe_numeric_bif_enhancements
RPG Cafe: %DEC(blank), %DEC('-1,234.56')
Warning After you compile your program to use this enhancement, a runtime PTF is needed on any system where you run your program.
See PTFs below. |
New rules for string parameters for %DEC, %INT, etc.
- Use EXPROPTS(*ALWBLANKNUM) to allow an all-blank value.
- Use EXPROPTS(*USEDECEDIT) to allow digit separators, such as thousands separators.
- These keywords also affect the way XML-INTO and DATA-INTO handle the values for numeric fields and subfields.
Details
EXPROPTS(*ALWBLANKNUM)
With EXPROPTS(*ALWBLANKNUM), the character parameter for numeric built-in functions such as %DEC and %FLOAT return zero if the parameter is blank or empty. (Without EXPROPTS(*ALWBLANKNUM), these built-in functions fail with status code 105 if the character parameter is blank or empty.)
In this example, EXPROPTS(*ALWBLANKNUM) is specified. The parameter for %DEC is blank, and %DEC returns zero.
CTL-OPT EXPROPTS(*ALWBLANKNUM); DCL-S num PACKED(5 : 2); DCL-S string CHAR(20); string = *BLANKS; num = %DEC(string : 63 : 5); // num = 0
EXPROPTS(*USEDECEDIT)
With EXPROPTS(*USEDECEDIT), the character parameter for numeric built-in functions such as %DEC and %FLOAT can have digit separators. The DECEDIT keyword is used to determine the decimal point and digit separator character. (Without EXPROPTS(*USEDECEDIT), both the period and comma are considered to be the decimal point, and a string with digit separators such as '1,234,567.8' fails with status code 105 because it has three decimal points.)
In this example, EXPROPTS(*USEDECEDIT) is specified. The parameter for the DECEDIT keyword defaults to '.', so the period is the decimal point and the comma is the digit separator. The parameter for %DEC has thousands separators and a decimal point, and %DEC returns -1234567.89.
CTL-OPT EXPROPTS(*USEDECEDIT); DCL-S num PACKED(15 : 5); DCL-S string CHAR(20); string = '-1,234,567.89'; num = %DEC(string : 63 : 5); // num = -1234567.89
. .
. .
PTFs for 7.3 and 7.4, available in November 2020
7.3:
Warning: You need a runtime PTF on every system where the program runs. If the runtime PTF is not applied on the system where the program is running, a string with only blanks or with digit separators causes an exception.
- ILE RPG compiler: SI74612
- ILE RPG runtime: SI74559
7.4:
- ILE RPG compiler: SI74613
- ILE RPG compiler, TGTRLS(V7R3M0): SI74614
- ILE RPG runtime: SI74560
The PTFs will also be available with the Db2 for i Fix Packs. See Db2 for IBM i 2020 PTF Group Schedule.
RDi support
The next release of RDi will support this enhancement.
Documentation in the IBM Knowledge Center
The ILE RPG Reference and ILE RPG Programmer's Guide in the 7.3 and 7.4 IBM Knowledge Center are updated with full information about this enhancement. Start at the What's New Since 7.3 or What's New Since 7.4 section in the Reference.
- 7.3 Reference: What's new since 7.3: https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzasd/rpgrelv7r3post.htm
- 7.4 Reference: What's new since 7.4: https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzasd/rpgrelv7r4post.htm
Was this topic helpful?
Document Information
Modified date:
12 November 2020
UID
ibm16342819