CICS with Channel Container Calling Convention

This document describes using the COBOL Mapping Editor to extract from a CICS channel container program.

graphics/map-diff-channel.png


Introduction

Modern CICS programs may use the CICS channels and containers model. During extraction, containers are mapped to IDL structures. See structure-parameter-definition (IDL).

If you have selected an IDL file and opened the COBOL Mapping Editor with an existing COBOL to IDL mapping, continue with Mapping Editor User Interface.

Extracting from a CICS Channel Container Program

If you are extracting IDL from a COBOL source or extending the IDL file by extracting an additional COBOL source with interface type CICS with channel container calling convention, the Extractor Settings dialog appears (see also Step 4: Define the Extraction Settings and Start Extraction).

Make sure the interface type is correct and, if required, that the channel name (max. 16 characters) is provided. If you do not provide a channel name, "EntireXChannel" is used as the default value.

graphics/map-diff-channel_extract.png

Press Next to open the COBOL Mapping Editor.

Start of instruction setTo select the COBOL interface data items of your COBOL server

  1. Define all the CICS input containers, one after another: in the Source View, use the toolbar icon Find text in Source graphics/icon_search.gif and enter "EXEC CICS" to find a GET call containing "EXEC CICS GET", function "CONTAINER" etc. Example:

    EXEC CICS GET
          CONTAINER(<container name constant>)
          CHANNEL  (<channel>)
          INTO     (<container>)
          NOHANDLE
    END-EXEC

    The COBOL data item <container> is the item you are looking for. Add the COBOL data item <container> to Input Message by using the context menu or toolbar available in the COBOL Source View and COBOL Interface. In the Input Message pane, select the corresponding COBOL data item <container>. Enter the container name, found in the value of <container name constant>. You can select multiple CICS input containers. See Notes.

  2. Define all the CICS output containers using the steps as above, but look for "EXEC CICS PUT". Example:

    EXEC CICS PUT
          CONTAINER(<container name constant>)
          CHANNEL  (<channel>)
          FROM     (<container>)
          FLENGTH  (LENGTH OF <container>)
          NOHANDLE
    END-EXEC

    Add the corresponding COBOL data item <container> to Output Message. In the Output Message pane, select the corresponding COBOL data item <container>. Enter the container name, found in the value of <container name constant>. The EXEC CICS PUT statement can be executed multiple times (for example in a loop) for the same container definition, creating an array of container. If this is true, set the column Array in the wizard to "Yes" and enter the maximum number of occurrences for the container in the Max column. You can select multiple CICS output containers. See Notes.

  3. Continue with COBOL to IDL Mapping.

Notes:

  1. It is very important to select the right COBOL data items describing the interface of the COBOL server correctly. This means the COBOL data items used as parameters must match in number and in sequence of formats (COBOL usage clause).
  2. If your COBOL server contain REDEFINEs, the first REDEFINE path is offered by default. Check manually whether this is the one you want. If not, correct it. You can select any other REDEFINE path.
  3. The container name length is restricted to 16 characters.
  4. Container arrays will enlarge the container name, because the number of occurrences (Max column) will be added to the name (max. 16 characters). Example:
    For MYCONTAINER as the container name and 99999 as the number of occurrences, the container names are MYCONTAINER00001 - MYCONTAINER99999.

The user interface of the COBOL Mapping Editor is described below.

Mapping Editor User Interface

This section assumes you have set the extraction settings as described above. The following areas of the COBOL Mapping Editor user interface are described here:

For COBOL server programs with CICS channel container interface, the user interface of the COBOL Mapping Editor looks like this:

graphics/map-diff-channel_interface-small-1.png COBOL Program Selection. Currently selected program with interface type graphics/toc_closed.png More info
graphics/map-diff-channel_interface-small-2.png COBOL Source View. Contains all related sources for the currently selected COBOL program graphics/toc_closed.png More info
graphics/map-diff-channel_interface-small-3.png COBOL to IDL Mapping. Tree view of your selected COBOL data items and mapping buttons with which you can map these items to your IDL interface graphics/toc_closed.png More info

COBOL Program Selection

graphics/map-diff-channel_interface_prog.png

The COBOL Program Selection displays the current selected COBOL program with its interface type. If you have extracted more than one COBOL program within the associated IDL file, you can switch to another COBOL program with its mapping by selecting the name in the combo box.

COBOL Source View

graphics/map-diff-channel_interface_source.png

All COBOL data items contained in the LINKAGE and WORKING-STORAGE SECTION are offered in a text view. The text view contains all related sources (including copybooks) for the currently selected COBOL program. It is used for selecting data items and retrieving information from the original COBOL sources. The light green bar indicates that the data item is already contained in the COBOL Interface; a dark green bar indicates the data item is selectable and can be added to the COBOL Interface. This section can be collapsed. If you open the Editor with Modify Interface it is collapsed by default. The toolbar provides the following actions:

