Transferring input and output data

This section illustrates how to transfer data between a parent and a child activity. It uses the Sale application’s Delivery activity as an example.

The SAL002 root activity creates the Delivery child activity by issuing a DEFINE ACTIVITY command.

Figure 14. Creating the Delivery activity
Delivery-Activity.
    .
    EXEC CICS DEFINE ACTIVITY('Delivery')
                 TRANSID('SDEL')
                 EVENT('Delivry-Complete')
             RESP(data-area) RESP2(data-area) END-EXEC
    .
    EXEC CICS GET CONTAINER(Order-Container)
                  ACTIVITY('Order') INTO(Order-Buffer)
             RESP(data-area) RESP2(data-area) END-EXEC
 
    EXEC CICS PUT CONTAINER(Order-Container)
                  ACTIVITY('Delivery') FROM(Order-Buffer)
             RESP(data-area) RESP2(data-area) END-EXEC

The GET CONTAINER command retrieves the data returned by the Order activity, and places it in a storage buffer. The data is retrieved from the Order activity’s output data-container, which is named Order.

Note:
A child activity’s data-containers are accessible to its parent even after the child has completed. An activity’s containers are only destroyed when the activity itself is destroyed. An activity is destroyed:

The PUT CONTAINER command associates a data-container (also named Order) with the Delivery activity, and places the retrieved data in it.

The implementation of the Delivery activity is shown in Figure 15.

Figure 15. Pseudocode for the Delivery activity
Identification Division.
Program-id. DEL001.
Environment Division.
Data Division.
Working-Storage Section.
01  Event-Name              pic x(16).
    88  DFH-Initial         value 'DFHINITIAL'.
01  Order-Ptr               usage is pointer.
01  Order-Container         pic x(16) value 'Order'.
01  Delivery-Container      pic x(16) value 'Delivery'.
01  Deliver-Data.
    .
Linkage Section.
01  DFHEIBLK.
    .
01  Order-Details.
    05  Order-Number        pic 9(8).
    .
 
Procedure Division..
Begin-Process.
    .
    EXEC CICS RETRIEVE REATTACH EVENT(Event-Name)
             RESP(RC) END-EXEC
    .
    If RC NOT = DFHRESP(NORMAL)
      .
    End-If.
    .
    Evaluate True
      When DFH-Initial
        Perform Delivery-Work
        Perform End-Activity
      When Other
        .
    End Evaluate.
    .
    EXEC CICS RETURN END-EXEC
    .
Delivery-Work.
    .
    EXEC CICS GET CONTAINER(Order-Container) SET(Order-Ptr)
             RESP(data-area) RESP2(data-area) END-EXEC
    .
    set address of Order-Details to Order-Ptr.
    .
    EXEC CICS READ FILE .....
              RESP(data-area) RESP2(data-area) END-EXEC
    .
    .  logic to print delivery details
    .
    .
    EXEC CICS PUT CONTAINER(Delivery-Container) FROM(Delivery-Data)
             RESP(data-area) RESP2(data-area) END-EXEC
    .
End-Activity.
    .
    EXEC CICS RETURN ENDACTIVITY
             RESP(data-area) RESP2(data-area) END-EXEC

The Delivery activity issues a GET CONTAINER command to retrieve data from a data-container named Order. Because the command does not specify the ACTIVITY option, it references a data-container associated with the current activity; in other words, it references the same Order data-container as that referenced by the PUT CONTAINER command in Figure 14.

The Delivery activity uses the input data to execute its logic. Then it issues a PUT CONTAINER command to store its output in a data-container named Delivery. Again, the ACTIVITY option is not specified, so the data-container is associated with the current (Delivery) activity.

See also Transferring data to asynchronous activations.

Related concepts
Overview of the Sale application
The initial request
The root activity
Using the BTS API to write business applications
Related reference
Overview of BTS API commands
BTS application programming commands
[[ Contents Previous Page | Next Page Index ]]