You are on page 1of 27

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 Compilation and options available Linker options Execution


– –

Testing and Debugging
Handle Abends Native commands like CEMT, CECI, CEBR
Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0

2

Coding COBOL under CICS
BMS Screens (Presentation Layer)

BMS

VTAM

COBOL – CICS program (Business Layer)

• EXEC interface stubs

Copyright © 2005, Infosys Technologies Ltd

3

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.

Copyright © 2005, Infosys Technologies Ltd

4

ER/CORP/CRS/TP01/003 Version No: 1.0

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).

Copyright © 2005, Infosys Technologies Ltd

5

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’) END-EXEC.

Copyright © 2005, Infosys Technologies Ltd

6

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.
Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0

7

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

Copyright © 2005, Infosys Technologies Ltd

8

ER/CORP/CRS/TP01/003 Version No: 1.0

Pseudo - conversational techniques
• EVALUATE your populated EIBAID.
Ex.B000-AID-CHK-PARA. EVALUATE EIBAID WHEN DFHENTER --------------WHEN DFHPF1 --------------END-EVALUATE.

Copyright © 2005, Infosys Technologies Ltd

9

ER/CORP/CRS/TP01/003 Version No: 1.0

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.
Copyright © 2005, Infosys 10 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
Copyright © 2005, Infosys 11 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

Copyright © 2005, Infosys 12 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.

Copyright © 2005, Infosys 13 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.

• HANDLE ABEND
EXEC CICS HANDLE ABEND LABEL (abend-handle-para) END-EXEC.
Copyright © 2005, Infosys 14 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.

Copyright © 2005, Infosys 15 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

Copyright © 2005, Infosys 16 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'

Copyright © 2005, Infosys 17 Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

Compilation of Cobol-CICS program
SOURCE CODE TRANSLATOR TRANSLATED SOURCE CODE COMPILER OBJECT MODULE LINKAGE EDITOR LOAD MODULE
Copyright © 2005, Infosys 18 Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0

TRANSLATOR LISTING

COMPILER LISTING

LINK EDIT LISTING

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
Copyright © 2005, Infosys 19 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

Copyright © 2005, Infosys 20 Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

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.

Copyright © 2005, Infosys 21 Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

CICS Hello World! Program Development
Step 4: Compile the program using the clist TRNGCICS

Copyright © 2005, Infosys 22 Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

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.

Copyright © 2005, Infosys 23 Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

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

Copyright © 2005, Infosys 24 Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

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.

Copyright © 2005, Infosys 25 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.
Copyright © 2005, Infosys 26 Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0

Thank You!
Copyright © 2005, Infosys 27 Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0