0% found this document useful (0 votes)
92 views113 pages

CICS Online Transaction Processing Overview

The document provides an overview of CICS (Customer Information Control System) and its role in Online Transaction Processing (OLTP) systems, highlighting the differences between online and batch systems. It discusses key considerations for online systems, including performance, file integrity, and security, as well as the functionalities and programming languages associated with CICS. Additionally, it outlines the structure of CICS services, including data communication and management, and the use of Basic Mapping Support for terminal-oriented applications.

Uploaded by

Ricardo Feitosa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views113 pages

CICS Online Transaction Processing Overview

The document provides an overview of CICS (Customer Information Control System) and its role in Online Transaction Processing (OLTP) systems, highlighting the differences between online and batch systems. It discusses key considerations for online systems, including performance, file integrity, and security, as well as the functionalities and programming languages associated with CICS. Additionally, it outlines the structure of CICS services, including data communication and management, and the use of Basic Mapping Support for terminal-oriented applications.

Uploaded by

Ricardo Feitosa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

CICS Training

CICS What is it ?

1
Introduction to OLTP System
 Online Transaction Processing Systems is accepting data from a terminal,
manipulating that data and then sending a message back to the user. All
these usually can be done in a matter of seconds in a well-designed CICS
Systems.

Thus a very key element to online systems is response time.

2
Difference Between Online & Batch System
 BATCH –
Transactions are accumulated into groups (batches) before processing.

 ONLINE – Interactive
Transactions entered one at a time via terminals and processed while you
wait.

3
Batch & Online : differences

BATCH SYSTEM ONLINE SYSTEM


1. Data is entered as needed not in
1. Input data is prepared and given in
sequence (file) sequence (terminal)
2. Since processing sequence is
2. Processing sequence is predictable
and hence restarting the process in unpredictable, Special recovery/restart
case of failure is easy
Process is required in case of failure.
3. Programs and files can’t be shared 3. Programs and files can be shared

4. Programs are scheduled through jobs


4. Transaction can be run at any time

4
Introduction to On-Line

 The main Advantage of On-Line over batch is responsiveness. Batch


response time is usually measured in days where On-Line response
time is usually measured in seconds!
 Another advantage is immediate error correction.
 Disadvantage – COST !!!

5
Online System Considerations

Four Main Areas of Concern :

• Ease of Use
• Performance
• File Integrity
• Security

6
Online System Considerations

 Ease of Use
Common User Access (CUA)
• Entry Model (Dumb Terminals)
 Mainframe CICS, etc.
• Graphical Model (Workstations, PC’s)
 Windows, OS/2, etc.

7
Online System Considerations

 Performance
Response Time (Measurement)
• Time for screen update to occur
• Factors affecting response time
 System load (Number of programs running)
 Communication traffic load
 Data traffic (Number of I/O operations required)
 File activity (Number of files accessed/updated)

8
Online System Considerations

 File Integrity
1. Simultaneous file activity
2. Shared files (Batch program ‘owns’ file)
3. Multiple users with conflicting needs
4. File (Record/Block) locking

9
Online System Considerations

 Security
 Logon Procedure (Name/Password)
 Multi-level Security
• RACF Security profile
• Alternate Logon’s (Supervisor, etc)

10
Introduction to CICS
 Customer Information Control System
 IBM Product of the 70’s (Intro in 1969)
 490 of Fortune 500 use CICS
 Over 1 billion lines of CICS (COBOL) code
 Nearly 15 million CICS terminals
 Nearly 1 million CICS programmers
 Allows BATCH O/S to handle ONLINE

11
Introduction to CICS
 CICS is interface between O/S & program
 CICS acts like an Operating System
 Manages its own storage
 Provides its own file and D/B management
 Has its own TASK manager
 Runs in its own ADDRESS SPACE

12
CICS Interface

Disk storage
Operating system

Application
programs Data access
(VSAM,DB2,IMS)

CICS
Communication
access
(VTAM, SNA,
TCP/IP)

User interface

CICS provides an interface between application programs and operating


system services, such as data access and communication access.
13
CICS in OS/390 Address Space
OS/390

Address space 1 Address space 2 Address space 3 Address space 4

CICS
CICS production Batch TSO
test
region Job user
region

More than one CICS system (or region) can run on the
same computer at the same time.