graphics/icon_addToInterface-in.gif Add selected COBOL data item to COBOL Interface as Input Message.
graphics/icon_addToInterface-out.gif Add selected COBOL data item to COBOL Interface as Output Message.
graphics/icon_removeFromInterface.gif Remove selected COBOL data item from COBOL Interface.
graphics/icon_removeAllFromInterface.gif Remove all COBOL data items from COBOL Interface.
graphics/icon_restoreDefault.gif Reset COBOL Interface to initial state.
graphics/icon_search.gif Show dialog to find text in Source.

The same functionality is also available from the context menu.

COBOL to IDL Mapping

This section covers the following topics:

COBOL Interface

The COBOL Interface shows a tree view of your selected COBOL data items describing the interface of the COBOL server. A context menu is available for the COBOL data items, which provides mapping and other functions. On some COBOL data items, decision icons indicate where particular attention is needed, including mapping icons to visualize the COBOL data type and your current mapping.

The COBOL data item names are derived from the COBOL source from which they were extracted. If your COBOL interface contains parameters without a name, that is, the keyword FILLER is used, those COBOL data items are shown as [FILLER]. See FILLER Pseudo-Parameter.

graphics/map-diff-channel_interface_cob2idl_cob.png

You can modify the COBOL interface using context menu or toolbar; decision and mapping icons provide additional information.

Context Menu

The context menu on COBOL data items provides the following mapping and other functions, depending on the data item type, the COBOL level and the current mapping.

Map to A suppressed COBOL data item becomes visible in the IDL interface. Used also to select another REDEFINE path.
Suppress Suppress unneeded COBOL data items.
Set Constant Set COBOL data items to constant.
Set Array Mapping Map an array to a fixed sized or unbounded array.
Set Multiple Possible Output (MPO) Structures Set COBOL data items where the server program decides the output structure used on return. Specify the set of multiple possible output (MPO) structures and the criteria when a structure is used.
Remove from COBOL Interface Remove the data item from the COBOL interface. This also removes the mapped IDL parameter from all IDL interfaces for the current COBOL program. See COBOL Program Selection.

See also Mapping Editor IDL Interface Mapping Functions.

Toolbar

The toolbar offers the following actions:

graphics/icon_plus.gif Create IDL Interface. Creates a new IDL interface based on the current COBOL interface: all IDL parameters are of IDL direction InOut; no IDL parameters are set to constant; for COBOL REDEFINE, the first REDEFINE path is mapped to IDL; FILLERs are suppressed according to your selection, see Step 4: Define the Extraction Settings and Start Extraction.
graphics/icon_duplicate.gif Copy current IDL Interface. Creates a duplicate of the current IDL interface: all modifications such as IDL directions, suppress, selection of REDEFINE paths etc. are kept.
graphics/icon_remove.gif Remove current IDL Interface.
graphics/icon_rename.gif Rename current IDL Interface.
graphics/icon_expand.png Expand the full tree.
graphics/icon_collapse.png Collapse the full tree.

See also Map to Multiple IDL Interfaces.

Decision Icons

The decision icons in the first column are set on COBOL data items where particular attention is needed:

graphics/icon_decisionRedefine.png This icon visualizes a COBOL REDEFINE. It is essential that you map the correct redefine path for your mapping to In, Out or InOut using the context menu. If you map a REDEFINE path, all other sibling REDEFINE paths are automatically set to "Suppress".
Mapping Icons

The following mapping icons on the COBOL data items indicate your current IDL mapping:

graphics/icon_in.png Scalar parameter, mapped to In.
graphics/icon_out.png Scalar parameter, mapped to Out.
graphics/icon_group-in.png Group parameter, here mapped to In.
graphics/icon_redefine-out.png REDEFINE parameter, here mapped to Out.
graphics/icon_constant.png Parameter set to Constant.

Mapping Buttons

The following buttons are available:

graphics/map-diff-channel_interface_cob2idl_buttons.png

Map to  ->

A suppressed COBOL data item becomes visible in the IDL interface. Used also to select another REDEFINE path.

Suppress

See Suppress Unneeded COBOL Data Items.

Set Constant...

See Set COBOL Data Items to Constants.

IDL Interface

If you have mapped the COBOL interface to multiple IDL interfaces, select the IDL interface by choosing the tabs. In the IDL Interface tree view, a context menu is also available with the following possibilities:

  • Rename

  • Remove from COBOL Interface. This also removes the mapped IDL parameter from all IDL interfaces for the current COBOL program. See COBOL Program Selection above.

graphics/map-diff-channel_interface_cob2idl_idl.png

Mapping Editor IDL Interface Mapping Functions

This section covers the following topics:

Map to

With the Map to functions you make a COBOL data item visible as an IDL parameter in the IDL interface, that is, you design the IDL interface by defining input and output parameters.

Start of instruction setTo map COBOL data items to IDL interface

  1. Go step-by-step through all top-level COBOL data items in the COBOL interface and use the Map to function available in the context menu of the COBOL interface and as mapping button to make a COBOL data item visible as an IDL parameter in the IDL interface:

    graphics/idlFunctions_mapTo-channel.png

  2. Do the same for the output message of the COBOL interface.

