Defining service fields
Service fields are used in service interfaces to map, transform, and modify the data that is used between a z/OS® Connect API and the underlying z/OS application that the API utilizes. Customizing service fields allows you to provide metadata and optimize payloads for service interfaces.
Before you begin
zosConnect-2.0 Applies to zosConnect-2.0.
If the service interface file is not already opened in the service project interface in Project Explorer, go to the service-interfaces/ folder for your project and double-click the service interface file (.si).
From the service project interface, you can edit service fields by using the Edit field wizard. Access the Edit field wizard for a given service field by right-clicking a service field, and selecting Edit field. You can also access the Edit field wizard by selecting a service field, and then clicking the Edit field icon in the Service Interface Editor.

The options of the Edit field wizard change according to the data type of the service field being edited.
To learn about commonly used Edit field wizard options, see Overview of the Edit Field wizard. To learn about other capabilities of the Edit field wizard, see the sections following this overview.
When reimporting data structures, ensure that the definitions for service fields remain preserved. Errors that are caused by reimporting data structures are indicated by a symbol in the service project editor, or in the Problems view of the API toolkit.
Overview of the Edit Field wizard
- Interface rename allows you to provide a different name to be used for the IBM® z/OS Connect service.
- Override data type allows you to specify a new data type at the service level to perform conditional mediation between application and API data.
- Default value type allows you to specify the data type that is used for a default value.
- Default value is a datatype-specific value that is used by the service at runtime whenever there is no appropriate service field value that is specified by an API request or response.
- Code page conversion can be toggled to convert service response code to CHAR data type.
- Business description metadata can be provided to clearly indicate the purpose of the service field as it relates to a service.

- Response service interfaces cannot contain default values in fields. If a default value is specified for a response service interface, a message is issued in the Problems view to assist problem resolution.
- The default value can be overridden if a value is assigned in the API editor during API creation. If a value is specified in the payload at runtime, the runtime value overrides the value that was specified at development time. To prevent the assigned default value from being overridden at runtime, set the field to be omitted from the interface.
- The Code page conversion checkbox is only visible when the Data type field has a value of CHAR. To convert the code page for the CHAR type, select the Code page conversion checkbox; otherwise, clear it.
Defining array counters
Array counters can be used to optimize the request and response JSON for services that use arrays. For request interfaces, an array counter is automatically set to the number of array entries received in the request JSON for the respective array. For response interfaces, an array counter indicates the number of array entries to include in the response JSON from the respective array.
Array counters are defined by specifying a numeric service field to be used as a counter for fixed-length or variable-length arrays.
The following conditions must be met for a service field to be used as an array counter:
-
Defining array counters requires installation of the minimum z/OS Connect Server and API toolkit versions that support the array counters capability. To learn more about z/OS Connect version requirements for capabilities, see IBM z/OS Connect capabilities compatibility.
- Only integer service fields can be used for array counters.
- The array counter service field must reside in the same data structure as the array it counts for.
- The array counter cannot be an
OCCURS DEPENDING ONor aREFERobject. - Array counters cannot be used to count more than one array.
- The array counter must be located before the array it counts for in the service data structure.
- If the array that is using an array counter has a parent array in the service data structure, then the array counter must also have the same immediate parent array.
- If the array has a parent
REDEFINES, the array counter must also have the same immediate parentREDEFINES.
Service fields that do not meet this criteria will not be listed for selection when editing an array in the Service Interface Editor.
- Counted by indicates a numeric field that specifies the number of
sequential entries that are used in the array. This count always starts from the first entry of the
array.
To change a counted array back to a noncounted array, select the empty line that is provided in the drop-down list for the Counted by field.
- Minimum items defines the minimum number of expected array entries. This
minimum is expressed as
minItemsin the JSON schema that corresponds to the service interface.

- Counters specify the number of sequential array entries in use by a service, starting with and including the first entry.
- When setting a counter for an array, the minimum expected number of array entries can be
customized. This minimum is reflected in the generated JSON schema (
minItems).- To enforce the minimum number of array occurrences for API requests and responses, you must enable the Enforce minimum array occurrence options in your service project. To learn how to enforce minimum array occurrences, see Service-level data conversion customization.
The following example of a service interface demonstrates where an array counter,
F_COMMENT_CNT, can be used to define the number of F_COMMENT array
entries within a service interface. Also included in this example is a fixed-length array,
F_ROUTINGCODE, which is counted by F_ROUTINGCODE_CNT.

