CICS – PROGRAM, INTERVAL AND TASK CONTROL COMMANDS Day2- Session5 Updated in Nov 2004
SESSION 5 : OBJECTIVESTo Understand the Logical levels in CICS operation LINK command XCTL command RETURN command Static and Dynamic calls Conversational modes Errors in program control Interval Control Commands Task Control Commands
PROGRAM TO PROGRAM TRANSITION The programs within a task can execute at different logical levels using the following commands CICS LINK CICS XCTL CICS RETURN CICS CALL
LOGICAL LEVELS CICS Sub SystemLEVEL 0 LEVEL 1 LEVEL 2 Program A XCTL ‘Pgm B’ LINK C RETURN Program C RETURN Program B RETURN
LINK’ING TO ANOTHER PROGRAM PROGRAM A PROGRAM C PROCEDURE DIV. LINK ... PGM C PROCEDURE DIV. . . . . . . RETURN
PASSING DATA USING LINK PROG000A PROG000C WORKING STORAGE WS-DATA . PROCEDURE ... LINK PROG000C COMMAREA(WS-DATA) LINKAGE SECTION DFHCOMMAREA . PROCEDURE ... RETURN
LINK COMMAND EXEC CICS LINK PROGRAM(pgm-name) COMMAREA(comm-area) LENGTH(length) END-EXEC. Example : EXEC CICS LINK PROGRAM(‘PROG000C’) COMMAREA(WS-DATA) LENGTH(WS-DATA-LENGTH) END-EXEC.
XCTL’ING TO ANOTHER PROGRAM PROGRAM A PROGRAM B PROCEDURE DIV. XCTL ... PGM B . . . PROCEDURE DIV... . . . . . . RETURN CICS SYSTEM
PASSING DATA USING XCTL PROG000A PROG000B WORKING STORAGE WS-DATA . PROCEDURE ... XCTL PROG000B COMMAREA(WS-DATA) LINKAGE SECTION DFHCOMMAREA . PROCEDURE ... RETURN CICS SYSTEM
XCTL COMMAND EXEC CICS XCTL PROGRAM(pgmname) COMMAREA(comm-area) LENGTH(length) END-EXEC. Example: EXEC CICS XCTL PROGRAM(‘PGMSAMP’) COMMAREA(WS-COMMAREA) LENGTH(WS-COMM-LENGTH) END-EXEC.
RETURN COMMAND EXEC CICS RETURN [TRANSID(next-id)] [COMMAREA(comm-area)] [LENGTH(length)] END-EXEC. EXEC CICS RETURN END-EXEC.
STATIC CALL PROCEDURE DIVISION . . . CALL ‘PGM0002’ . . . THE CALLER AND THE CALLED PROGRAM MUST BE LINK-EDITED TOGETHER INTO A SINGLE LOAD MODULE PGM00001
DYNAMIC CALL PROCEDURE DIVISION . MOVE ‘PGM0001’ TO WS-PGM. . CALL WS-PGM . . . THE CALLER AND THE CALLED PROGRAM ARE LINK EDITED AS SEPARATE LOAD MODULES PGM00001
PASSING DATA IN CALL PROG000A PROG000C LINKAGE SECTION 01 DFHEIBLK .... 01 DFHCOMMAREA 01 WS-DATA . PROCEDURE DIVISION USING DFHEIBLK DFHCOMMAREA WS-DATA . .. GOBACK PROCEDURE DIV ... CALL ‘ PROG000C’ USING DFHEIBLK DFHCOMMAREA WS-DATA
CONVERSATIONAL MODES • NON-CONVERSATIONAL • CONVERSATIONAL • PSEUDO CONVERSATIONAL
NON-CONVERSATIONAL TRANSACTION • Does not involve any user interaction (e.g. all Batch programs) • Transaction has to be initiated by special ways •Automatic task initiation •Using START command from another transaction
CONVERSATIONAL TRANSACTIONProgram converses with the user using SEND and RECEIVE command pair The program waits and resources held until the user responds Applications written in conversational mode are very inefficient.
PSEUDO-CONVERSATIONAL TRANSACTION Program terminates after sending a message with a pointer to the next task. Resources are freed while waiting for the user’s response More efficient than the Conversational approach. When the user completes the response, the next task is automatically initiated by CICS.
PSEUDO CONVERSATIONAL MODE: METHOD 1 TXN1 PGM00001 TXN2 PGM00002 PGM00001 SEND MAP ..... .... RETURN TRANSID(‘TXN2’) PGM00002 RECEIVE MAP ..... ..... SEND RETURN PCT ENTRIES
PSEUDO CONVERSATIONAL MODE: METHOD 2 TXN1 PGM00001 PGM00001 PARA- A SEND MAP ..... .... RETURN TRANSID(‘TXN1’) COMMAREA(WS-DATA) RECEIVE MAP ..... ..… SEND MAP ... RETURN TRANSID(‘TXN1’) COMMAREA(WS-COMM-AREA) PCT ENTRIES PGM00001 PARA- B IF EIBCALEN = 0 PERFORM PARA-A ELSE PERFORM PARA-B Zero for 1st time entry into pgm
ERRORS CONDITIONS IN PROGRAM CONTROL COMMANDS • INVREQ • LENGERR • NOAUTH • PGMIDERR
INTERVAL CONTROL - COMMANDSASKTIME FORMATTIME DELAY START RETRIEVE CANCEL
ASKTIME - SYNTAX To request current date and time. EXEC CICS ASKTIME[ABSTIME(data_area)] END-EXEC
FORMATTIME - SYNTAX EXEC CICS FORMATTIME ABSTIME(data-area) [YYDDD(data-area)] [YYMMDD(data-area)] [YYDDMM(data-area)] [DDMMYY(data-area)] [MMDDYY(data-area)] [DATASEP(data-value)] [DAYOFWEEK(data-area)] [DAYOFMONTH(data-area)] [MONTHOFYEAR(data-area)] [YEAR(data-area)] [TIME(data-area) [TIMESEP(data-value)]] END-EXEC.
FORMATTIME - EXAMPLE WORKING STORAGE SECTION. 77 WS-ABS-DATE PIC S9(15) COMP-3 01 WS-DATE. 05 WS-D-MM PIC 99. 05 FILLER PIC X. 05 WS-D-DD PIC 99. 05 FILLER PIC X. 05 WS-D-YY PIC 99. 01 WS-TIME. 05 WS-T-HH PIC 99. 05 FILLER PIC X. 05 WS-T-MM PIC 99. 05 FILLER PIC X. 05 WS-T-SS PIC 99. PROCEDURE DIVISION. EXEC CICS ASKTIME ABSTIME(WS-ABS-DATE) END-EXEC. EXEC CICS FORMATTIME ABSTIME(WS-ABS-DATE) MMDDYY(WS-DATE) DATESEP(‘-’) TIME(WS-TIME) TIMESEP(:) END-EXEC. Result : WS-DATE : 08-28-97 WS-TIME : 12:23:37
DELAY COMMAND To delay a task for the specified time interval or until the specific time EXEC CICS DELAY INTERVAL(data-value) | TIME (data-value) END-EXEC Example 1: Example 2 : EXEC CICS DELAY EXEC CICS DELAY INTERVAL(001500) TIME(163000) END-EXEC. END-EXEC.
ASYNCHRONOUS TRANSACTION STARTING - START COMMAND To initiate a transaction from current task. EXEC CICS START TRANSID(data-value) [TIME(hhmmss) | INTERVAL (hhmmss)] [AFTER [HOURS(hh)] [MINUTES(mm)] [SECONDS(ss)] | AT [HOURS(hh)] [MINUTES(mm)] [SECONDS(ss)]] [TERMID(data-value)] [FROM(data-area)] [LENGTH(data-value)] [REQID(NAME)] END-EXEC
RETRIEVE COMMAND To retrieve data passed by a task issuing a START transaction EXEC CICS RETRIEVE INTO (data-area) LENGTH(data-value) END-EXEC. Example : EXEC CICS RETRIEVE INTO (WS-DATA) LENGTH(100) END-EXEC.
START & RETRIEVE : EXAMPLE WORKING STORAGE. 77 WS-DATA PIC X(100). PROCEDURE DIVISION. .... Update data in WS-DATA. EXEC CICS START TRANSID(‘TRN2’) FROM(WS-DATA) LENGTH(100) END-EXEC. .... WORKING STORAGE. 77 WS-IN-DATA PIC X(100). PROCEDURE DIVISION. .... EXEC CICS RETRIEVE INTO (WS-IN-DATA) LENGTH(100) END-EXEC. .... PROG001 PROG002 TRN1 PROG001 TRN2 PROG002 PCT
CANCEL COMMAND To Cancel a previously issued START command Transaction to be cancelled identified by REQID Cannot be cancelled if the transaction had already started. EXEC CICS CANCEL REQID(data-value) END-EXEC Example : EXEC CICS START TRNSID(‘TRN1’) REQID(‘START1’) TIME (084000) END-EXEC. .... EXEC CICS CANCEL REQID(‘START1’) END-EXEC
TASK CONTROL COMMANDSSUSPENDCommand Task suspended and control given to other tasks with higher priority Control returns back to the suspended task once other tasks are executed Similar to the DELAY Command EXEC CICS SUSPEND END-EXEC.
ENQ AND DEQ COMMANDSENQ Command To gain exclusive control over a resource EXEC CICS ENQ RESOURCE(resource-id) END-EXEC. DEQ Command To free the exclusive control from a resource EXEC CICS DEQ RESOURCE(resource-id) END-EXEC.
SESSION 5 : SUMMARY Logicallevels inCICSoperation PassingdatausingLINK PassingdatausingXCTL RETURN command Static andDynamic calls - PassingdatainaCall Pseudo-conversational mode- Examples Errors inprogramcontrol IntervalControlCommands TaskControlCommands