14
CICS Programming Languages
Language Description

COBOL The most used programming language for both batch and online
applications in a mainframe environment.

Assembler Assembler language is used mostly for special-purpose devices like


ATM machines.

PL/I You probably won’t find any new program development being done
in PL/I.

C and C++ Traditionally used in engineering and math environments. With


C++, an object-oriented language, you can develop object-oriented
classes that access CICS services.

Java The newest language for writing CICS applications, Java can also be
used for developing object-oriented classes that access CICS
services.

15
Terminal Networks

 Network connects terminal to host


 Terminals can be ‘local’ or ‘remote’
 Local
 Short distance (Usually same building)
 Remote
 Further distance (Different cities)

16
3270 Information Display system

3270 display

IBM 3x74
controller
3270 display
S/390
mainframe

LAN/
WAN

Internet/
3270 display Intranet

PC 3270 PC 3270
emulation emulation

PC 3270 PC 3270 PC 3270 PC 3270


emulation emulation emulation emulation

17
CICS Fundamentals

 Multitasking is basic feature of CICS


 CICS allows multiple tasks to operate
 Uses its own method (not regular O/S)
 Works same regardless of O/S

 Multithreading allows program sharing


 Program must be reentrant
 No code modification allowed!

18
How Multitasking works

CICS address space

Task 1 Task 2 Task 3 Task 4 Task 5

Order entry Customer Master menu Customer Order entry


program inquiry program maintenance program
(user 1) program (user 3) program (user 5)
(user 2) (user 4)

A task is the execution of an application program for a specific user

Within CICS, two or more tasks can execute at the same time using a CICS
feature called multitasking

CICS handles multitasking internally, within its own address space

19
How Multithreading works
CICS address space

User 1

Working
storage

Order entry program

User 5

User 1
User 5

Working
storage

With multithreading, two or more users can access the same copy of a
program at the same time. CICS accomplishes this by providing a
separate copy of working storage for each user running the program

20
CICS Fundamentals (contd.)

 CICS/COBOL produces reentrant code.


 Users share same program code.
 Each user gets separate copy of W/S.
 Users invoke a TRANSACTION

21
How conversational programming works
 A conversational program is an online
program that sits idle while it waits for user Start

input
Send
first
 While a conversational program waits for map

user input, the task associated with that


program must remain in storage Wait
for
input

 Conversational programs are often the


cause of a CICS condition known as Short End?
Yes
End
on Storage, or SOS
No

Receive
map

Process
data

Send
map

22
How pseudo-conversational programming works

Wait
 A pseudo-conversational program ends Start for Start
input
after it sends data to a terminal, and
some of the resources used by the Send
End?
Yes
first End
program are released map
No

Receive
End
 CICS restarts the program when the user map

completes an entry and presses one of


the terminal’s attention identifier (AID) Process
data
keys

 A pseudo-conversational program
Send
map

requires a different type of design and


logic than a conversational program
End

23
How CICS invokes an application program

The user enters


ORD1
trans-id ORD1

PCT
Transaction Program
CICS locates DM01 DMPGM01
trans-id ORD1 DM01 DMPGM02
in the Program MMA1 MMAPGM1
Control Table ORD1 ORDPGM1
ORD2 ORDPGM2

PPT
Program Location
CICS locates
program DMPGM01 In storage
ORDPGM1 in the DMPGM02 On disk
Processing MMAPGM1 In storage CICS address space
Program Table ORDPGM1 On disk
ORDPGM2 On disk

DMPGM01

Library Load module MMAPGM1


CICS locates load
module ORDPGM1 DMPROG DMPGM01
on disk, loads it DMPGM02
into memory, and MMAPROG MMAPGM1
starts the task ORDPROG ORDPGM1 ORDPGM1
ORDPGM2

24
CICS Services
 Three main categories of CICS Services:
 Data Communications Services
 Data Management Services
 CICS Management Services

25
CICS Services (contd.)
 Data Communication Services
 Basic mapping Support (BMS)
• Assembler program to handle screen formats.
 Terminal Control
• Interface with VTAM
• Send/Receive text to/from terminal

26
Basic Mapping Support-Objectives
 To simplify the development and maintenance of terminal oriented
application systems.
 Using Formatted Screens
• Field justification
• Field padding
• Provide Attributes for fields

 To improve terminal performance.


 Efficient use of buffering to reduce I/O activity
 Reduce the use of communication lines