Defining Boolean fields
Service fields can be exposed in JSON payloads as type Boolean to create more easily consumable APIs. Boolean service fields allow for the definition of specific request and response conditions to process true or false values for a given service field, while leaving the underlying COBOL or PL/I application field values unchanged.
To expose a given service field as Boolean, select the Boolean option in the Override data type property of the Edit Field wizard.
The following conditions must be met for a service field to be overridden as type Boolean:
- Overriding service fields as type Boolean requires installation of the minimum IBM z/OS Connect server and API toolkit versions that support the Boolean override capability. To learn more about IBM z/OS Connect version requirements for capabilities, see IBM z/OS Connect capabilities compatibility.
- The application data type for the service field is CHAR.
- If the application data type for the service field is not CHAR:
- The service field's application data type must not be Float or Double.
- For decimal service field data types, decimal scale must be set to 0 so that fields can be read as integers.
- PL/I data types that are set to
VARYINGcannot be overridden as Boolean service fields.
Service fields that do not meet this criteria will not display the option to be overridden to Boolean in the Service Interface Editor.
- Under the Request tab:
- The True value type and False value type field
properties determine how service request JSON values are transformed into application data. True and
false request values can be defined with the following options:
- Single values use a precise value to determine if a service field value is true or false. Single values must be of the same datatype as the Original data type, unless hexadecimal values are used.
- High values are byte values consisting of all
0xFF. - Low values are byte values consisting of all
0x00.
- The True value type and False value type field
properties determine how service request JSON values are transformed into application data. True and
false request values can be defined with the following options:
- Under the Response tab:
- The True value type and False value type field
properties define how service field values are determined as true for an API response. In addition
to Single values, High values, and Low
values options, true and false response values can be defined with the following
additional options:
- Range of values uses a specified lower and upper bound value to determine if a service field value is true or false. Value ranges are inclusive and must be of the same data type as the Original data type, unless hexadecimal values are used.
- Multiple values consist of a delimited set of values that determine if a service field value is true or false. You can choose the delimiter that is used between values.
- The True value type and False value type field
properties define how service field values are determined as true for an API response. In addition
to Single values, High values, and Low
values options, true and false response values can be defined with the following
additional options:

Once a service field has been overridden as type Boolean, it is marked in the Data
Type column of the service project interface as Boolean, in parentheses. Also, when looking at
service fields by using the API field-mapping editor, fields that are overridden as type Boolean are
listed as Boolean fields.
- For the JSON request and response payload, the only valid values are true and false, without single or double quotation marks. Any values other than true and false cannot be used.
- If a service response value does not match either of the specified true or false conditions, an
API response of
nullis issued instead.
The following example demonstrates how a service field that is overridden as type Boolean appears
in the Service Interface Editor. In this example, the
F_AVAILABLE service field is overridden to express a CHAR value as a Boolean data
type in the resulting API request and response JSON.

Defining Date fields
Service fields can be exposed and consumed in JSON payloads as date string patterns in order to create effective APIs that use validated dates. Date service fields allow for the exposing of host dates as OpenAPI™ 2.0 compliant dates, while leaving the underlying COBOL or PL/I application field values unchanged.
To override a given service field as a Date, select the Date option in the Override data type property of the Edit Field wizard.
-
Overriding service fields as dates requires installation of the minimum z/OS Connect server and API toolkit versions that support the date override capability. To learn more about z/OS Connect version requirements for capabilities, see IBM z/OS Connect capabilities compatibility.
- CICS CHAR containers cannot be redefined as a Date service field.
- In the Host date pattern field of the Edit Field wizard, you can type the date pattern of an underlying application field. By pressing Ctrl + Space, content assist suggests matching date components that are applicable to your pattern.
- Alternatively, you can click the insert... button next to the Host date pattern field. A dialog box opens containing all available date components. Select a component and click OK to insert the date component at the current cursor position in the Host date pattern field.

