Application Program Design Day3
2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Objectives Basic CICS programming –Structure of a simple CICS embedded COBOL program –Not to be used COBOL verbs Program Control statements –EXEC Interface Block –Exception handling Creating a run-unit –Translation and options available –Compilation and options available –Linker options –Execution Testing and Debugging –Handle Abends –Native commands like CEMT, CECI, CEBR
3 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Coding COBOL under CICS EXEC interface stubs BMS Screens (Presentation Layer) COBOL – CICS program (Business Layer) BMSVTAM
4 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Not to be used COBOL verbs File I/O statements like –CLOSE, DELETE, OPEN, READ, WRITE, REWRITE, START No File Section and Environment Division required Other statements like –ACCEPT Date/Day/Day-of-week/Time, MERGE, STOP RUN and GO BACK.
5 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Ex.WORKING-STORAGE SECTION. 01 WS-COMMAREA. 02 WS-FLAG PIC X(2). LINKAGE SECTION. 01 DFHCOMMAREA. 02 LK-FLAG PIC X(2). Pseudo - conversational techniques The most important thing is passing of data between pseudo-conversational tasks. We can pass data via a COMMAREA
6 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Pseudo - conversational techniques Return Statements RETURN -1 EXEC CICS RETURN END-EXEC. RETURN -2 EXEC CICS RETURN TRANSID (‘TN01’) TRANSID (‘TN01’)END-EXEC.
7 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Pseudo - conversational techniques Return Statements RETURN -3 EXEC CICS RETURN TRANSID (‘TN01’) COMMAREA (WS-COMMAREA) LENGTH (WS-COMMAREA-LEN) END-EXEC. To get the data back from DFHCOMMAREA MOVE DFHCOMMAREA TO COMMAREA-DATA.
8 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Ex.PROCEDURE DIVISION. A000-MAIN-PARA. EXEC CICS HANDLE CONDITION END-EXEC. IF EIBCALEN = ELSE PERFORM EVALUATE B000-AID-CHK-PARA ENDIF Pseudo - conversational techniques
9 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Ex.B000-AID-CHK-PARA. EVALUATE EIBAID WHEN DFHENTER WHEN DFHPF END-EVALUATE. Pseudo - conversational techniques EVALUATE your populated EIBAID.
10 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 EXEC CICS ASKTIME [ABSTIME(data_area)] END-EXEC. Useful CICS commands EXEC CICS FORMATTIME ABSTIME(data_area) [YYDDD(data_area)] [YYMMDD(data_area)] [YYDDMM(data_area)] [DATESEP(data_value)] [TIME(data_area)] [TIMESEP(data_value)] END-EXEC. EXEC CICS SYNCPOINT END_EXEC.
11 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Exception handling Expected CICS errors –Record not found –Map fail Logical errors –Division by zero –Transaction id error –Illegal character in numeric field Hardware or system errors –Input/output error while accessing files
12 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 CICS commands for exception handling To handle expected CICS errors –HANDLE CONDITION –RESP –The above errors can be ignore by using IGNORE CONDITION or NO HANDLE To handle logical fatal errors –HANDLE ABEND
13 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 HANDLE and IGNORE condition HANDLE CONDITION EXEC CICS HANDLE CONDITION LENGERR (LENGTH-ERR-PARA) INVREQ (INVREQ-ERR-PARA) DUPKEY (DUPKEY-ERR-PARA) ERROR (GEN-ERR-PARA) END-EXEC. IGNORE CONDITION EXEC CICS IGNORE CONDITION LENGERR END-EXEC.
14 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 NOHANDLE and HANDLE ABEND NOHANDLE EXEC CICS RECEIVE INTO (IN-DATA-BUF) LENGTH (20) NOHANDLE END-EXEC. EXEC CICS HANDLE ABEND LABEL (abend-handle-para) END-EXEC. HANDLE ABEND
15 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 RESP code handling WORKING-STORAGE SECTION. 01 WS-RCODE PIC S9(8) COMP PROCEDURE DIVISION EXEC CICS SEND FROM (-----) LENGTH (-----) RESP (WS-RCODE) END-EXEC. IF WS-RCODE = DFHRESP (LENGERR) PERFORM LENGTH-ERROR-PARA-0100.
16 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Creating a run unit The CICS translator –Converting CICS code into the language in which rest of the program is coded –If EXEC SQL is used, additional steps to translate SQL s/ms and bind is required –EXEC commands are translated to CALL s/ms –One input SYSIN and 2 output SYSPUNCH and SYSPRINT
17 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Creating a run unit contd., Compiler options –AMODE(31), RMODE(ANY) –Ex : //LINKEDIT EXEC PGM=HEWL, PARM='XREF,RMODE=ANY,AMODE=31' –AMODE(24), RMODE(24) –Ex : //LINKEDIT EXEC PGM=HEWL, PARM='XREF,RMODE=24,AMODE=24'
18 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Compilation of Cobol-CICS program
19 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Testing and Debugging Abend Control Commands EXEC CICS HANDLE ABEND PROGRAM (name) LABEL (label) CANCEL RESET END-EXEC EXEC CICS ABEND ABCODE(‘9999’) END-EXEC
20 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Native CICS Commands - Recap CESN – to sign on CESF – to sign off CECI – Command level Interpreter CEBR – Temporary Storage Browse CEMT – Enhanced Master Terminal CEDF – Execution Diagnostic facility
21 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Step 1: Open a tso session. Step 2: Create a new PDS. Step 3: Code the following program in a new member. CICS Hello World! Program Development
22 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Step 4: Compile the program using the clist TRNGCICS CICS Hello World! Program Development
23 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Step1: Open an Client session for Mainframe, type CICS3 and hit ENTER key. Enter your User id and Password and press the Enter Key. Execution of Hello World! Program
24 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Step 2: You’ll find a blank screen as shown below. Type the transaction-id. To Sign off, use the transaction CESF Execution of Hello World! Program
25 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Step 5: Open a CICS Session. Step 6: Install the program using the command CEMT SET PROG(program-name) NEW. Step 7: Associate a transaction-id with the program in PCT Note that transaction-ids are unique in the system. CICS Hello World! Program Development
26 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Summary What are the not to be used COBOL verbs? What is used to store and retrieve information in pseudo-conversational programs? Ways of ending a task without ending the transaction How do we know if the program has been entered for the first time? How do we know what key is pressed? How do we do a commit or save changes in CICS? Different ways of exception handling How do we create a run unit in CICS? What are the Native CICS commands? Hello World Program (COBOL-CICS) development.
27 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Thank You!