Cics program, interval and task control commands-session 5

  • 1.
    CICS – PROGRAM,INTERVAL AND TASK CONTROL COMMANDS Day2- Session5 Updated in Nov 2004
  • 2.
    SESSION 5 :OBJECTIVESTo Understand the Logical levels in CICS operation LINK command XCTL command RETURN command Static and Dynamic calls Conversational modes Errors in program control Interval Control Commands Task Control Commands
  • 3.
    PROGRAM TO PROGRAM TRANSITION Theprograms within a task can execute at different logical levels using the following commands CICS LINK CICS XCTL CICS RETURN CICS CALL
  • 4.
    LOGICAL LEVELS CICS SubSystemLEVEL 0 LEVEL 1 LEVEL 2 Program A XCTL ‘Pgm B’ LINK C RETURN Program C RETURN Program B RETURN
  • 5.
    LINK’ING TO ANOTHERPROGRAM PROGRAM A PROGRAM C PROCEDURE DIV. LINK ... PGM C PROCEDURE DIV. . . . . . . RETURN
  • 6.
    PASSING DATA USINGLINK PROG000A PROG000C WORKING STORAGE WS-DATA . PROCEDURE ... LINK PROG000C COMMAREA(WS-DATA) LINKAGE SECTION DFHCOMMAREA . PROCEDURE ... RETURN
  • 7.
    LINK COMMAND EXEC CICSLINK PROGRAM(pgm-name) COMMAREA(comm-area) LENGTH(length) END-EXEC. Example : EXEC CICS LINK PROGRAM(‘PROG000C’) COMMAREA(WS-DATA) LENGTH(WS-DATA-LENGTH) END-EXEC.
  • 8.
    XCTL’ING TO ANOTHER PROGRAM PROGRAMA PROGRAM B PROCEDURE DIV. XCTL ... PGM B . . . PROCEDURE DIV... . . . . . . RETURN CICS SYSTEM
  • 9.
    PASSING DATA USINGXCTL PROG000A PROG000B WORKING STORAGE WS-DATA . PROCEDURE ... XCTL PROG000B COMMAREA(WS-DATA) LINKAGE SECTION DFHCOMMAREA . PROCEDURE ... RETURN CICS SYSTEM
  • 10.
    XCTL COMMAND EXEC CICSXCTL PROGRAM(pgmname) COMMAREA(comm-area) LENGTH(length) END-EXEC. Example: EXEC CICS XCTL PROGRAM(‘PGMSAMP’) COMMAREA(WS-COMMAREA) LENGTH(WS-COMM-LENGTH) END-EXEC.
  • 11.
  • 12.
    STATIC CALL PROCEDURE DIVISION . . . CALL‘PGM0002’ . . . THE CALLER AND THE CALLED PROGRAM MUST BE LINK-EDITED TOGETHER INTO A SINGLE LOAD MODULE PGM00001
  • 13.
    DYNAMIC CALL PROCEDURE DIVISION . MOVE‘PGM0001’ TO WS-PGM. . CALL WS-PGM . . . THE CALLER AND THE CALLED PROGRAM ARE LINK EDITED AS SEPARATE LOAD MODULES PGM00001
  • 14.
    PASSING DATA INCALL PROG000A PROG000C LINKAGE SECTION 01 DFHEIBLK .... 01 DFHCOMMAREA 01 WS-DATA . PROCEDURE DIVISION USING DFHEIBLK DFHCOMMAREA WS-DATA . .. GOBACK PROCEDURE DIV ... CALL ‘ PROG000C’ USING DFHEIBLK DFHCOMMAREA WS-DATA
  • 15.
    CONVERSATIONAL MODES • NON-CONVERSATIONAL •CONVERSATIONAL • PSEUDO CONVERSATIONAL
  • 16.
    NON-CONVERSATIONAL TRANSACTION • Does notinvolve any user interaction (e.g. all Batch programs) • Transaction has to be initiated by special ways •Automatic task initiation •Using START command from another transaction
  • 17.
    CONVERSATIONAL TRANSACTIONProgram converses withthe user using SEND and RECEIVE command pair The program waits and resources held until the user responds Applications written in conversational mode are very inefficient.
  • 18.
    PSEUDO-CONVERSATIONAL TRANSACTION Program terminates aftersending a message with a pointer to the next task. Resources are freed while waiting for the user’s response More efficient than the Conversational approach. When the user completes the response, the next task is automatically initiated by CICS.
  • 19.
    PSEUDO CONVERSATIONAL MODE: METHOD1 TXN1 PGM00001 TXN2 PGM00002 PGM00001 SEND MAP ..... .... RETURN TRANSID(‘TXN2’) PGM00002 RECEIVE MAP ..... ..... SEND RETURN PCT ENTRIES
  • 20.
    PSEUDO CONVERSATIONAL MODE: METHOD2 TXN1 PGM00001 PGM00001 PARA- A SEND MAP ..... .... RETURN TRANSID(‘TXN1’) COMMAREA(WS-DATA) RECEIVE MAP ..... ..… SEND MAP ... RETURN TRANSID(‘TXN1’) COMMAREA(WS-COMM-AREA) PCT ENTRIES PGM00001 PARA- B IF EIBCALEN = 0 PERFORM PARA-A ELSE PERFORM PARA-B Zero for 1st time entry into pgm
  • 21.
    ERRORS CONDITIONS INPROGRAM CONTROL COMMANDS • INVREQ • LENGERR • NOAUTH • PGMIDERR
  • 22.
  • 23.
    ASKTIME - SYNTAX Torequest current date and time. EXEC CICS ASKTIME[ABSTIME(data_area)] END-EXEC
  • 24.
    FORMATTIME - SYNTAX EXECCICS FORMATTIME ABSTIME(data-area) [YYDDD(data-area)] [YYMMDD(data-area)] [YYDDMM(data-area)] [DDMMYY(data-area)] [MMDDYY(data-area)] [DATASEP(data-value)] [DAYOFWEEK(data-area)] [DAYOFMONTH(data-area)] [MONTHOFYEAR(data-area)] [YEAR(data-area)] [TIME(data-area) [TIMESEP(data-value)]] END-EXEC.
  • 25.
    FORMATTIME - EXAMPLE WORKINGSTORAGE SECTION. 77 WS-ABS-DATE PIC S9(15) COMP-3 01 WS-DATE. 05 WS-D-MM PIC 99. 05 FILLER PIC X. 05 WS-D-DD PIC 99. 05 FILLER PIC X. 05 WS-D-YY PIC 99. 01 WS-TIME. 05 WS-T-HH PIC 99. 05 FILLER PIC X. 05 WS-T-MM PIC 99. 05 FILLER PIC X. 05 WS-T-SS PIC 99. PROCEDURE DIVISION. EXEC CICS ASKTIME ABSTIME(WS-ABS-DATE) END-EXEC. EXEC CICS FORMATTIME ABSTIME(WS-ABS-DATE) MMDDYY(WS-DATE) DATESEP(‘-’) TIME(WS-TIME) TIMESEP(:) END-EXEC. Result : WS-DATE : 08-28-97 WS-TIME : 12:23:37
  • 26.
    DELAY COMMAND To delaya task for the specified time interval or until the specific time EXEC CICS DELAY INTERVAL(data-value) | TIME (data-value) END-EXEC Example 1: Example 2 : EXEC CICS DELAY EXEC CICS DELAY INTERVAL(001500) TIME(163000) END-EXEC. END-EXEC.
  • 27.
    ASYNCHRONOUS TRANSACTION STARTING -START COMMAND To initiate a transaction from current task. EXEC CICS START TRANSID(data-value) [TIME(hhmmss) | INTERVAL (hhmmss)] [AFTER [HOURS(hh)] [MINUTES(mm)] [SECONDS(ss)] | AT [HOURS(hh)] [MINUTES(mm)] [SECONDS(ss)]] [TERMID(data-value)] [FROM(data-area)] [LENGTH(data-value)] [REQID(NAME)] END-EXEC
  • 28.
    RETRIEVE COMMAND To retrievedata passed by a task issuing a START transaction EXEC CICS RETRIEVE INTO (data-area) LENGTH(data-value) END-EXEC. Example : EXEC CICS RETRIEVE INTO (WS-DATA) LENGTH(100) END-EXEC.
  • 29.
    START & RETRIEVE: EXAMPLE WORKING STORAGE. 77 WS-DATA PIC X(100). PROCEDURE DIVISION. .... Update data in WS-DATA. EXEC CICS START TRANSID(‘TRN2’) FROM(WS-DATA) LENGTH(100) END-EXEC. .... WORKING STORAGE. 77 WS-IN-DATA PIC X(100). PROCEDURE DIVISION. .... EXEC CICS RETRIEVE INTO (WS-IN-DATA) LENGTH(100) END-EXEC. .... PROG001 PROG002 TRN1 PROG001 TRN2 PROG002 PCT
  • 30.
    CANCEL COMMAND To Cancela previously issued START command Transaction to be cancelled identified by REQID Cannot be cancelled if the transaction had already started. EXEC CICS CANCEL REQID(data-value) END-EXEC Example : EXEC CICS START TRNSID(‘TRN1’) REQID(‘START1’) TIME (084000) END-EXEC. .... EXEC CICS CANCEL REQID(‘START1’) END-EXEC
  • 31.
    TASK CONTROL COMMANDSSUSPENDCommand Tasksuspended and control given to other tasks with higher priority Control returns back to the suspended task once other tasks are executed Similar to the DELAY Command EXEC CICS SUSPEND END-EXEC.
  • 32.
    ENQ AND DEQCOMMANDSENQ Command To gain exclusive control over a resource EXEC CICS ENQ RESOURCE(resource-id) END-EXEC. DEQ Command To free the exclusive control from a resource EXEC CICS DEQ RESOURCE(resource-id) END-EXEC.
  • 33.
    SESSION 5 :SUMMARY Logicallevels inCICSoperation PassingdatausingLINK PassingdatausingXCTL RETURN command Static andDynamic calls - PassingdatainaCall Pseudo-conversational mode- Examples Errors inprogramcontrol IntervalControlCommands TaskControlCommands