Notes:

  1. If a COBOL group is mapped, all subordinate COBOL data items are also made visible in the IDL interface.
  2. With the inverse function Suppress Unneeded COBOL Data Items (see below) available in the context menu of the COBOL interface and as mapping button, a COBOL data item can be removed from the IDL interface.

Map OCCURS DEPENDING ON

You can make the COBOL ODO subject (here COBOL data item TABLE) of a variable-sized COBOL table (see COBOL Tables with Variable Size - DEPENDING ON Clause) visible as an IDL unbounded group (with maximum). The ODO object (here COBOL data item COUNTER-1) is suppressed and therefore not part of the IDL interface. This is because the number of elements of the IDL unbounded group is already implicitly available. See the following example:

01 COUNTER-1 PIC 99.
01 TABLE OCCURS 1 TO 10 DEPENDING ON COUNTER-1
 02 FIELD1 PIC XX.
 02 FIELD2 PIC 99.

Start of instruction setTo map OCCURS DEPENDING ON

  • Add the COBOL subject (here data item TABLE) and ODO object (here data item COUNTER-1) to the input message or to the output message, wherever they belong. It is important both data items are always together per message direction (input or output).

    graphics/idlFunctions_odo-channel.png

Notes:

  1. The ODO subject can be mapped to the IDL interface.
  2. The ODO object is always suppressed, but is required to be part of the same message direction (Input Message or Output Message) of the COBOL interface.
  3. IDL directions are described in the direction-attribute in attribute-list under Software AG IDL Grammar.

Map to Multiple IDL Interfaces

Assume the COBOL server program provides multiple functions or operations, in the following example ADD, SUBRACT, MULTIPLY. Some dispatcher front-end code executes the correct function, for example, depending on a function-code or operation-code parameter:

graphics/map-common_idlFunctions_multiple.png

This example is described in more detail under Example 1: COBOL Server with Multiple Functions.

If you have such a situation, a good approach is to expose each COBOL server program function separately as an IDL program. This gives advantages in further processing of the IDL and COBOL mapping files (SVM and CVM). For example:

  • If your target endpoint is a web service: instead having a Web service with a single operation, you get a web service with multiple operation, one operation for each COBOL function.

  • If your target endpoint is Java or .NET: instead having a class with a single method, you get a class with multiple methods, one method for each COBOL function.

Start of instruction setTo map a COBOL interface to multiple IDL interfaces

  1. Select the tab with COBOL to IDL Mapping. For each function, define a separate IDL interface with the toolbar functions graphics/icon_plus.gif or graphics/icon_duplicate.gif:

    graphics/idlFunctions_multiple-channel-1.png

  2. Give the IDL interfaces meaningful names with the toolbar function graphics/icon_rename.gif:

    graphics/idlFunctions_multiple-channel-2.png

  3. Define the required constant values to the function-code or operation-code parameter, see Set COBOL Data Items to Constants above:

    graphics/idlFunctions_multiple-channel-3.png

For the delivered Example 1: COBOL Server with Multiple Functions:

  • First, for step 1 above: Extract and define 3 separate IDL programs ADD, SUBTRACT, MULTIPLY.

  • Second, for step 2 above: Rename them to suitabable names, e.g. 'ADD', 'SUBTRACT', MULTIPLY'

  • Third, for step 3 above: Define the constants '+', '-' and '*' to the parameter OPERATION respectively.

  • After pressing Finish, the following IDL together with a server mapping file is created. See Server Mapping Files for COBOL.

    library 'EXAMPLE' is
    
     program 'ADD' is
      define data parameter
       1 INPUT ('REQUEST') In
       1 OUTPUT ('REPLY')  Out
      end-define
    
     struct 'REQUEST' is
      define data parameter
       1 OPERAND1 (I4)
       1 OPERAND2 (I4)
      end-define
    
     struct 'REPLY' is
      define data parameter
       1 FUNCTION-RESULT (I4)
      end-define
    
     program 'SUBTRACT' is
      define data parameter
       1 INPUT ('REQUEST') In
       1 OUTPUT ('REPLY')  Out
      end-define
    
     program 'MULTIPLY' is
      define data parameter
       1 INPUT ('REQUEST') In
       1 OUTPUT ('REPLY')  Out
      end-define
    

Notes:

  1. The following functions are offered to create further mappings from the COBOL interface, resulting in multiple IDL interfaces (IDL programs).
    Icon Function Description
    graphics/icon_plus.gif Create IDL Interface Creates a new IDL interface based on the current COBOL interface. All IDL parameters are of IDL direction InOut; no IDL parameters are set to constant; for COBOL REDEFINE, the first REDEFINE path is mapped to IDL; FILLERs are suppressed according to your selection, see Step 4: Define the Extraction Settings and Start Extraction.
    graphics/icon_duplicate.gif Copy current IDL Interface Creates a duplicate of current IDL interface. All modifications such as IDL directions, suppress, selection of REDEFINE paths etc. are kept.
    graphics/icon_rename.gif Rename current IDL Interface The default name for the IDL interface is based on the COBOL program name plus appended number. With this function you can give the IDL interface a suitable name.
    graphics/icon_remove.gif Remove current IDL Interface Deletes the current IDL interface.
  2. With the steps 1 thru 3 described here you can emulate the behavior of function Map to Operation of EntireX version 9.6 and earlier.

