Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 10 Sample Application Using TIBCO Object Service Broker MAP Tables : MAIN Sample Rule

MAIN Sample Rule
MAIN Rule Illustrated

 
RULE EDITOR ===> SCROLL: P
MAIN;
_ LOCAL COMMAREA_PTR, COMMAREA_LEN, NEWCOMMAREA_PTR, EMPLOYEE_PTR;
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ GET @SESSION(0); | 1
_ COMMAREA_PTR = @SESSION.COMMHANDLE; | 2
_ COMMAREA_LEN = @SESSION.COMMLENGTH; | 3
_ @MAP.ADDRESS = 0; | 4
_ @MAP.SIZE = 32; | 5
_ INSERT @MAP(’ENVIRONMENT’); | 6
_ NEWCOMMAREA_PTR = @MAP.ADDRESS; | 7
_ @SESSION.COMMHANDLE = @MAP.ADDRESS; | 8
_ @SESSION.COMMLENGTH = @MAP.SIZE; | 9
_ REPLACE @SESSION(0); | A
_ GET COMM_HEADER(COMMAREA_PTR); | B
_ GET INPUT_HEADER(COMM_HEADER.POINTER); | C
_ EMPLOYEE_PTR = COMM_HEADER.POINTER + 40; | D
_ FORALL EMPLOYEE_RECORD(EMPLOYEE_PTR, | E
_ INPUT_HEADER.EMPLOYEE_COUNT) WHERE SALARY >= 1000 : |
_ EMPLOYEE_SUMMARY.* = EMPLOYEE_RECORD.*; |
_ EMPLOYEE_SUMMARY.KEY = 1; |
_ REPLACE EMPLOYEE_SUMMARY(NEWCOMMAREA_PTR); |
_ CALL CICS_ROUTINE; |
_ END; |
_ @SESSION.COMMHANDLE = COMMAREA_PTR; | F
_ @SESSION.COMMLENGTH = COMMAREA_LEN; | G
_ REPLACE @SESSION(0); | H
_ ---------------------------------------------------------------------------

 
MAIN Rule Explained
The following table contains line by line comments on the MAIN rule:
Line Number
Saves the address and length of the incoming COMMAREA in the local variables COMMAREA_PTR and COMMAREA_LEN.
Sets the address and length of the newly allocated space in the table @SESSION, thus making the new block of storage the active COMMAREA.
Uses the MAP table COMM_HEADER (shown in Sample MAP Tables) to map the area addressed by the original COMMAREA pointer.
Uses the MAP table INPUT_HEADER (shown in INPUT_HEADER Table) to map the area addressed by the field COMM_HEADER.POINTER.
The FORALL statement retrieves records starting at address EMPLOYEE_PTR whose SALARY value is greater than or equal to 1000. The record count in INPUT_HEADER.EMPLOYEE_COUNT is used to limit the number of occurrences in storage traversed by the FORALL. Fields in the summary table EMPLOYEE_SUMMARY (shown in EMPLOYEE_RECORD Table) are copied from the MAP table EMPLOYEE_RECORD (shown in EMPLOYEE_RECORD Table). The key field is set to 1 so that the first logical occurrence of the EMPLOYEE_SUMMARY table is the one written.
The REPLACE statement writes the EMPLOYEE_SUMMARY data to the storage area pointed to by NEWCOMMAREA_PTR. The external routine CICS_ROUTINE (which must be listed in the ROUTINES table) is called. Since the EMPLOYEE_SUMMARY record was written to the storage area pointed to by @SESSION.COMMAREA, the external CICS routine has access to it.
F, G, and H
Returns the COMMAREA pointer and length to their original values for the original caller to use (for example, for another call to this routine).
See Also
TIBCO Object Service Broker for z/OS External Environments for more information on the routines.

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved