CICS - Pseudo Programming



As of now, we have covered non-conversion and conversion programs. Conversion programs have a major drawback as their think time is considerably high. To overcome this problem, pseudo-conversion programming came into the picture. We will now discuss more about pseudo-conversion programs.

Pseudo-Conversion Program

Following is the sequence of events which take place in a pseudo-conversion program −

  • Step 1 − The system sends a message to the screen and terminates the transaction, specifying the transaction to be started when the user input is received.

  • Step 2 − The system allocates the resources used by this transaction to other transactions running in the system. So we can utilize the resources in a pseudo-conversion program till the user gives the input.

  • Step 3 − The system polls the terminal input at regular intervals of time. When the input is received, it is processed and the output is displayed.

  • Step 4 − The application program is loaded into the main storage when needed and released when not in use.

CICS Pseudo Conversion Program

Pseudo Conversion Techniques

The important point to note in pseudo-conversation is passing of data between every task. We will discuss about the techniques for passing data.

COMMAREA

COMMAREA is known as communication area. COMMAREA is used to pass data between tasks. The following example shows how to pass COMMAREA where WSCOMMAREA and WS-COMMAREA-LENGTH are declared in Working Storage Section −

EXEC CICS RETURN
   TRANSID ('transaction-id')
   COMMAREA (WS-COMMAREA)
   LENGTH  (WS-COMMAREA-LENGTH)
END-EXEC.

DFHCOMMAREA

DFHCOMMAREA is a special memory area which is provided by CICS to every task.

  • It is used to pass data from one program to another program. The programs can exist in the same transaction or in different transaction also.

  • It is declared in the Linkage Section of the program at 01 level.

  • It should have the same picture clause as WS-COMMAREA.

  • Data can be moved back from DFHCOMMAREA to WS-COMMAREA using a MOVE statement.

MOVE DFHCOMMAREA TO WS-COMMAREA.

Example

After sending the map, the task ends and waits for the user response. At this stage, the data needs to be saved, because though the task has ended, the transaction has not. When this transaction is to be resumed, it would require the prior status of the task. User enters the input. This now has to be received by the RECEIVE MAP command and then validated. The following example shows how to declare COMMAREA and DFHCOMMAREA −

WORKING-STORAGE SECTION.
01 WS-COMMAREA.
   05 WS-DATA PIC X(10).
   
LINKAGE SECTION.
01 DFHCOMMAREA.
   05 LK-DATA PIC X(10).

Pseudo Code

Given below is the logic of pseudo code which we use in pseudo programming −

MOVE DFHCOMMAREA TO WS-COMMAREA
IF EIBCALEN = 0
   STEP1: SEND MAP
   STEP2: MOVE <internal-transaction-id1> to WS-COMMAREA
   STEP3: ISSUE CONDITIONAL RETURN
ELSE
   IF WS-COMMAREA = <internal-transaction-id1> 
      STEP4: RECEIVE MAP
      STEP5: PROCESS DATA
      STEP6: SEND OUTPUT MAP
      STEP7: MOVE <internal-transaction-ID2> to WS-COMMAREA
      STEP8: ISSUE CONDITIONAL RETURN 
   END-IF
END-IF      
STEP9: REPEAT STEP3 TO STEP7 UNTIL EXIT

Example

The following example shows a pseudo-conversion program −

******************************************************************
* PROGRAM TO DEMONSTRATE PSEUDO-CONVERSATION                     *
******************************************************************
IDENTIFICATION DIVISION.                                         
PROGRAM-ID. HELLO.                                               
DATA DIVISION.                                                   
WORKING-STORAGE SECTION.                                         
01 WS-MESSAGE          PIC X(30).                                
01 WS-COMMAREA         PIC X(10) VALUE SPACES.                    
LINKAGE SECTION.                                                 
01 DFHCOMMAREA         PIC X(10).                                 
PROCEDURE DIVISION.
   MOVE DFHCOMMAREA TO WS-COMMAREA
   IF  WS-COMMAREA  =  SPACES                                   
******************************************************************
* TRANSACTION GETTING EXECUTED FOR THE FIRST TIME                *
******************************************************************
   MOVE 'HELLO' TO WS-MESSAGE                               
   EXEC CICS SEND TEXT                                      
      FROM (WS-MESSAGE)                                   
   END-EXEC                                                 
   MOVE 'FIRST' TO WS-COMMAREA                              
******************************************************************
* TASK ENDS AS A RESULT OF RETURN. IF AID KEY PRESSED, NEXT      *
* TRANSACTION SHOULD BE TP002. DATA PASSED FROM WS-COMMAREA TO   *
* DFHCOMMAREA                                                    *
******************************************************************
   EXEC CICS RETURN                                         
      TRANSID('TP002')                                      
      COMMAREA(WS-COMMAREA)                                
   END-EXEC                                                 
******************************************************************
* IF  COMMAREA IS NOT EMPTY , THEN TP002 HAS BEEN EXECUTED ONCE  *
* ALREADY, USER INTERACTION IS FACILITATED BY RECEIVE            *
******************************************************************
   ELSE                                                         
      EXEC CICS RECEIVE                                        
         INTO(WS-MESSAGE)                                    
   END-EXEC
      EXEC CICS SEND TEXT                                      
      FROM (WS-MESSAGE)                                   
   END-EXEC                                                 
******************************************************************
* TASK ENDS AS A RESULT OF RETURN, NO NEXT TRANSACTION SPECIFIED *
* TO BE EXECUTED                                                 *
******************************************************************
   EXEC CICS RETURN                                         
   END-EXEC                                                 
END-IF.       

Advantages of Pseudo Conversion

Following are the advantages of pseudo conversion −

  • The resources are best utilized. Resources are released as soon as the program is suspended temporarily.

  • It looks as if it is in conversational mode.

  • It has better response time.

Return Statements

Following are the two types of return statements which are used in CICS −

Return-1

When the following unconditional return statement is issued, the task and the transaction (program) is terminated.

EXEC CICS RETURN 
END-EXEC.

Return-2

When the following conditional return, i.e., return with TRANSID statement is issued, the control returns to the CICS with the next transid to be executed. The next transaction starts when the user presses an AID key.

EXEC CICS RETURN
   TRANSID ('trans-id')
   [COMMAREA(WS-COMMAREA)]
END-EXEC.
Advertisements