Select REDEFINE Paths

For COBOL server programs containing COBOL REDEFINEs, the correct REDEFINE path needs to be chosen for the IDL interface.

Start of instruction setTo select redefine paths

  • Use the Map to function available in the context menu of the COBOL interface and as mapping button to make the COBOL REDEFINE path available in the IDL interface.

    graphics/idlFunctions_redefine-channel.png

    Begin with the COBOL REDEFINE defined at the highest level first. Work through all inner COBOL REDEFINE data items, going from higher levels to lower levels.

Notes:

  1. Only one REDEFINE path of a COBOL REDEFINE can be mapped to the IDL interface. All COBOL REDEFINE siblings are suppressed.
  2. If a REDEFINE path is actively mapped to the IDL interface, all COBOL REDEFINE siblings are suppressed.
  3. You can suppress all REDEFINE paths of a COBOL REDEFINE. Simply suppress the active REDEFINE path, see Suppress Unneeded COBOL Data Items above.

Suppress Unneeded COBOL Data Items

COBOL data items without any relevant information can be made invisible in the IDL interface. The IDL interface is simplified - it becomes shorter and tidier. This is useful, for example

  • for FILLER data items

  • if the RPC client or Adapter Service does not need an Out parameter

  • if the RPC server or Adapter Service does not need an In parameter and a low value can be provided

If you are using an RPC server such as the z/OS (CICS | Batch), z/VSE (CICS | Batch), Micro Focus or BS2000/OSD RPC server, the amount of data to be transferred to/from the RPC client is also reduced.

Start of instruction setTo suppress unneeded COBOL data items

  • Use the Suppress function available in the context menu of the COBOL interface and as mapping button to make the COBOL data item invisible in the IDL interface:

    graphics/idlFunctions_suppress-channel.png

Notes:

  1. The COBOL data item is not part of the IDL interface. It is invisible for RPC clients or Adapter Service.
  2. The RPC server or Adapter Service provides the COBOL data item to your COBOL server with low value, managing the offset to the next COBOL data item.
  3. If a COBOL group is suppressed, all subordinate COBOL data items are suppressed as well.
  4. With the inverse function Map to (see above) available in the context menu of the COBOL interface and as a mapping button, a COBOL data item can be made visible in the IDL interface again.

Set COBOL Data Items to Constants

COBOL data items that always require fixed constant values on input to the COBOL server program can be made invisible in the IDL interface and initialized with the required constant values. This is useful for keeping the IDL interface short and tidy. RPC clients or Adapter Services are not bothered with IDL parameters that always contain constants, such as RECORD-TYPES. This function is often used in conjunction with Map to Multiple IDL Interfaces (see above).

Start of instruction setTo COBOL data items to constants

  1. Use the Set Constant function available in the context menu of the COBOL interface and as mapping button to define a constant value for a COBOL data item:

    graphics/idlFunctions_constant-1-channel.png

  2. You are prompted with a window to enter the constant value:

    graphics/idlFunctions_constant-2.png

Notes:

  1. The COBOL data item is not part of the IDL interface. It is invisible for RPC clients or Adapter Services.
  2. The RPC server or Adapter Service provides the defined constant in the COBOL data item to your COBOL server.
  3. With the function Map to (see above) available in the context menu of the COBOL interface and as a mapping button, a COBOL data item can be made visible in the IDL interface again.

Set Arrays (Fixed <-> Unbounded)

For COBOL server programs using the message length to transfer a variable number of elements in a COBOL table with a fixed size (see COBOL Tables with Fixed Size) in a variable manner (see COBOL Tables with Variable Size - DEPENDING ON Clause) you need to set the mapping to unbounded array.

For details of such a COBOL server program see Example 2: COBOL Server Using Fixed-length Tables in Variable Manner.

Start of instruction setTo set arrays from fixed to unbounded or vice versa

  • Select the COBOL table and use the function Set Arrays (Fixed<->Unbounded) available in the context menu. A modal window is displayed. Select Unbounded array. The IDL array parameter will be changed from fixed array /number to an unbounded array /Vnumber, see array-definition under Software AG IDL Grammar in the IDL Editor documentation.

Notes:

  1. This option should be used carefully and requires knowledge of the COBOL server program. Be aware that an incorrect mapping results in runtime errors.
  2. The COBOL Table with a fixed size (see COBOL Tables with Fixed Size) used in this manner must be the last parameter of the COBOL interface; it must not be a subparameter of any other COBOL table and must not contain any DEPENDING ON clause (see COBOL Tables with Variable Size - DEPENDING ON Clause).

