300 likes | 614 Views
Application Program Design. Day3. 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
E N D
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
BMS Screens (Presentation Layer) BMS VTAM COBOL – CICS program (Business Layer) Coding COBOL under CICS • EXEC interface stubs
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.
Pseudo - conversational techniques • The most important thing is passing of data between pseudo-conversational tasks. • We can pass data via a COMMAREA 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 Return Statements • RETURN -1 EXEC CICS RETURN END-EXEC. • RETURN -2 EXEC CICS RETURN TRANSID (‘TN01’) END-EXEC.
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.
Pseudo - conversational techniques Ex.PROCEDURE DIVISION. A000-MAIN-PARA. EXEC CICS HANDLE CONDITION END-EXEC. IF EIBCALEN = 0 ---------- ELSE PERFORM EVALUATE B000-AID-CHK-PARA ENDIF
Pseudo - conversational techniques • EVALUATE your populated EIBAID. Ex.B000-AID-CHK-PARA. EVALUATE EIBAID WHEN DFHENTER --------------- WHEN DFHPF1 --------------- END-EVALUATE.
Useful CICS commands EXEC CICS ASKTIME [ABSTIME(data_area)] END-EXEC. 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.
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
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
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.
NOHANDLE and HANDLE ABEND • NOHANDLE EXEC CICS RECEIVE INTO (IN-DATA-BUF) LENGTH (20) NOHANDLE END-EXEC. • HANDLE ABEND EXEC CICS HANDLE ABEND LABEL (abend-handle-para) END-EXEC.
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.
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
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'
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
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
CICS Hello World! Program Development 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 Step 4: Compile the program using the clist TRNGCICS
Execution of Hello World! Program 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 Step 2: You’ll find a blank screen as shown below. Type the transaction-id. To Sign off, use the transaction CESF
CICS Hello World! Program Development 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.
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.