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.
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.
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.
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.