CICS programs are written in COBOL language in Mainframes. We will be discussing about writing a simple COBOL-CICS program, compiling it, and then executing it.
We will be writing a simple COBOL-CICS program which displays some message on the CICS output screen. This program is to demonstrate the steps involved in executing a COBOL-CICS program. Following are the steps to code a simple program −
Login to Mainframes and open a TSO Session.
Create a new PDS in which we will be coding our program.
Create a new member inside the PDS and code the following program −
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 WS-MESSAGE PIC X(40). 01 WS-LENGTH PIC S9(4) COMP. PROCEDURE DIVISION. A000-MAIN-PARA. MOVE 'Hello World' TO WS-MESSAGE MOVE '+12' TO WS-LENGTH EXEC CICS SEND TEXT FROM (WS-MESSAGE) LENGHT(WS-LENGTH) END-EXEC EXEC CICS RETURN END-EXEC.
After coding the program, we need to compile it. We can compile the program using the following JCL −
//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C //CICSCOB EXEC CICSCOB, //COPYLIB = ABC.XYZ.COPYLIB, //LOADLIB = ABC.XYZ.LOADLIB //LIB JCLLIB ORDER = CICSXXX.CICS.XXXPROC //CPLSTP EXEC DFHEITVL //TRN.SYSIN DD DSN = ABC.XYZ.PDS(HELLO),DISP = SHR //LKED.SYSIN DD * NAME HELLO(R) //
Open a CICS session.
We will now install the program using the following command −
CEMT SET PROG(HELLO) NEW.
Execute the program using the associated transaction-id. Transaction-id is provided by the Administrator. It will show the following output −
The following flowchart shows the steps used in compiling a COBOL-CICS program −
The function of a translator is to check for syntax errors in CICS commands. It translates them into equivalent COBOL statements.
The function of a compiler is to expand the COBOL copy books. It compiles the code after checking the source code for syntax errors.
The function of a Linkage Editor is to link different object modules to create a single load module.