You are on page 1of 24

CICS - Application Programming,Use of Return

Command,Program Preparation and Execution

1
Session Objectives
To understand

• Introduction to Application Programming


• SEND, RECEIVE, RETURN – Command format and Argument Values
• CICS Embedding in COBOL Application program
• Program Preparation and Execution

2
Host Languages
CICS supports the following host languages :

• COBOL
• Assembler
• PL/1
• C and C++
• Java

In this course, COBOL will be used as the primary programming


language.

3
Application Programming in CICS
Some steps to be followed in pseudo-conversation programs:


The length of the commarea will be checked to decide whether the map is
being sent for the first time or not. Initially, the map has to be sent when
EIBCALEN is 0.


When the map is with the user awaiting response, pseudo conversation
happens with the help of the RETURN command. The commarea needs to
be populated with some value so that EIBCALEN will not be zero on re-
entry.


The second time, the map will be received and the values will be obtained
within the program. After processing the data, it can be sent to the screen
again.
4
Pseudo-Code for COBOL - CICS program
DEFINE THE COMMAREA IN THE WORKING STORAGE SECTION.
DEFINE THE DFHCOMMAREA WITH THE SAME SIZE OF COMMAREA IN LINKAGE SECTION.
MOVE DFHCOMMAREA TO WS-COMMAREA
IF EIBCALEN = 0

STEP1: SEND MAP


STEP2: POPULATE THE COMMAREA WITH SOME VALUE
STEP3: ISSUE CONDITIONAL RETURN (TRANSACTION ID AND COMMAREA)
ELSE
STEP4: RECEIVE MAP
STEP5: PROCESS DATA
STEP6: SEND OUTPUT MAP
STEP7: POPULATE THE COMMAREA WITH SOME VALUE
STEP8: ISSUE CONDITIONAL/UNCONDITIONAL RETURN
…….......
…………

END-IF
5
CICS Command Format

EXEC
EXEC CICSCICSfunction
function
[option
[option ( argument
( argument value)]
value)]
[option
[option ( argument
( argument value)]
value)]
... ...
[RESP
[RESP ( argument
( argument value)]
value)]
END-EXEC
END-EXEC

6
Argument values
• Data Value
• Data Area
• Name
• Label
• Time in hhmmss format
• Pointer Reference

7
SEND COMMAND(1/2)
Send command is used to send the map/text to the user for
responding to a request.

8
SEND COMMAND(2/2)
Some of the parameters are as follows:

1. MAP – name of the screen which needs to be sent


2. MAPSET – name of the mapset where the map is present
3. FREEKB – specifies that the keyboard is to be unlocked when the data is
written.
4. ERASE - specifies the screen buffer needs to be erased before the screen
is displayed.
5. CURSOR – used when the cursor needs to be dynamically positioned on
screen.
6. FROM – specifies the data area that contains data needs to be sent.
7. LENGTH – specifies the length of the data that needs to be formatted.

9
RECEIVE COMMAND(1/2)
Receive command is used to receive screen input into the data
area in the application program. This data can then be logically
processed.

10
RECEIVE COMMAND(2/2)

Some of the parameters are as follows:

1. MAP – name of the screen which needs to be received.


2. MAPSET – name of the mapset where the map is present.
3. INTO – specifies the data area into which the mapped data needs to be
written.
4. LENGTH – specifies the length of the data has been received.

11
RETURN COMMAND(1/2)
Return command is used to return control from an application
program either to another application program at the next
higher logical level or to CICS.

1. Return command to implement pseudo-conversation. The trans-id and


commarea will ensure re-entry into the program after temporary termination.

12
RETURN COMMAND(2/2)

2. Return command to exit from the program completely and provide control to
CICS.

13
CICS Program Preparation

14
CICS - DB2 Program Preparation

Source Pre-Compile Translate Translated


Program Source

DBRM Precompile Translator


Listing Listing Compile

Bind
Compiler
Listing

Application Load Object


Plan Module Link-Edit
Module

15
CICS Program Preparation

• COBOL-CICS programs should be compiled with RENT option to make it


Re-entrant.

• A CICS-DB2-COBOL program would require a few more additional steps


like a Pre-compile and a Bind. The pre-compiler would generate a DBRM
(Database Request Module) and the bind will generate a plan or package
using the DBRM.

16
Compiling the CICS Program

A CICS program contains the EXEC CICS command. The language
compilers are unaware of that command. Therefore a kind of pre-processor
is necessary to translate each EXEC CICS commands into a language-
specific CALL statement.


Language statements remain unchanged, but CICS commands are
translated into CALL statements of the form required by the language in
which you code.


The CALL invokes a CICS-provided "EXEC" interface module or stub, which
is a function-dependent piece of code that the CICS high-level programming
interface uses.

17
CICS Statements after Translation
Original Source Code :

EXEC CICS
READ DATASET(ACCMSTR) INTO(ACCT-MSTR-DTLS)
RIDFLD(ACCT-NO) RESP(RESP-CODE)
END-EXEC.

Translated Source
* EXEC CICS
* READ DATASET(‘ACCMSTR’) INTO(ACCT-MSTR-DTLS)
* RIDFLD(ACCT-NO) RESP(RESP-CODE)
* END-EXEC.
MOVE ‘..0……00061 ‘ TO DFHEIV0
MOVE ‘ACCMSTR’ TO DFHC0080
MOVE LENGTH OF ACCT-MSTR-DTLS TO DFHB0020
CALL ‘DFHEI1’ USING DFHEIV0 DFHC0080 ACCT-MSTR-DTLS
DFHB0020 ACCT-NO
MOVE EIBRESP TO RESP-CODE.

18
Link-Editing a CICS Program

High-Level language (HLL) compilers produce a program, listing all the
information that it generated during the compilation. Additionally, another file
is created that contains the object code. This newly created file is input for
another program, the linkage-editor or binder.


During the bind process all external references (for example, calls to sub-
routines and service modules) are resolved. The binder uses information in
the object deck to combine them into a load module.


A load module is an executable program stored in a Partitioned Data Set
(PDS) program library. At program fetch time, the load module produced by
the binder is loaded into virtual storage. When the program is loaded, it then
can be run.

19
Link-Edit Step

20
CICS Program Execution

• Compile and Bind the COBOL-CICS-DB2 programs.

• The Programs and Maps have already been registered in the PCT and PPT
tables.

• Sign on to CICS.

• Execute CEMT command to refresh the map load and program load in the
PPT table.

• Enter 4-character long transaction identifier.

21
Starting a TASK
PCT
PCT
TXN1 Trans. Program
TXC1 MAPPGC1
TXC2 MAPPGC2
PPT
TXN1 TXNPGM1 PPT
TXN2 TXNPGM2 Program. Location
CICS Address Space MAPPGC1 In Storage
MAPPGC2 On Disk
TXNPGM1 In Storage
TXNPGM2 On Disk
MAPPGC1

Load Module Library


MAPPGC1 MAPLIB
MAPPGC2 MAPLIB
TXNPGM1 TXNPGM1 PGMLIB
TXNPGM2 PGMLIB

22
Session 2 : Summary

• Language support and Embedding in COBOL


• Command syntax & Argument values
• Structure of a CICS application program
• Program preparation and Program execution - PCT, PPT

23
THANK YOU

24

You might also like