27
Formatted Screens

 Screens with fields in proper positions with proper attributes.


 Require Buffer Control Characters (BCCs) to be sent along
with data.
 The mixture of BCCs and TEXT is called as Native Mode
Data Stream (NMDS) which depends on the protocol of the
terminal being used.

28
Physical Maps
 Physical map contains the display format for the map, for a given terminal,
available as a load library member.
 Length and location
 Attributes
 Constants
 Device characteristics

29
Symbolic Maps
 Symbolic map contains all variable data which is copied into programs
working storage section, available as copy library member.

30
MAP & MAPSET
 MAP
 is a single screen format
 MAPSET
 is a collection of maps link edited together to create a load module.
 should have a PPT entry.
 Naming
 1 to 7 chars of generic name for maps and map sets
 1 char added by CICS.

31
BMS Assembly Language Program

 BMS map is a program written in Assembly Language to manage


screens. It
 receives input data and format it into the symbolic map area.
 application program has access only to data in symbolic map
 application program processes data and places the output
variables into the symbolic map.
 BMS will merge output variable data with physical map on send.

32
BMS Macros
 DFHMSD (Mapset definition)
 DFHMDI (Map definition)
 DFHMDF (Map Field definition)

33
DFHMSD Parameters (to define a MAPSET)

 TYPE=DSECT/MAP/&&SYSPARM/FINAL
 MODE=IN/OUT/INOUT
 LANG=ASM/COBOL/PL1
 STORAGE=AUTO/BASE=name
 CTRL=(PRINT,FREEKB,ALARM,FRSET)
 TERM=terminal type, SUFFIX=n
 TIOAPFX=YES/NO
 MAPATTS=(COLOR,HIGHLIGHT,.......)
 DSATTS=(COLOR,HIGHLIGHT,.......)
 COLOR=DEFAULT/ colour
 HIGHLIGHT=OFF/BLINK/REVERSE/UNDERLINE

34
Example of DFHMSD
DFHMSD TYPE=&&SYSPARM, X
CTRL=(FREEKB,FRSET), X
LANG=COBOL, X
STORAGE=AUTO, X
TIOAPFX=YES, X
MODE=INOUT, X
TERM=3270
DFHMSD TYPE=FINAL
END

35
DFHMDI Parameters
 SIZE=(LINE,COLUMN)
 LINE=line-number
 COLUMN=column-number
 JUSTIFY=left/right

36
Example of DFHMDI

MAPNAME DFHMDI SIZE=(24,80), X


LINE=01, X
COLUMN=01, X
CTRL=(FREEKB,FRSET)

37
DFHMDF Parameters

 POS=(line, column)
 LENGTH=number
 INITIAL=‘text’
 JUSTIFY=(LEFT/RIGHT,BLANK/ZERO)
 ATTRB=(ASKIP/PROT/UNPROT, NUM, BRT/NORM/
DRK, IC, FSET)
 COLOR=DEFAULT/colour
 HIGHLIGHT=OFF/BLINK/REVERSE/UNDERLINE
 PICIN=‘value’
 PICOUT=‘value’
 OCCURS=n
38
Example of DFHMDF

DFHMDF POS=(01,01), LENGTH=4, X


INITIAL=‘SCR1’, X
ATTRB=(PROT,NORM)

DATEM DFHMDF POS=(01,70), LENGTH=08, X


ATTRB=(PROT,NORM)
DFHMDF POS=(01,79), LENGTH=1, X
ATTRB=ASKIP

39
MDT - Modified Data Tag
 Used to know whether the field is modified by the user or not. The field is
only receivable if it has been modified.

40
FORMAT OF SYMBOLIC MAP

 A 12-byte TIOA (Terminal Input/Output Area) prefix.

 The map names are suffixed with ‘I’ and ‘O’

 When performing INPUT functions fields suffixed with ‘L’, ’F’ and ‘I’ are
meaningful

 When performing OUTPUT functions fields suffixed with ‘A’, and ‘O’ are
meaningful

41
Data Management
 The core portion or Nucleus of CICS consists of IBM supplied control
programs and corresponding user defined CICS control tables.

 CICS control programs perform their primary task based on the entries in the
