Sample Programs In Cics Cobol

Posted on admin
Sample Programs In Cics Cobol Average ratng: 4,2/5 8233 reviews

CICS - Sample COBOL CICS Program RAMESH KRISHNA REDDY DRONA SERIES CICS TUTORIAL / STUDY MATERIAL CHAPTER - 3 Sample CICS Program INTRODUCTION Writing CICS programs - We write CICS program in much the same way as you write any other program. You can use COBOL, OO COBOL, C, C, PL/I, or assembler language to write CICS application programs. Most of the processing logic is expressed in standard language statements, but you use CICS commands for some functions. Now, Let us write simple CICS program Requirement: Task 1 - CICS program to accept input from terminal Task 2 - prefix string 'OUTPUT: ' to the input data send it back to the modified data to terminal Program: IDENTIFICATION DIVISION. ENVIRONMENT DIVISION. DATA DIVISION.

AssemblerCobol

Join the more than 150,000 programmers who have learned CICS using our CICS books alone. Now, our two-part CICS for the COBOL Programmer has been revised into a. The following examples show JCL procedures (PROCs) that may be used to compile and link a program for execution in a CICS environment.

WORKING-STORAGE DIVISION. 01 WS-INPUT. 05 WS-TRAN-ID PIC X(4).

05 WS-MESSAGE-I PIC X(70). 01 WS-OUTPUT. 05 WS-TEXT PIC X(8).

05 WS-MESSAGE-O PIC X(70). 01 WS-MSG-LENGTH PIC S9(4) COMP.

PROCEDURE DIVISION. MOVE 74 TO WS-MSG-LENGTH.

(1). EXEC CICS RECEIVE - (2) INTO(WS-INPUT) LENGTH(WS-MSG-LENGTH) END-EXEC. MOVE WS-MESSAGE-I TO WS-MESSAGE-O. (3) MOVE 'OUTPUT: ' TO WS-TEXT. (4) MOVE 78 TO WS-MSG-LENGTH.

(5). EXEC CICS SEND - (6) FROM(WS-OUTPUT) LENGTH(WS-MSG-LENGTH) ERASE END-EXEC. EXEC CICS RETURN - (7) END-EXEC. (8). © www.mainframegurukul.com Explanination - (1) Moving 74 to WS-MSG-LENGTH, ie., we are expecting 74 bytes of input data from the terminal (2) All CICS commands embedded in COBOL program must be between EXEC CICS & END-EXECtags.

Observe the RECEIVE command started with EXEC CICS & ended with END-EXEC tag. Using this RECEIVE CICS command, program can able to get the data passed from terminal.

There are two options used in this command. A) INTO - received data will be placed into WS-INPUT variable b) LENGTH - length of the data we are expecting to receive (3) Moving input data to part of output variable.

If you observe one thing here, we are not move WS-INPUT to WS-OUPUT, Why because, In WS-INPUT, first 4 bytes is transactionID, which is used by CICS to identify our program to execute. Rest of the data we are passing to second part of output variable, first part of output variable contains the value 'OUTPUT:' in it.

(4) Now our task is to add 'OUTPUT:' string to received data. For that we are moving 'OUPUT:' string to WS-TEXT which is part of output variable WS-OUTPUT.

Programs

(5) Since WS-OUTPUT variable size is 78, we are move 78 to WS-MSG-LENGTH (6) Now in step 6, we are using SEND command to send the the data in WS-OUPUT variable to terminal. There are two options used in this command. A) FROM - specifing data location to be send to terminal b) LENGTH - specifing length of data being passed to terminal c) ERASE - instructing to erase data on the screen, before printing data that is being send. (7) RETURN command terminates current transaction. (8) GOBACK statement returns control to CICS. EXECUTING CICS PROGRAM - To execute above CICS program in CICS region, programmer should follow these steps (1) Compile the program (2) Move the load module to CICS load libraries. (3) Define the Transaction identifier ( 1 to 4 bytes ) in PCT (Program control table ) along with program name.

(4) Define program name in PPT (Processing Program Table ) (5) Login into CICS region (6) Enter transaction identifier defined in PCT. It will execute your program and return the results. NEXT CHAPTER TOPIC: Resource Definition.

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. CICS Program 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 − Step 1 Login to Mainframes and open a TSO Session. Step 2 Create a new PDS in which we will be coding our program.

Step 3 Create a new member inside the PDS and code the following program − IDENTIFICATION DIVISION. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 WS-MESSAGE PIC X(40).

01 WS-LENGTH PIC S9(4) COMP. PROCEDURE DIVISION. 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. Step 4 After coding the program, we need to compile it.

Sample Cobol Db2 Program

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) // Step 5 Open a CICS session. Step 6 We will now install the program using the following command − CEMT SET PROG(HELLO) NEW.

Step 7 Execute the program using the associated transaction-id. Transaction-id is provided by the Administrator.

It will show the following output − Program Compilation The following flowchart shows the steps used in compiling a COBOL-CICS program − Translator The function of a translator is to check for syntax errors in CICS commands. It translates them into equivalent COBOL statements. Compiler The function of a compiler is to expand the COBOL copy books. It compiles the code after checking the source code for syntax errors. Linkage Editor The function of a Linkage Editor is to link different object modules to create a single load module.