Previous Topic: User StorageNext Topic: Shared Storage


User Kept Storage

User kept storage is available to all tasks running on a logical terminal until a task associated with that terminal releases the storage. User kept storage is ideal for passing small amounts of information between tasks. CA IDMS maintains TCE linkage for user kept storage across tasks by using the logical terminal element (LTE). When a new task is initiated from the same terminal, CA IDMS transfers this linkage from the LTE to the TCE of the new task.

Steps to Acquire User Kept Storage

To dynamically acquire and use variable storage from the storage pool and make the storage available to multiple tasks running on the same logical terminal:

  1. Acquire variable storage from the storage pool by issuing a GET STORAGE statement that specifies both the USER and the KEEP parameters.

    Note: You can indicate that storage is eligible for allocation above the 16Mb line by specifying LOCATION IS ANY on the GET STORAGE statement.

  2. Check for an ERROR-STATUS of 3210 (DC-NEW-STORAGE).
  3. Perform the IDMS-STATUS routine if 3210 is not returned.
  4. Perform processing, using the acquired storage as needed.
  5. Issue a DC RETURN statement, optionally specifying the next task to be invoked.

Accessing User Kept Storage

In subsequent tasks invoked on the same logical terminal:

  1. Establish addressability to the previously acquired storage by issuing a GET STORAGE request that names the storage ID specified for the storage area when it was first allocated.
  2. Perform processing, using the acquired data.

You should release the acquired storage as soon possible by issuing a FREE STORAGE statement that specifies the appropriate storage ID.

Example of Acquiring User Kept Storage

The program excerpt below shows the initial assignment of user kept storage.

The program performs preliminary error checking before transferring control to a database retrieval program.

 DATA DIVISION.
 01  TRANSPROG              PIC X(8)   VALUE 'DEPTGET'.
 01  SOLICIT-REC.
     05 SOLICIT-DEPT-ID     PIC X(4).
 LINKAGE SECTION.
 01  PASS-DEPT-INFO.
     05 PASS-DEPT-ID        PIC 9(4).
     05 PASS-DEPT-INFO-END  PIC X.

 PROCEDURE DIVISION.
     BIND MAP SOLICIT.
     BIND MAP SOLICIT RECORD SOLICIT-REC.
*
     MAP IN USING SOLICIT.
     INQUIRE MAP SOLICIT MOVE AID TO DC-AID-IND-V.
     IF CLEAR-HIT DC RETURN.
*
     IF SOLICIT-DEPT-ID NOT NUMERIC
        GO TO ERROR-DEPT-ID.
*** ACQUIRE USER KEPT STORAGE ***
     GET STORAGE FOR PASS-DEPT-INFO
                  TO PASS-DEPT-INFO-END
         NOWAIT KEEP LONG USER
         STGID 'DEPT' VALUE IS LOW-VALUE
     ON DC-NEW-STORAGE
         NEXT SENTENCE.
*** MOVE MAP DATA TO FIELDS IN ACQUIRED STORAGE ***
     MOVE SOLICIT-DEPT-ID TO PASS-DEPT-ID.
*** TRANSFER CONTROL TO DATABASE ACCESS PROGRAM ***
     TRANSFER CONTROL TO TRANSPROG
        NORETURN.

Reestablishing Addressability to User Kept Storage

The program excerpt below establishes addressability to the previously acquired storage and releases it. The program uses data from the previously acquired storage to perform database access.

 DATA DIVISION.
 01  NTCODES.
     05 NEXT-TASK              PIC X(8)   VALUE 'DEPTMOD'.
 01  MESSAGES.
     05 DEPT-DISPLAY-MESS      PIC X(20)
        VALUE 'DEPARTMENT DISPLAYED'
     05 DEPT-DISPLAY-MESS-END. PIC X.
 01  SOLICIT-REC.
     05 SOLICIT-DEPT-ID        PIC X(4).
 LINKAGE SECTION.
 01  PASS-DEPT-INFO.
     05 PASS-DEPT-ID        PIC 9(4).
     05 PASS-DEPT-INFO-END  PIC X.

 PROCEDURE DIVISION.
*** ESTABLISH ADDRESSABILITY TO PREVIOUSLY ACQUIRED STORAGE ***
     GET STORAGE FOR PASS-DEPT-INFO
                  TO PASS-DEPT-INFO-END
         NOWAIT KEEP LONG USER
         STGID 'DEPT'.
     BIND MAP SOLICIT.
     BIND MAP SOLICIT RECORD SOLICIT-REC.
*** MOVE DATA TO DATABASE CALC-KEY AND MAP DATA FIELD ***
     MOVE PASS-DEPT-ID TO DEPT-ID-0410.
     MOVE PASS-DEPT-ID TO SOLICIT-DEPT-ID.
*** RELEASE STORAGE ***
     FREE STORAGE STGID 'DEPT'.
             .
*** DATABASE ACCESS ***
             .
     MAP OUT USING SOLICIT
         MESSAGE IS DEPT-DISPLAY-MESS TO DEPT-DISPLAY-MESS-END.
     DC RETURN NEXT TASK CODE NEXT-TASK.