corresponding user defined CICS control tables.
 Programmers can modify the control table entries depending on requirement.

 CICS This makes CICS system flexible and easy to maintain.

42
Control Programs Control Tables

SIP (System Initialization Program) SIT (System Initialization Table)


TCP (Terminal Control Program) TCT (Terminal Control table)
SCP (Storage Control Program)
KCP (Task Control Program) PCT (Program Control Table)
PCP (Program Control Program) PPT (Processing Program Table)
FCP (File Control Program) FCT (File Control Table)
TSP (Temporary Storage Program) TST (Temporary Storage Table)
TDP (Transient Data Program) DCT (Destination Control Table)

43
CICS Control Programs and Tables
 PPT = Processing Program Table
 List of all valid program names
 Used by CICS to determine if in storage.
 IF not in storage, CICS loads NEW COPY
 Tables created by programmer with CEDA
 RDO = Resource Definition Online – CEDA
 Files defined in FCT
 FCT = File Control Table
 List of available files, status, type, security

44
Basic CICS Commands

General Structure:
EXEC CICS
CICS COMMAND
OPTION (value) …
(Parameters as needed)
END-EXEC

45
Program Control Commands

EXEC CICS
LINK PROGRAM(name)
[ COMMAREA (data-area) ]
[ LENGTH (data-value) ]
END-EXEC
NOTE: Program name must be in PPT.
Works like COBOL PERFORM statement.

46
Program Control Commands

EXEC CICS
XCTL PROGRAM(name)
[ COMMAREA (data-area) ]
[ LENGTH (data-value) ]
END-EXEC
NOTE: Program name must be in PPT.

47
Program Control Commands

EXEC CICS
RETURN [ TRANSID (name) ]
[ COMMAREA (data-area) ]
[ LENGTH (data-value) ]
END-EXEC

48
XCTL Vs LINK

 XCTL does not expect • LINK expects control back.


control back.
 Handle conditions in the • Handle conditions in the calling
main program are not
available to the called program are needed again. Hence use
program. Establish new PUSH and POP commands to restore
handle conditions. them again.

 XCTL does not expect • LINK expects control back and hence
control back and hence less the overhead is more in this case on
overhead on system memory etc.
resources like memory etc.

 • Similar to perform, and control will be


Similar to GO TO.
passed back to the instruction
following this.

49
CALL Vs XCTL/LINK
 Link edited along with the • Separately compiled and
main module.
link edited.
 Higher module size and
higher memory •Single copy be shared.
requirement.
Dynamic loading may slow
 Single copy can not be down execution speed.
used.
• Changes in this will not
 Any changes in this require
compiling of all other effect other modules using
modules using this. this.
 A Called program remains • A LINKed or XCTLed
in the last used state after it
returns control. program always brings a
NEW copy.

50
COBOL Considerations
 Identification Division.
 No differences
 Environment Division
 MUST be EMPTY in CICS Program!
 No SELECT statements allowed!
 Data Division
 No FILE SECTION – (No SELECTS)

51
COBOL Considerations (More)

 Data Division
 WORKING-STORAGE SECTION.
• Switches, Flags, Variables, Records, etc.
• You get ‘fresh’ copy each time program loaded!
 LINKAGE SECTION (New Item!!)
• DFHCOMMAREA defined or CICS will!
• Used to receive data from CICS.
• CICS also inserts EIB Block definition

52
COBOL Considerations (More)
 Procedure Division
 Uses most COBOL statements

• OPEN, CLOSE, and non-CICS READ & WRITE statements are not permitted.
File management is handled by CICS

