Considerations for how to handle the PECB-UEXIT-HOLD-FIELD in PKGXBLKS in COBOL, to pass and share storage between Endevor exit points.
Solution If PRE COBOL 6
The PECB-UEXIT-HOLD-FIELD in the Primary Information Block of the PACKAGE-EXIT-BLOCK for COBOL, is used to store address values, to be able to share storage with other Exits via the anchor ID, and is the same field as the ECB-UEXIT-HOLD-FIELD. If one shares the storage with other Exit points, the storage is for example acquired by an EXIT05, and released by an EXIT06.
It can also be used to only share storage with other EXIT7 Exit points, in that case the storage is typically acquired at the Package exit SETUP call. It is however not straightforward to do this in COBOL. When Endevor invokes a LE/COBOL program exit, an ENCLAVE is started. W hen the Cobol program ends the ENCLAVE is terminated and the storage released. This happens for each package exit call (setup, cast, execute, etc.), and therefore the HEAP and STACK storage, which is acquired new within each LE Enclave, is not usable to pass storage across these calls. This means that this storage will not be usable across the various package exit calls, since each call by Endevor will typically imply a new Enclave. Because the LE callable service CEEGTST uses HEAP storage, it is not usable to acquire storage to pass across package exit calls either.
A way to solve this dilemma would be to CALL an Assembler subroutine, and pass it the address of the PECB-UEXIT-HOLD-FIELD. The subroutine would then GETMAIN the storage, and store the address in the passed parameter, so that the PECB-UEXIT-HOLD-FIELD contains this address, after the CALL. The COBOL program could then use a POINTER technique to address and map the storage, or it could call another Assembler subroutine to handle the storage.
WORKING-STORAGE SECTION. 01 MY-POINTER. 03 WS-POINT USAGE IS POINTER. 03 RD-POINT REDEFINES WS-POINT PIC S9(8) COMP SYNC. 01 WS-PGM PIC X(8). LINKAGE SECTION. 01 HOLD-MEMORY. 03 COMM PIC X(40). 03 FILLER PIC X(4056). COPY PKGXBLKS. PROCEDURE DIVISION USING PACKAGE-EXIT-BLOCK PACKAGE-REQUEST-BLOCK PACKAGE-EXIT-HEADER-BLOCK PACKAGE-EXIT-FILE-BLOCK PACKAGE-EXIT-ACTION-BLOCK PACKAGE-EXIT-APPROVER-MAP PACKAGE-EXIT-BACKOUT-BLOCK PACKAGE-EXIT-SHIPMENT-BLOCK PACKAGE-EXIT-SCL-BLOCK. IF SETUP-EXIT-OPTIONS MOVE 'Y' TO PECB-MID-CAST MOVE 'Y' TO PECB-AFTER-CAST MOVE 'Y' TO PECB-BEFORE-CAST MOVE ZEROS TO RETURN-CODE MOVE 'SUBRGET ' TO WS-PGM CALL WS-PGM USING PECB-UEXIT-HOLD-FIELD MOVE PECB-UEXIT-HOLD-FIELD TO RD-POINT SET ADDRESS OF HOLD-MEMORY TO WS-POINT GO TO RETURN.
The subroutine 'SUBRGET' would in this example contain code like (R9 contains saved R1 at entry):
STORAGE OBTAIN,LENGTH=4096,LOC=BELOW L R2,0(,R9) R2 has address of PECB-UEXIT-HOLD-FIELD now LA R2,0(,R2) clear high bit ST R1,0(,R2) Store address of obtained storage
Solution If COBOL 6 Used
With COBOL 6 the allocate command was introduced. This allows Cobol to be used not requiring the Assembler program.
This is a sample code:
01 SIZE-NEEDED PIC 9(8) BINARY.
01 WS-POINTER USAGE IS POINTER.
01 RD-POINTER REDEFINES WS-POINTER
PIC S9(8) COMP SYNC.
05 WORKMEM PIC X(8).
05 CNT-ELM PIC S9(4) COMP.
05 METADATA OCCURS 2000 TIMES.
10 ENV PIC X(8).
10 SYSTEM PIC X(8).
10 SUBSYSTEM PIC X(8).
10 ELEMENT PIC X(8).
10 ELEMENT-TYPE PIC X(8).
10 STAGE-NAME PIC X(8).
COMPUTE SIZE-NEEDED = LENGTH OF WORK-DATA
ALLOCATE SIZE-NEEDED CHARACTERS INITIALIZED
SET ADDRESS OF WORK-DATA TO WS-POINTER
MOVE RD-POINTER TO PECB-UEXIT-HOLD-FIELD