Set Multiple Possible Output (MPO) Structures

A COBOL server program produces more than one type of output. The layout of the output can therefore take two or more dissimilar shapes. The COBOL server program decides at runtime the output structure returned, that is, the COBOL layout on output varies.

Multiple Possible Output with REDEFINES

As illustrated in Example 3: COBOL Server Using Multiple Possible Output (MPO), a COBOL REDEFINES Clause is often used to describe the possible output structures. In COBOL this is the standard way to describe multiple possible output.

In addition, the COBOL interface

  • limits the number of possible output structures returned

  • defines all possible output structures, that is, they are known during extraction. In the example these are the structures PAYMENT-DATA-VOUCHER, PAYMENT-DATA-CREDITCARD and PAYMENT-DATA-TRANSFER. These are the MPO structures.

  • contains an additional COBOL data item carrying a value related to the returned output structure. By inspecting this data item first, the appropriate output structure can be selected to address the data correctly. In the example it is PAYMENT-TYPE. This item is the MPO selector.

  • always occupies memory to be able to transfer the longest output structure. If the actual returned output structure is shorter than the longest possible output structure, there is a gap (space) between the multiple possible output and the subsequent data item.

graphics/idlFunctions_mpo.png

This abstract concept is known as multiple possible output (MPO) EntireX bundles all MPO structures into an MPO group. See MPO Terminology below.

Optional Output with Groups

As illustrated in Example 4: COBOL Server Using Optional Output, COBOL group data items can be used to describe optional output structures. See Optional COBOL Group Data Items. Optional output with group data items are a variant of multiple possible output (MPO).

In addition, the COBOL interface

  • limits the number of possible output structures returned

  • defines all optional output structures, that is, they are known during extraction. In the example these are the structures OPTIONAL-OUTPUT-STRUCTURE1 and OPTIONAL-OUTPUT-STRUCTURE2. These are the MPO structures.

  • contains an additional COBOL data item carrying an indication if the optional output is present. By inspecting this data item first, the appropriate optional output structure can be selected to address the data correctly. If its value does not match, the optional output is not present. In the example it is OPTIONAL-OUTPUT. This item is the MPO selector.

  • If the optional output is not present no memory is occupied. There is no gap between the optional output and the subsequent data item, as opposed to Multiple Possible Output with REDEFINES above.

In the example there are three different shapes of output:

graphics/idlFunctions_mpo_groups.png

MPO Terminology

The following terminology is used with MPOs:

MPO structure

A COBOL group describing the output layout used in an MPO case. All alternative layouts in an MPO group are often described with COBOL REDEFINEs. An MPO structure can also contain other MPO groups.

MPO group

Bundles together all MPO structures that can be used alternatively. A COBOL interface can contain more than one MPO group.

MPO case

An MPO structure together with its MPO selector values (one or more).

MPO selector

A COBOL data item containing a specific value (MPO selector value) where the actual MPO case can be determined. The MPO selector precedes the MPO group and is located outside the MPO group.

MPO selector value

Each value indicates exactly one output structure. An output structure can be indicated by further values.

Steps

Start of instruction setTo set multiple possible output (MPO) structures

Use the Set Multiple Possible Output (MPO) Structures function available in the context menu of the COBOL interface to create new or modify existing MPO groups.

  1. Set the top-level COBOL data item where the MPO structures are contained to IDL direction Out. Use the Map to Out function for this purpose:

    graphics/idlFunctions_mpo-set-topLevel.png

  2. From the context menu of the COBOL interface of the COBOL REDEFINE, choose Set Multiple Possible Output (MPO) Structures.

    graphics/idlFunctions_mpo-set-structs-same.png

  3. Set Multiple Possible Output (MPO) Structures into MPO Group.

    graphics/idlFunctions_mpo-set-group.png

  4. Create a new MPO group.

    graphics/idlFunctions_mpo-new-group.png

  5. Set MPO selector values for MPO Structures.

    graphics/idlFunctions_mpo-set-selectorValues-1.png

    Use the functions graphics/icon_mpo-delete.gif to delete and graphics/icon_plus.gif to add MPO selector values:

    graphics/idlFunctions_mpo-set-selectorValues-2.png

    Notes:

    1. To add multiple MPO selector values per MPO structure, use the function graphics/icon_plus.gif multiple times for the same MPO structure (see value 10 and 20 for structure PAYMENT-DATA).
    2. MPO structures without any MPO selector are unused and suppressed in the IDL interface value (e.g. see structure PAYMENT-DATA-TRANSFER).
    3. Each MPO selector value must uniquely identify an MPO structure. The same value cannot be used more than once for different MPO structures.
    4. If no defined MPO selector value matches during runtime, an empty MPO group is delivered to the RPC client, that is, none of the MPO cases contain any data. No runtime error is produced.
  6. For the delivered example COBOL Server Using Multiple Possible Output (MPO) (see below): After pressing Finish, the following IDL together with a server mapping file is created. See Server Mapping Files for COBOL.

    library 'PAYMENT' is
    
     program 'PAYMENT' is
      define data parameter
       1 INPUT ('REQUEST') In
       1 OUTPUT ('REPLY')  Out
      end-define
    
     struct 'REQUEST' is
      define data parameter
       1 ORDER-NUMBER (NU10)
      end-define
    
     struct 'REPLY' is
      define data parameter
       1 PAYMENT-TYPE              (AV2)
        2 PAYMENT-DATA-MPO  Choice
         3 PAYMENT-DATA            (/V1)
          4 PAYMENT-DATA           (AV256)
         3 PAYMENT-DATA-VOUCHER    (/V1)
          4 VOUCHER-ORIGIN         (AV128)
          4 VOUCHER-SERIES         (AV128)
         3 PAYMENT-DATA-CREDITCARD (/V1)
          4 CREDITCARD-NUMBER      (NU18)
          4 CREDITCARD-CODE        (NU12)
          4 CREDITCARD-VALIDITY    (AV8)
         end-define
    