• Many COBOL features should be avoided like internal sorts, using special registers,
ACCEPT, DISPLAY, EXHIBIT, TRACE, STOP RUN, & GOBACK. (STOP RUN &
GOBACK are sometimes included in order to eliminate a compiler diagnostic but never
executed

Uses CICS Commands like:


• RETURN
• READ DATASET
• WRITE DATASET
• SEND MAP
• RECEIVE MAP
• XCTL

53
LINKAGE SECTION
 Used to access data left by previous execution of a program
 Data should be moved to your W/S!
 Each execution starts with initial W/S
 Define COMMAREA in Working-Storage
 DEFINE DFHCOMMAREA in Linkage
 RETURN references Working-Storage

54
Fields in the EXEC Interface Block (not all)
01 DFHEIBLK.
.
.
02 EIBCALEN PIC S9(4) COMP.
02 EIBAID PIC X(1).
.
.
Description

The Execute Interface Block (EIB) is a CICS area that contains information related
to the current task. The definition of this area is inserted into the Linkage Section of
the program when the program is prepared for execution

The EIBCALEN field contains the length of the data passed to the program through
its communication area (DFHCOMMAREA)

The EIBAID field indicates the AID key the user pressed to restart the program

55
EXEC Interface Block

 EIB definition added by CICS Compiler


 In Linkage Section after DFHCOMMAREA
 Contains several useful fields
 EIBCALEN, EIBAID, EIBCPOSN, EIBDATE, EIBTIME, EIBTRNID,
EIBTRMID, EIBRSRCE
 Most kept current by CICS
 You can update a few of them-EIBTRNID

56
EIB Useful Fields

 EIBCALEN Length of COMMAREA

 EIBAID Current AID Key pressed

 EIBCPOSN Position of CURSOR

 EIBDATE Task DATE (00YYDDD)

 EIBTIME Task Time (0HHMMSS)

 EIBTRNID Transaction of Task

 EIBTRMID Terminal ID of Task

 EIBRSRCE Recently used Resource Name

 EIBDS Recently accessed Data Set

57
DEBUGGING EIB FIELDS
 EIBFN Last CICS Command
 EIBRESP Completion Status
 EIBRESP2 More Completion Status
 EIBRCODE Response Code (OLD)
 EIBRSRCE Recent Resource Name
 MAP Map Name
 PRG CTL Program Name
 FILE CTL Data Set Name

58
Basic CICS Commands

EXEC CICS
RETURN [ TRANSID (name) ]
[ COMMAREA (data-area) ]
[ LENGTH (data-value) ]
END-EXEC
Length – PIC S9(4) COMP or Literal

59
Basic CICS Commands
EXEC CICS
SEND MAP (name)
[ MAPSET (name) ]
[ FROM (data-area) ]
[ MAPONLY | DATAONLY ]
[ ERASE | ERASEUP ]
[ CURSOR [ (value) ] ]
END-EXEC

60
Basic CICS Commands
EXEC CICS
SEND MAP (name)
[ MAPSET (name) ]
[ FROM (data-area) ]
[ MAPONLY | DATAONLY ]
[ ERASE | ERASEUP ]
[ CURSOR [ (value) ] ]
END-EXEC

61
Basic CICS Commands

EXEC CICS
RECEIVE MAP (map-name)
[ MAPSET (mapset-name) ]
INTO (data-area)
END-EXEC

62
Basic CICS Commands

EXEC CICS
READ DATASET (filename)
INTO (data-area)
RIDFLD (data-area)
[ RRN | RBA ]
[ UPDATE ]
END-EXEC

63
Basic CICS Commands

EXEC CICS
WRITE DATASET (filename)
FROM (data-area)
RIDFLD (data-area)
[ RRN | RBA ]
END-EXEC

64
Basic CICS Commands

EXEC CICS
REWRITE DATASET (filename)
FROM (data-area)
END-EXEC

NOTES:
Record MUST be READ with UPDATE!
data-area - NOT have to match Read

65
Basic CICS Commands

EXEC CICS
DELETE DATASET (filename)
[ RIDFLD (data-area) ]
[ RRN | RBA ]
END-EXEC

NOTE: If no RIDFLD last READ is Deleted

66
Basic CICS Commands
EXEC CICS
UNLOCK DATASET (filename)
END-EXEC

NOTE: If READ/UPDATE command is used and you determine that record


does not need to be updated. Usually not needed as record is unlocked
when the task is terminated.

67
Some useful CICS commands
 ASKTIME updates the EIBDATE and EIBTIME which initially contained the
information about when the task started as well as populates the data_area
with the current date and time.

EXEC CICS ASKTIME


[ABSTIME (data_area)]
END-EXEC.

68
Some useful CICS commands
 FORMATTIME converts the absolute date and time normally produced for
CICS ASKTIME into any one of a number of the optional formats using the
ABSTIME data_area.

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.

69
Exception Conditions

 Most Common Exceptions:

 DISABLED Dataset disabled


 DUPREC Record already exists
 FILENOTFND Dataset not in FCT
 INVREQ Invalid request
 IOERR File I/O error
 NOTAUTH User not authorized
 NOTFND Record not in file

70
Checking for Exceptions
 ALL CICS Commands allow RESP Parm
 01 RESP-CODE PIC S9(8) COMP.

IF RESP-CODE = DFHRESP(NORMAL)
MOVE ‘Y’ TO OK-COMMAND
ELSE
IF RESP-CODE = DFHRESP(NOTFND)
MOVE ‘N’ TO REC-NOT-FOUND
ELSE
PERFORM DISPLAY-MISC-ERROR
END-IF
END-IF

71
Preventing File Corruption

 PREVENT
 Add ‘busy’ flag in record (Special Maint)
 All programs MUST follow procedure
 Extra I/O required (to Set/Reset flag)
 DETECT
 Save copy and compare before updating
 OR – Add Maint -Timestamp and check it
 Notify User to get latest version of data

72
Avoiding Deadlock
 Sometimes called ‘Deadly Embrace’

 Happens when records from multiple files must be updated as a unit


 Withdraw from Savings – Deposit to Check
 Crash after withdraw? Where’s money?

 Must both be done or neither! (Atomic)

73
CICS Program Design

 Event-driven design
 Structure Chart - Consider All Functions
 Identify Events and Context
 Any action that starts program
 List All (Valid) Possible User Actions
 Design Appropriate Response
 Processing required for an event
 Managing user interaction

74
An chart for, customer inquiry program event/response
Event Response

Start the program Display the customer map.

Enter key Receive the customer map.


Edit the customer number.
If valid
read the record.
If the record exists
display it.
If the number isn’t valid or the record doesn’t exist
display an error message.

PF3 or PF12 Return to the menu program.

Clear key Redisplay the customer map without any data.

Any PA key Ignore the key.

Any other key Display an error message.

An event/response chart summarizes each user action (event) and the


program’s response to that event.
75
CICS Program Design
 Event/Response Chart
 Helps with design or Program
 Serves as Documentation of Program
 Sometimes replaced with ‘Structure Chart’
 Structure Chart ‘Evolves’ into Design
 Start with Major Functions
 Add Detail as Needed
 Assign Paragraph Numbering (If Used)

76
CICS Program Design
 COMMAREA usually stores ‘context’
 Get Key
 Add Customer
 Change Customer
 Delete Customer

 Response to same key can be different depending on ‘context’ (ENTER


key)

77
Sample CICS COBOL Program
 WORKING-STORAGE SECTION.
 Switches, Flags, and Misc Variables
 COMMUNICATION-AREA (Your copy!)
 RESPONSE-CODE PIC S9(08) COMP.
 RECORD Descriptions
 COPY Library for MAP
 Other COPY Members as needed

78
Sample CICS COBOL Program
 LINKAGE SECTION.
 DFHCOMMAREA PIC X(nnn).
 If you don’t code it, CICS Will!
 The commarea (if any) placed here!
 EIBCALEN gives length of commarea
 0 (ZERO) means there is NO commarea

79
Sample CICS COBOL Program
 Sample CICS COBOL Program

PROCEDURE DIVISION
IF first-time
SEND Initial-Map
ELSE
IF <ENTER>
Process Screen
ELSE
Process Function-Key
END-IF
END-IF
SEND MAP

80
Sample CICS COBOL Program

PROCEDURE DIVISION
EVALUATE TRUE
WHEN EIBCALEN = 0
First time in Program
WHEN EIBAID = DFHENTER
Process Screen
WHEN EIBAID = DFHPF3 or DFHPF12
Exit Program
WHEN OTHER
Invalid key
END-EVALUATE

81
HANDLE CONDITION

• Common CONDITIONS

• DUPREC Record already exists

• MAPFAIL No data sent by user

• NOSPACE No space left in file


• NOTOPEN Data set not OPEN

• NOTFND Record not in file


• PGMIDERR Program not in PPT

• ERROR ALL conditions not coded


82
HANDLE CONDITION Example

EXEC CICS
HANDLE CONDITION
MAPFAIL(500-NO-DATA)
DUPREC(600-DUPLICATE)
NOTOPEN
END-EXEC
NOTE: Condition by itself will nullify it!

83
RESPONSE CHECKING (NEW!)

 ADD ‘RESP’ option to CICS Command


 Define binary full-word PIC S9(8) COMP
 Name that field in each RESP option
 COPY of EIBRESP from EIB
 EIBRESP2 (RESP2) also available
 Not many CICS Commands use it
 Seldom needed as RESP is usually enough

84
HANDLE CONDITION (Notes)
 Not an executable command
 Establishes paragraph to correct error
 Can issue multiple times
 Last one executed is in effect
 Causes ‘GO TO’ to paragraph named
 Done BEFORE CICS Command executed

85
Strange Exception - MAPFAIL
 MAPFAIL Condition
 Raised by RECEIVE MAP with no data
• User entered no data but pressed AID key
• User pressed CLEAR key or PA key

 Simplest to PREVENT it from occurring


• Check EIBAID to see what key was pressed
• Don’t issue RECEIVE MAP if PA or CLEAR hit
• Include ‘DUMMY’ field with MDT set ON

86
Eight-step procedure for developing a CICS program

Analysis and design


1. Develop a complete set of program specifications
2. Design the program using an event/response chart and a structure chart

Implementation
3. Prepare the BMS map set
4. Code the program
5. Prepare the program for execution
6. Create the necessary CICS table entries
7. Test the program under CICS

Documentation
8. Document the program

87
Program Preparation
 Before you compile a CICS program, you
must translate it Source program

 The CICS translator converts the CICS CICS translator


commands to Move and Call statements
that can be compiled by the COBOL
compiler
Translated program

 The translator also inserts code into your


program that it needs to operate under Copy libraries
COBOL compiler Compiler output
CICS

 After you translate the program, you Object module


compile and link-edit it just as you would
any other COBOL program Linkage editor
Linkage editor output
Object libraries

Load module

88
Write CICS Program Using VSAM

 How you can use VSAM file within the CICS/Cobol


program ???

89
Types of VSAM Files

 ESDS - Entry Sequenced Data Set


 KSDS - Key Sequential Data Set
 RRDS - Relative Record Data Set
 LDS – Linear Data Set

90
How to Use ?
 Create a VSAM cluster using JCL.
 Enter data into it. (Using REPRO)
 Make FCT entry with a symbolic file name for the file created.
 Use symbolic file name in the program.

91
READ

MOVE +80 TO WS-EMP-REC-LEN.


MOVE ‘10000’ TO WS-EMP-REC-KEY.
MOVE 5 TO WS-EMP-KEY-LEN.
EXEC CICS READ
FILE (‘EMPFILE1’)
INTO (WS-EMP-REC)
LENGTH (WS-EMP-REC-LEN)
RIDFLD (WS-EMP-REC-KEY)
KEYLENGTH (WS-EMP-KEY-LEN)
END-EXEC.
Places the record in WS-EMP-REC

92
READ Continues...

 READ COMMAND OPTIONS


 EQUAL
 GTEQ
 UPDATE
 READ-UPDATE/REWRITE
 Maintains exclusive control on the resource (on CI in case of
VSAM file) until
• REWRITE is done
• Transaction ends normally or abnormally
• Control over resource is released by program using UNLOCK
command.

93
WRITE

 To write records into file.


MOVE +80 TO WS-EMP-REC-LEN.
MOVE ‘11000’ TO WS-EMP-REC-KEY.
MOVE 5 TO WS-EMP-KEY-LEN.
EXEC CICS WRITE
FILE (‘EMPFILE’)
FROM (WS-EMP-REC)
LENGTH (WS-EMP-REC-LEN)
RIDFLD (WS-EMP-REC-KEY)
KEYLENGTH (WS-EMP-KEY-LEN)
END-EXEC.

94
REWRITE

 To rewrite records into file.


EXEC CICS REWRITE
FILE (‘EMPFILE’)
FROM (WS-EMP-REC)
LENGTH (WS-EMP-REC-LEN)
END-EXEC.
 This command updates a record.
 Prior to this command the record must be read with a READ UPDATE
command.

95
DELETE
 Read the record with UPDATE option and then delete it with the following
command.
EXEC CICS DELETE
FILE(‘EMPFILE’)
END-EXEC.
 Use the following command to delete the record directly.
MOVE ‘12345’ TO EMP-REC-KEY.
EXEC CICS DELETE
FILE(‘EMPFILE’)
RIDFLD (EMP-REC-KEY)
END-EXEC.

96
GROUP DELETE
 MOVE ‘11’ TO WS-EMP-REC-KEY.
 MOVE 2 TO WS-EMP-KEY-LEN.
EXEC CICS DELETE
FILE (‘EMPFILE’)
RIDFLD (WS-EMP-REC-KEY)
KEYLENGTH (WS-EMP-KEY-LEN)
GENERIC
NUMREC (WS-NUM-REC-DEL)
END-EXEC.

97
Some important bullets
 Exclusive control on CI.

 Exclusive control may cause transaction deadlocks. Make sure to use


UNLOCK when you are not rewriting

 In pseudo-conversation, at the end of transaction, all locks are released.

98
Browsing
» STARTBR

» READNEXT

» READPREV

» RESETBR

» ENDBR

99
STARTBR
 This establishes a browse session.
EXEC CICS STARTBR
FILE (‘EMPFILE’)
RIDFLD (EMP-REC-KEY)
KEYLENGTH(KEY-LEN)
GTEQ/EQUAL/GENERIC
END-EXEC.

100
READNEXT/READPREV
 EXEC CICS READNEXT/READPREV
FILE (‘EMPFILE’)
INTO (EMP-REC)
LENGTH (EMP-REC-LEN)
RIDFLD (EMP-REC-KEY)
END-EXEC.

101
RESETBR

 Establish a new browsing position with in the same browse.


MOVE ‘12345’ TO EMP-REC-KEY.
EXEC CICS RESETBR
FILE (‘EMPFILE’)
RIDFLD (EMP-REC-KEY)
GTEQ
END-EXEC.

102
ENDBR
 End browse operation

EXEC CICS ENDBR


FILE (‘EMPFILE’)
END-EXEC.

103
Temporary Storage
 COMMAREA (Communication Area)
 CWA (Common Work Area)
 TWA (Transaction Work Area)
 TSQ (Temporary Storage Queue)
 TDQ (Transient Data Queue)

104
Temporary Storage Continues...

 COMMAREA
 It can be used to transfer data from one program to another in a
transaction or from one transaction to another in an application.

 CWA
 There is only one CWA in a system. Any transaction in the system can
access this area, and hence the format and use of it must be agreed
upon by all transactions in the system.

105
Temporary Storage Continues...

 TWA
 The TWA exists only for the duration of a transaction. Hence it
can be used to for forwarding data among programs in a
transaction.

 TSQ
 It can be created and removed dynamically in a program.
 It can be read and written sequentially or randomly.
 Records can be added or modified.
 Can be kept in Main memory for faster access. In this case
recovery is not possible.

106
Temporary Storage Continues...

 If recovery is needed, TDQ must be used. This requires the TDQ to be


specified in DCT.

 All TSQ services are provided by TSP.

 A 1 to 8 character unique name should be used for each TSQ.

107
TSQ Commands (Write)
 WRITEQ TS
EXEC CICS WRITEQ TS
QUEUE (‘TRG4321A’)
FROM (TSQ-REC)
LENGTH (TSQ-LENGTH)
ITEM (TSQ-REC-NUM)
END-EXEC.

108
TSQ Commands (Read)
 READQ TS
EXEC CICS READQ TS
QUEUE (‘TRG4321A’)
INTO (TSQ-REC)
LENGTH (TSQ-LENGTH)
ITEM (TSQ-REC-NUM)
END-EXEC

109
TSQ Commands (delete)
 DELETEQ TS
EXEC CICS DELETEQ TS
QUEUE (‘TRG4321A’)
END-EXEC.

110
TDQ Command (Write)
 WRITEQ TD
EXEC CICS WRITEQ TD
QUEUE (‘XXXX’)
FROM (TDQ-REC)
LENGTH (TDQ-LENGTH)
RESP(WS-RESP)
END-EXEC.

111
Difference between TSQ and TDQ
 TDQ •TSQ
 TDQ is read destructive. • TSQ is not read destructive
• TSQ can be created dynamically.
 TDQ cannot be created
dynamically. • TSQ is temporary in nature (i.e. it
will be deleted when the program
finishes execution, unless it is made
 TDQ is not temporary in permanent by making a entry in the
nature. Temporary Storage Table).
 Can be intra / extra partitioned.
• Only intra-partitioned

 Can be used for input or output • Can be used for input / output
and not both

112
Thanks
Question ?

113

You might also like