News
Abstract
Support fields that can be treated as a boolean type
Content
You are in: IBM i Technology Updates > Welcome to IBM Integrated Web Services for i Technology Updates > Support for boolean types
What is it?
Before this update there was no way to indicate a field is of type boolean. For example, assume that an ILE RPG procedure is defined with parameters that contain an RPG indicator - a one-byte character field that contains either '1' (on) or '0' (off). The compiler generates program interface information (PCML) where the indicator is treated as a character field as follows (partial content):
<data name="theIndicator" type="char" length="1" usage="inherit" />
If you wanted to set the field, theIndicator, in a JSON request, it would look something like:
{
...
"theIndicator": "1"
}
Where the preferred way would be to send the request as a boolean data type as follows:
{
...
"theIndicator": true
}
In COBOL, PIC 1 fields result in unsupported data type errors when the program interface information is generated:
<data name="P1B" usage="inputoutput" />
<!-- Error: unsupported data type (E) -->
New support in the RPG and COBOL compilers has been added to indicate in the generated PCML what fields are to be treated as boolean. Program interface information generated includes an attribute to indicate whether the field is boolean, as shown in the following example:
<data name="P1B" type="char" length="1" boolean="true" usage="inputoutput" />
IWS uses this information to map the field to a boolean type.
For COBOL, after the COBOL PTF is applied to the system, there is no additional steps to take other than to recompile your code and redeploy the web service.
For RPG, after applying one or more PTFs, you will need to indicate in your code the version *V8 in the PGMINFO keyword. Alternatively, instead of specifying the version parameter, you can also control the PCML version by specifying the QIBM_RPG_PCML_VERSION environment variable. For example,
ADDENVVAR QIBM_RPG_PCML_VERSION VALUE('8.0') LEVEL(*SYS)
In either case, you will need to recompile the RPG code and redeploy the web service.
You can also modify the PCML for a web service manually if you want character or numeric fields to be considered a boolean data type by adding the boolean="true" attribute to the PCML data element corresponding to the field. If a character field length is less than 5, the field is set to '1' (true) or '0' (false). For character fields with lengths greater than 4, the field is set to 'true' or 'false'. For numeric fields, the result is true if the value is not zero, and false if the value is zero.
Why use it?
To ensure client applications know that a field is a boolean data type and thus allow the natural processing of the field in client applications.
Availability
The support is enabled in the following PTFs:
V7R5M0 SI83122, SI83130 (COBOL), SI83480 (RPG), SI83468 (RPG)
V7R4M0 SI83123, SI83129 (COBOL), SI83497 (RPG), SI83471 (RPG)
V7R3M0 SI83124, SI83128 (COBOL), SI83429 (RPG)
[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"HW1A1","label":"IBM Power Systems"},"Component":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]
Was this topic helpful?
Document Information
Modified date:
12 May 2023
UID
ibm16989885