Programming Techniques

Example 1: COBOL Server with Multiple Functions

Assume a COBOL server program has a FUNCTION or OPERATION code COBOL data item in its COBOL interface. The COBOL server program behaves differently depending on field values of this data item. See the following example where a COBOL programs implements a calculator with the functions ADD, SUBTRACT, MULTIPLY, etc. The execution of the different functions is controlled by the COBOL data item OPERATION:

. . .

     01 OPERATION                      PIC X(1).
     01 OPERAND1                       PIC S9(9) BINARY.
     01 OPERAND2                       PIC S9(9) BINARY.
     01 FUNCTION-RESULT                PIC S9(9) BINARY.
     . . .
     MOVE 0 TO FUNCTION-RESULT.
     EVALUATE OPERATION
         WHEN "+"
            ADD OPERAND1 OPERAND2
            GIVING FUNCTION-RESULT
         WHEN "-"
            SUBTRACT OPERAND2 FROM OPERAND1
            GIVING FUNCTION-RESULT
         WHEN "*"
            MULTIPLY OPERAND1 BY OPERAND2
            GIVING FUNCTION-RESULT
         WHEN . . .

     END-EVALUATE.
. . .

You can expose each COBOL server program function separately. The advantages or reasons for wanting this depend on the target endpoint. For example:

  • Web Service
    Instead having a Web service with a single operation, you want a web service with multiple operations, one operation for each COBOL function.

  • Java or .NET
    Instead having a class with a single method, you want a class with multiple methods, one method for each COBOL function.

  • etc.

To do this you need to extract the COBOL server program as described under Map to Multiple IDL Interfaces.

Example 2: COBOL Server Using Fixed-length Tables in Variable Manner