- Top-level data structures cannot be overridden as characters by using the Redefine as CHAR field function of the Service Interface Editor.
- The Redefine as CHAR field function applies only to STRUCT type
application fields that meet the following conditions:
- The STRUCT is not already a redefining field.
- The STRUCT does not contain redefining fields, also known as nested redefines.
- The STRUCT does not contain ARRAY fields.
- All numeric fields in the STRUCT are zoned decimal with
sign is separate
is signed. - All fields in the STRUCT have the same encoding. For example, all SBCS, all Unicode, or all DBCS.
- The following additional properties apply to service fields that are overridden as CHAR fields.
- The redefining field that is created by the Redefine as CHAR field function is considered a
User defined field
, and can be later removed by using the Remove user defined field context menu action. - The redefining field by the Redefine as CHAR field that is created function will be preserved
during data structure re-import if the following conditions are met:
- The redefined STRUCT still exists in the reimported data structure.
- The redefined STRUCT still satisfies the requirements for the Redefine as CHAR field function.
- The redefining field that is created by the Redefine as CHAR field function is considered a
- Some examples that are featured in this section use the Redefine as CHAR field function. This capability is only required to enable the definition of STRUCT as character groups, and is not required to override existing numeric and character fields as dates.
- For requests, the host date pattern is used to convert a JSON date value to a host date value. For responses, the host date pattern is used to convert a host date value to a JSON date value.
- Default JSON data types can be overridden where necessary by using the data transformation function of the z/OS Connect API toolkit. To learn more, see COBOL to JSON schema mapping and PL/I to JSON schema mapping.
- For requests, an invalid JSON date value results in an HTTP response code 400 that includes either message GMOMW0024E or GMOMW0025E. For responses, an invalid host date value causes the field to be omitted from the JSON, and message GMOMW0026E is issued by the z/OS Connect Server.
- Services that are updated to use date fields must be reimported into APIs that use those services. When reimporting services that use date fields, the impact analysis view specifies which APIs are affected and how.
The following table contains a list of accepted host date patterns:
| Component name | Component syntax | Description |
|---|---|---|
| Day of Month | dd | Two-digit day of the Month. |
| Day of Year | DDD | Three-digit ordinal Day. |
| Month of Year | MM | Two-digit month of the Year. |
| Year | yyyy | Four-digit Year. |
| Year of Century | YY | Two-digit Year. This component must be followed by a Century component. |
| Century | CC | Two-digit century. This component must be preceded by a Year of Century component. |
Literal ('') |
'value' | Single quotation marks that contain a literal that consists of one or more characters.
Characters in a quoted literal are not parsed as date pattern components. Example:
|
Hex literal (%'') |
%'hex value' | A literal consisting of one or more hex-encoded bytes. Hex literals are not supported for
numeric fields. Example: |
Literal escape (\) |
\character | An escaped literal consisting of one character. Example: |
| Component name | Component syntax | Description |
|---|---|---|
| Day of Month | dd | Two-digit day of the Month. |
| Day of Year | DDD | Three-digit ordinal Day. |
| Month of Year | MM | Two-digit month of the Year. |
| Year | yyyy | Four-digit Year. |
| Year of Century | YY | Two-digit Year. This component must be followed by a Century component. |
| Century | CC | Two-digit century. This component must be preceded by a Year of Century component. |
Literal ('') |
'value' | Single quotation marks that contain a literal consisting of one or more characters.
Characters in a quoted literal are not parsed as date pattern components. Example:
|
Hex literal (%'') |
%'hex value' | A literal consisting of one or more hex-encoded bytes. Hex literals are not supported for
numeric fields. Example: |
Literal escape (\) |
\character | An escaped literal consisting of one character. Example: |
The following table contains all COBOL fields that are acceptable for a Date override. Only the following COBOL field types might be used for a Date override:
/or a
-, that can be used for Host Date patterns.
| Field type | Example declarations | Example Host Date patterns |
|---|---|---|
| PIC [S]9(n) USAGE COMP |
05 YYYYDDD PIC [S]9(7) COMP 05 YYYYMMDD PIC [S]9(8) COMP |
yyyyDDD yyyyMMdd |
| PIC [S]9(n) USAGE COMP-3 |
05 YYYYDDD PIC [S]9(7) COMP-3 05 DDMMYYYY PIC [S]9(8) COMP-3 |
yyyyDDD ddMMyyyy |
| PIC [S]9(n) USAGE DISPLAY |
05 YYYYDDD PIC [S]9(7) DISPLAY 05 MMDDYYCC PIC [S]9(8) DISPLAY |
yyyyDDD MMddYYCC |
| PIC X(n) USAGE DISPLAY |
05 MMDDYYYY PIC X(8) DISPLAY 05 MM-DD-YYYY PIC X(10) DISPLAY 05 MM-DD-YYYY PIC 99/99/9999 DISPLAY |
MMddyyyy MM/dd/yyyy MM/dd/yyyy |
| PIC N(n) USAGE NATIONAL |
05 YYYYMMDD PIC N(8) NATIONAL 05 YYYY-MM-DD PIC N(11) NATIONAL 05 YYYY-MM-DD PIC 99/99/9999 NATIONAL |
MMddyyyy yyyy年MM月dd日 yyyy/MM/dd |
| PIC X(n) USAGE DISPLAY-1 |
05 YYYYMMDD PIC X(10) DISPLAY-1 05 YYYY-MM-DD PIC X(20) DISPLAY-1 |
MMddyyyy yyyy年MM月dd日 |
| PIC 9(n) USAGE NATIONAL |
05 YYYYDDD PIC 9(7) NATIONAL 05 YYCCMMDD PIC 9(8) NATIONAL |
yyyyDDD YYCCmmdd |
| PIC S9(n) USAGE NATIONAL SIGN [LEADING|TRAILING] SEPARATE |
05 YYYYDDD PIC S9(7) NATIONAL SIGN LEADING SEPARATE 05 YYCCMMDD PIC S9(8) NATIONAL SIGN TRAILING SEPARATE |
yyyyDDD YYCCmmdd |
The following table contains all PL/I fields that are acceptable for a Date override. Only the following PL/I field types may be used for a Date override:
| Field type | Example declarations | Example Host Date patterns |
|---|---|---|
| FIXED DECIMAL(n,0) |
05 YYYYDDD FIXED DECIMAL(7) 05 YYYYMMDD FIXED DECIMAL(8) |
yyyyDDD yyyyMMdd |
| PICTURE '(n)9' |
05 YYYYDDD PIC [S]9(7) COMP-3 05 DDMMYYYY PIC [S]9(8) COMP-3 |
yyyyDDD ddMMyyyy |
| PIC [S]9(n) USAGE DISPLAY |
05 YYYYDDD PICTURE '(7)9' 05 DDMMYYYY PICTURE '(8)9' |
yyyyDDD ddMMyyyy |
| PICTURE 'S(n)9' or '(n)9S' |
05 YYCCDDD PICTURE 'S(7)9' 05 YYCCMMDD PICTURE '(8)9S' |
YYCCDDD YYCCMMdd |
| CHAR(n) NONVARYING |
05 MMDDYYYY CHAR(8) NONVARYING 05 MM_DD_YYYY CHAR(10) NONVARYING 05 YYYY_MM_DD CHAR(20) NONVARYING |
MMddyyyy MM/dd/yyyy yyyy年MM月dd日 |
| WCHAR(n) NONVARYING |
05 YYYYMMDD WCHAR(8) NONVARYING 05 YYYY_MM_DD WCHAR(11) NONVARYING |
MMddyyyy yyyy年MM月dd日 |
Numeric date override example
04 F-YYYYDDD-COMP PIC 9(07) COMP.The following override is applied to the service field:

