Handling COBOL REDEFINES

If a COBOL field is redefined by one or more REDEFINES statements, by default, the original field name is selected. You can select a group of REDEFINES to be exposed in your service.

zosConnect-2.0 Applies to zosConnect-2.0.

If the service interface file is not already opened in the service interface editor, in Project Explorer, go to the service-interfaces/ folder for your project and double-click the service interface file (.si file).

If a field is redefined by the REDEFINES clause multiple times for different data description entries, expose only one group of the REDEFINES in your service. Because the last definition overrides previous definitions, exposing multiple definitions for a field could result in unexpected behaviors and errors. Use different services, one for each REDEFINES group, to ensure the correct values in correct data types are passed through.

In IBM® z/OS® Connect you may select multiple REDEFINEs in both request and response SIs but the behavior differs. For request SIs, sending JSON that causes more than one [re]definition of an item to be addressed causes a runtime error. For response SIs, JSON is generated for all the selected redefinitions of an item.

Using REDEFINES to change the size of a structure is not good practice. However, REDEFINES that are larger or smaller than the redefined item are supported. If redefining items are larger than the items they redefine, the compiler will make the redefined item as large as its largest redefining item. This capability is only available with recent versions of COBOL. If a redefining item is smaller than the redefined item, compiler warnings are issued.

In the following example, Field-1 is redefined by Group-1 and again by Group-2. The two groups contain different data description entries. For request messages, the last definition, Group-2, is used at run time. To ensure both types of input are preserved, expose Group-1 definition in one service and Group-2 in another. For output (response) messages, multiple views of the data would be returned. If the values are not valid, empty tags are returned.

05  Field-1 PICTURE X(100).
05  Group-1 REDEFINES Field-1.
    10 Field-2 PICTURE 9(4) comp-3.
    10 Field-3 PICTURE X(96).
05  Group-2 REDEFINES Field-1.
    10 Field-4 PICTURE 9(4) comp-5.
    10 Field-5 PICTURE X(50).
    10 Field-6 PICTURE X(46).