Assume a COBOL CICS channel container server program has a fixed-length COBOL table as its last parameter, similar to COBOL data item COBOL-TABLE-FIX in the example below; each table element is 100 bytes; the length of COBOL-FIELD1 + COBOL-FIELD2 + COBOL-FIELD3; the length of the data preceding the COBOL table is described by COBOL-GROUP1; its length is 1000 bytes.

         WORKING-STORAGE SECTION.         
         01 LS-CONTAINER-NAME                 PIC X(16) VALUE "VAR-INPUT".
         01 WS-CONTAINER-NAME                 PIC X(16) VALUE "VAR-OUTPUT".
         01 NUMBER-OF-INCOMING-ELEMENTS       PIC S9(8) BINARY.
         01 NUMBER-OF-OUTGOMING-ELEMENTS      PIC S9(8) BINARY.

          . . .

         01 WS-CONTAINER-LAYOUT.          
           10 COBOL-GROUP1.
             20 COBOL-TABLE-PREFIX            PIC X(1000).
           10 COBOL-TABLE-FIX                 OCCURS 20.
             20 COBOL-GROUP2.
               25 COBOL-FIELD1                PIC X(4).
               25 COBOL-FIELD2                PIC X(3).
               25 COBOL-FIELD3                PIC X(50).
         LINKAGE SECTION.         
         01 LS-CONTAINER-LAYOUT.          
           10 COBOL-GROUP1.
             20 COBOL-TABLE-PREFIX            PIC X(1000).
           10 COBOL-TABLE-FIX                 OCCURS 20.
             20 COBOL-GROUP2.
               25 COBOL-FIELD1                PIC X(30).
               25 COBOL-FIELD2                PIC X(20).
               25 COBOL-FIELD3                PIC X(50).
              . . .
         PROCEDURE DIVISION.
            EXEC CICS GET
                CONTAINER (LS-CONTAINER-NAME
                SET       (ADDRESS OF LS-CONTAINER-LAYOUT)
                FLENGTH   (WS-CONTAINER-LENGTH)
                RESP      (WS-RESP)
                RESP2     (WS-RESP2)
            END-EXEC.  
            COMPUTE NUMBER-OF-INCOMING-ELEMENTS = (WS-CONTAINER-LENGTH  
                  - LENGTH OF COBOL-GROUP1 IN AREA LS-CONTAINER-LAYOUT)
                  / LENGTH OF COBOL-GROUP2 IN AREA LS-CONTAINER-LAYOUT.           
              . . .
            COMPUTE WS-CONTAINER-LENGTH = LENGTH OF COBOL-GROUP1 IN AREA WS-CONTAINER-LAYOUT 
                  + (NUMBER-OF-OUTGOING-ELEMENTS 
                  * LENGTH OF COBOL-GROUP2 IN AREA WS-CONTAINER-LAYOUT).           
            
            EXEC CICS PUT
                 CONTAINER (WS-CONTAINER-NAME)
                 FROM      (WS-CONTAINER-LAYOUT)
                 FLENGTH   (WS-CONTAINER-LENGTH)
                 RESP      (WS-RESP)
                 RESP2     (WS-RESP2)
            END-EXEC.
     EXEC CICS RETURN END-EXEC.

During input the COBOL channel container server program uses the container length WS-CONTAINER-LENGTH to evaluate the NUMBER-OF-INCOMING-ELEMENTS. During output the WS-CONTAINER-LENGTH is determined according to the NUMBER-OF-OUTGOING-ELEMENTS and set in the EXEC CICS PUT CONTAINER statement.

Although the COBOL table is defined as a table with a fixed size (see COBOL Tables with Fixed Size) it is used in a variable manner, similar to tables with variable size (see COBOL Tables with Variable Size - DEPENDING ON Clause). In this case you need to map the COBOL table to an IDL unbounded array. See Set Arrays (Fixed <-> Unbounded).

Example 3: COBOL Server Using Multiple Possible Output (MPO)

A COBOL REDEFINE can be used in a COBOL server program to return multiple possible output (MPO) structures, similar to COBOL data item PAYMENT-DATA in the example below; for this purpose, PAYMENT-DATA is redefined; each redefinition represents an output structure (MPO case); on return exactly one output structure is used; by inspecting COBOL data item PAYMENT-TYPE (MPO selector) first, a caller can determine the returned output structure; the caller then uses the correct redefinition to access the data.

    . . .
    01 INPUT-DATA.
       02 ORDER-NUMBER                       PIC 9(10).

    . . .
    01 OUTPUT-DATA.
        02 <some fields>                          PIC <clause>.
       . . .

        02 PAYMENT-TYPE                           PIC X(2).
           88 PAYMENT-TYPE-VOUCHER                VALUE "VO".
           88 PAYMENT-TYPE-CREDITCARD             VALUE "CC".
           88 PAYMENT-TYPE-TRANSFER               VALUE "TR".
           88 PAYMENT-TYPE-DIRECTDEBIT            VALUE "DB".
          . . .
        02 <preceding data items>                 PIC <clause>.
       . . .
        02 PAYMENT-DATA                           PIC X(256).
        02 PAYMENT-DATA-VOUCHER     REDEFINES PAYMENT-DATA.
           04 VOUCHER-ORIGIN                      PIC X(128).
           04 VOUCHER-SERIES                      PIC X(128).
        02 PAYMENT-DATA-CREDITCARD  REDEFINES PAYMENT-DATA.
           04 CREDITCARD-NUMBER                   PIC 9(18).
           04 CREDITCARD-COMPANY                  PIC X(128).
           04 CREDITCARD-CODE                     PIC 9(12).
           04 CREDITCARD-VALIDITY                 PIC X(8).
        02 PAYMENT-DATA-TRANSFER    REDEFINES PAYMENT-DATA.
           04 TRANSFER-NAME                       PIC X(128).
           04 TRANSFER-IBAN                       PIC X(34).
           04 TRANSFER-BIC                        PIC X(11).
        02 PAYMENT-DATA-DIRECTDEBIT REDEFINES PAYMENT-DATA.
           04 DIRECTDEBIT-IBAN                    PIC X(34).
           04 DIRECTDEBIT-NAME                    PIC X(128).
           04 DIRECTDEBIT-EXPIRES                 PIC 9(8).
          . . .
        02 <subsequent data items>                PIC <clause>.
       . . .

    . . .

*   read order record using ORDER-NUMBER
    . . .

*  set value indicating type of reply (MPO selector)
    IF <some-condition> THEN
      SET PAYMENT-TYPE-VOUCHER TO TRUE
    ELSE IF <some-other-condition> THEN
      SET PAYMENT-TYPE-CREDITCARD TO TRUE
    ELSE IF <some-further-condition> THEN
      SET PAYMENT-TYPE-TRANSFER TO TRUE
    ELSE
      SET PAYMENT-TYPE-DIRECTDEBIT TO TRUE
    END-IF.
   . . .

*   set fields (MPO case) depending on type of reply
    INITIALIZE PAYMENT-DATA.
    EVALUATE TRUE
         WHEN PAYMENT-TYPE-VOUCHER
            MOVE . . . TO VOUCHER-ORIGIN
            MOVE . . . TO VOUCHER-SERIES
         WHEN PAYMENT-TYPE-CREDITCARD
            MOVE . . . TO CREDITCARD-NUMBER
            MOVE . . . TO CREDITCARD-CODE
            MOVE . . . TO CREDITCARD-VALIDITY
         WHEN PAYMENT-TYPE-TRANSFER
            MOVE . . . TO TRANSFER-NAME
            MOVE . . . TO TRANSFER-IBAN
            MOVE . . . TO TRANSFER-BIC
         WHEN PAYMENT-TYPE-DIRECTDEBIT
            MOVE . . . TO DIRECTDEBIT-IBAN
            MOVE . . . TO DIRECTDEBIT-NAME
            MOVE . . . TO DIRECTDEBIT-EXPIRES
         WHEN
            . . .
    END-EVALUATE.
    . . .

COBOL server programs using alternative and dissimilar shapes for the output layout are extracted as described under Set Multiple Possible Output (MPO) Structures.

Example 4: COBOL Server Using Optional Output

COBOL group data items can be used in a COBOL server program to return optional output similar to the example below; the returned data is built by copying the necessary COBOL structures into an output area. The optional output is one of OPTIONAL-OUTPUT-STRUCTURE1, OPTIONAL-OUTPUT-STRUCTURE2 or nothing. The presence of the optional output is controlled by a structure named CONTROL-AREA. Optional output with group data items are a variant of MPO, see Example 3: COBOL Server Using Multiple Possible Output (MPO).

   WORKING-STORAGE SECTION.

   01 INPUT-AREA.
      02 FIX-INPUT-ITEM1                      PIC X(4).
      02 <some fields>                        PIC <clause>.
      . . .

   01 OUTPUT-OFFSET                           PIC  S9(9) BINARY.
   01 OUTPUT-AREA                             PIC X(32000).
      . . .

   01 CONTROL-AREA.
      02 OPTIONAL-OUTPUT                      PIC X(1).
         88 OPTIONAL-OUTPUT-1                 VALUE "1".
         88 OPTIONAL-OUTPUT-2                 VALUE "2".
         88 OPTIONAL-OUTPUT-NONE              VALUE "N".
      . . .

   01 OPTIONAL-OUTPUT-STRUCTURE1.
      02 OPTIONAL-OUTPUT-ITEM11               PIC X(10).
      02 OPTIONAL-OUTPUT-ITEM12               PIC X(100).
      02 OPTIONAL-OUTPUT-ITEM13               PIC X(20).
      . . .

   01 OPTIONAL-OUTPUT-STRUCTURE2.
      02 OPTIONAL-OUTPUT-ITEM21               PIC X(4).
      02 OPTIONAL-OUTPUT-ITEM22               PIC X(50).
      02 OPTIONAL-OUTPUT-ITEM23               PIC X(50).
      . . .

   01 FIX-OUTPUT-STRUCTURE1.
      02 FIX-OUTPUT-ITEM11                    PIC X(4).
      02 FIX-OUTPUT-ITEM12                    PIC X(20).
      02 FIX-OUTPUT-ITEM13                    PIC X(8).
      . . .

   01 FIX-OUTPUT-STRUCTURE2.
      02 FIX-OUTPUT-ITEM21                    PIC X(2).
      02 FIX-OUTPUT-ITEM22                    PIC X(10).
      02 FIX-OUTPUT-ITEM23                    PIC X(10).
      . . .


      IF <some-condition> THEN
         SET OPTIONAL-OUTPUT-1 TO TRUE
      ELSE IF <some-other-condition> THEN
         SET OPTIONAL-OUTPUT-2 TO TRUE
      ELSE
         SET OPTIONAL-OUTPUT-NONE TO TRUE
      END-IF.

      . . .

*     provide control area for optional output
      MOVE 1 TO OUTPUT-OFFSET.
      STRING CONTROL-AREA DELIMITED BY SIZE
      INTO OUTPUT-AREA WITH POINTER OUTPUT-OFFSET.

*     provide data items before optional output
      STRING FIX CONTROL-AREA DELIMITED BY SIZE
      INTO OUTPUT-AREA WITH POINTER OUTPUT-OFFSET.

*     provide optional output
      EVALUATE TRUE
          WHEN OPTIONAL-OUTPUT-1
             STRING OPTIONAL-OUTPUT-STRUCTURE1 DELIMITED BY SIZE
             INTO OUTPUT-AREA WITH POINTER OUTPUT-OFFSET
          WHEN OPTIONAL-OUTPUT-2
             STRING OPTIONAL-OUTPUT-STRUCTURE2 DELIMITED BY SIZE
             INTO OUTPUT-AREA WITH POINTER OUTPUT-OFFSET
      END-EVALUATE.

*     provide data items after optional output
      STRING FIX-OUTPUT-STRUCTURE2 DELIMITED BY SIZE
      INTO OUTPUT-AREA WITH POINTER OUTPUT-OFFSET.
      . . .

COBOL server programs using optional shapes for the output layour are extracted as described under Set Multiple Possible Output (MPO) Structures.