"F_YYYYDDD_COMP" : {
"type" : "string",
"format" : "date"
}The following value is provided in the response JSON at
runtime:"F_YYYYDDD_COMP" : "2020-02-29"For the request, the service takes the JSON date value of "2020-02-29" and
converts it to a host date value of 2020060 using the pattern
yyyyDDD. For the response, the host date value of 2020060 is
converted to a JSON date value of "2020-02-29" using the same pattern,
yyyyDDD.
Character date override example
04 F-DD-MM-YYYY-SBCS PIC X(10) DISPLAY.The following override is applied to the service field:

"F_DD_MM_YYYY_SBCS" : {
"type" : "string",
"format" : "date"
} The following value is provided in the response JSON at
runtime:"F_DD_MM_YYYY_SBCS" : "2020-02-29"For the request, the service takes a JSON date value of "2020-02-29" and
converts it to a host date value of 29/02/2020 using the pattern
dd/MM/yyyy. For the response, the host date value of 29/02/2020 is
converted to a JSON date value of "2020-02-29" using the same pattern,
dd/MM/yyyy.
Group date override example
04 F-DD-MM-YYYY-DETAIL-SBCS.
04 F-MM PIC 9(02) DISPLAY.
04 FILLER PIC X(01) VALUE '/'.
04 F-DD PIC 9(02) DISPLAY.
04 FILLER PIC X(01) VALUE '/'.
04 F-YYYY PIC 0(04) DISPLAY.The STRUCT is overridden as a character field group in the service interface editor by right-clicking the STRUCT and selecting the Redefine as CHAR field function.

The following override is applied to the service field group:

"detailSBCS_MM/dd/yyyy" : {
"type" : "string",
"format" : "date"
} The following value is provided in the response JSON at
runtime:"detailSBCS_MM/dd/yyyy" : "2020-02-29"For the request, the service takes the JSON date value of "2020-02-29" and
converts it to a host date value of 02/29/2020 by using the pattern
MM/dd/yyyy. For the response, the host date value of 02/29/2020 is
converted to a JSON payload of "2020-02-29" by using the same pattern,
MM/dd/yyyy.