Post on 07-Apr-2018
8/4/2019 Ch03_slides
1/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 1
Chapter 3
How to designa CICS program
8/4/2019 Ch03_slides
2/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 2
Objectives1. Explain why event-driven program design is appropriate for pseudo-conversational CICS programs.
2. Given specifications for a CICS program, create a list of each user
input event that can trigger execution of the program, identify the
various contexts the program must manage, and create a summaryof the programs response to each event.
3. Working from an event/response chart such as the one in figure 3-4,
create a program structure chart that indicates the major event-
processing modules and the major functional modules subordinate
to each event-processing module.
8/4/2019 Ch03_slides
3/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 3
The program overview for the customermaintenance programProgram CUSTMNT1: Customer maintenance
Trans-id MNT1
Overview Maintain customer information in the customer master file by allowing
the user to enter new customers, change existing customers, or delete
existing customers.
Input/output
specifications
CUSTMAS Customer master file
MNTMAP1 Customer maintenance key map
MNTMAP2 Customer maintenance data map
Processing
specifications
1.Control is transferred to this program via XCTL from the menu
program INVMENU with no communication area. The user can also
start the program by entering the trans-id MNT1. In either case, theprogram should respond by displaying the key map.
8/4/2019 Ch03_slides
4/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 4
The program overview for the customermaintenance program (continued)
Processingspecifications
2.On the key map, the user enters a customer number and selects aprocessing action. If the user selects Add, the customer number
entered must not exist in the file. For Change or Delete, the
customer number must exist in the file. If a valid combination isnt
entered, an error message should be displayed.
3.If the user enters a valid combination of action and customer
number, the program displays the data map. For an add operation,the user can then enter the customer information. For a change
operation, the user can change any of the existing information. For a
delete operation, all fields should be set to protected so the user
cant enter changes. To complete any of these operations, the user
must press the Enter key.
4.If the user presses PF3 from either map, return to the menu programINVMENU by issuing an XCTL command. If the user presses PF12
from the key map, return to the menu program. However, if the user
presses PF12 from the data map, redisplay the key map without
completing the current operation.
8/4/2019 Ch03_slides
5/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 5
The copy member for the customer master record(CUSTMAS)
01 CUSTOMER-MASTER-RECORD.
*
05 CM-CUSTOMER-NUMBER PIC X(6).
05 CM-FIRST-NAME PIC X(20).
05 CM-LAST-NAME PIC X(30).
05 CM-ADDRESS PIC X(30).
05 CM-CITY PIC X(20).
05 CM-STATE PIC X(2).
05 CM-ZIP-CODE PIC X(10).
*
8/4/2019 Ch03_slides
6/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 6
The screen layout for the key map
8/4/2019 Ch03_slides
7/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 7
The screen layout for the data map
8/4/2019 Ch03_slides
8/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 8
How to create an event/response chart
Identify the events that can cause the program to be started, and
identify in general terms how the program should respond to eachof those events.
Be sure to include a response to the user action that causes theprogram to be started for the first time. A program typically
responds to this event by displaying the first map and then
ending.
If the final step in a response is to return control to CICS, you canomit this step from the event/response chart and it will be
assumed.
Identify the contextof each event (if any), then add the contexts
to the event/response chart and expand the response processing.
If the response to an event causes a change in the context,indicate the new context in the event/response chart.
8/4/2019 Ch03_slides
9/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 9
A beginning event/response chart for thecustomer maintenance program
Event Response
Start the program Display the key map.
PF3 Transfer control to the menu program.
PF12 If the key map is displayed
transfer control to the menu program.
If the data map is displayedcancel the operation and display the key map.
Enter If the key map is displayed
prepare the data map according to the requested action and
display it.
If the data map is displayed
add, change, or delete the customer as appropriate.
Clear Redisplay the current map without any data.
PA1, PA2, or PA3 Ignore the key.
Any other key Display an appropriate error message.
8/4/2019 Ch03_slides
10/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 10
Event contexts for the customer maintenanceprogramContext Explanation
Get key The key map is displayed, awaiting input of a valid combination of
action code and customer number.
Add customer The data map is displayed in response to a request to add a customer.
Change customer The data map is displayed in response to a request to change a
customer.
Delete customer The data map is displayed in response to a request to delete a
customer.
8/4/2019 Ch03_slides
11/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 11
The final event/response chart for the customer
maintenance programEvent Context Response New context
Start the
program
n/a Display the key map. Get key
PF3 All Transfer control to the menu program. n/a
PF12 Get key Transfer control to the menu program. n/a
Add customer
Change customer
Delete customer
Cancel the operation and display the key
map.
Get key
Enter Get key Edit input data.
If valid
display data map
else
display an error message.
Add customer,
Change customer,
or Delete customer
Get key
8/4/2019 Ch03_slides
12/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 12
The final event/response chart for the customer
maintenance program (continued)Event Context Response New context
Enter Add customer Add the customer record.
If not duplicate record
display the key map with a
completion message
else display the key map with an error
message.
Get key
Get key
Change customer Change the customer record.
If record found
display the key map with a
completion message
else
display the key map with an errormessage.
Get key
Get key
8/4/2019 Ch03_slides
13/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 13
The final event/response chart for the customer
maintenance program (continued)Event Context Response New context
Enter Delete customer Delete the customer record.
If record found
display the key map with a
completion message
else
display the key map with an errormessage.
Get key
Get key
Clear Get key Redisplay the key map. Unchanged
Add, Change, or
Delete customer
Redisplay the data map with unprotected
data erased.
Unchanged
PA1, PA2,
or PA3
All Ignore the key. Unchanged
Any other
key
All Display an appropriate error message. Unchanged
8/4/2019 Ch03_slides
14/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 14
A general procedure for designing the first twolevels of a structure chart
1. Draw the top-level module and give it a name that represents theentire program.
2. Decide what event processing should be implemented as separatemodules, and draw a box subordinate to the top-level module for
each one.
8/4/2019 Ch03_slides
15/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 15
How to determine what modules should make up
the second level of a structure chart If the programs response to an event includes receiving data from
the terminal, processing it, and sending data back to the terminal,
create a separate module for the event.
If the programs response to an event doesnt include receiving
data from the terminal, consider creating a separate module only ifthe response requires more than a few COBOL statements to
implement.
If the COBOL statements for implementing the top-level modulerequire more than a page or two, consider creating additional
second-level modules to simplify the coding in the top-levelmodule.
8/4/2019 Ch03_slides
16/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 16
The first two levels of the structure chartfor the customer maintenance program
Process
customermaintenance
Process
changecustomer
Process
addcustomer
Process
keymap
Process
deletecustomer
8/4/2019 Ch03_slides
17/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 17
An alternative design for the customermaintenance program
Processkeymap
Processaddcustomer
Processchangecustomer
Processdeletecustomer
Processdatamap
Processcustomermaintenance
8/4/2019 Ch03_slides
18/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 18
A general procedure for designing one leg of astructure chart
1. Draw one subordinate module for each function that the controlmodule at the top of the leg needs to do.
2. Use the same thought process for the next level of modules. Ifany of them require more than one function, draw one
subordinate module for each function.
3. If necessary, continue this process until each of the lowest-levelmodules consists of just one function.
8/4/2019 Ch03_slides
19/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 19
Guidelines for designing the legs of a structurechart
Each module should represent one and only one function. The function of a called module must be logically contained in the
function of its calling module.
The code in each module should be manageable. Use a generalized send module for each map. Each module will
contain one or more SEND MAP commands with various options.
Include a separate module for each file I/O statement so thestatements are easy to locate and modify.
8/4/2019 Ch03_slides
20/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 20
The process-key-map leg of the customer
maintenance program
Processkeymap
Editkeydata
Senddatamap
Sendkeymap
Receivekeymap
Readcustomerrecord
8/4/2019 Ch03_slides
21/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 21
The final structure chart for the customer maintenanceprogram
Senddatamap
Sendkeymap
Receivekeymap
Editkeydata
Processaddcustomer
Writecustomerrecord
Receivedatamap
Sendkeymap
Sendkey
map
Rewritecustomer
record
Readcustomer
for update
Receivedata
map
Readcustomerfor update
Deletecustomerrecord
Sendkeymap
Processchangecustomer
Processdeletecustomer
Readcustomer
record
Process
customermaintenance
Processkeymap
Senddatamap
Sendkeymap
0000
1000 2000 3000 4000 1400 1500
1100 1200 1400 1500
1300
2100 2300 1500
2100 3100 3200 1500
3100 4100 1500
8/4/2019 Ch03_slides
22/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 22
How to identify common modules
To identify a common module (a module that appears more thanonce in a structure chart), shade its upper right corner.
If a common module has subordinate modules, you need to includethem only once on the chart.
How to identify linked or called programs To identify a linked program (a program thats executed using the
LINK command), add a module to the structure chart. Include a
stripe at the top of the module that gives the program name.
Use the same technique to identify a called program (a programthats executed using the COBOL Call statement).
8/4/2019 Ch03_slides
23/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 23
How to number the modules in a structure chart
Use 000 or 0000 for the top-level module.
Number the modules in the second level from left to right leavinglarge enough gaps for subordinate modules.
After the first two levels, number the modules down each leg inappropriate increments.
When you code the COBOL paragraph for each module later on,the paragraph name will be the module number followed by the
module name.
8/4/2019 Ch03_slides
24/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 24
How to create a structure listing A structure listing is an outline that uses indentation to show the
levels of the modules. The letter C in parentheses can be used to
identify common modules.
When youre designing a program, use the outline feature of anymodern word processor to prepare a structure listing. This feature
makes it easy to analyze the structure and reorganize the listing.
When a program is finished, you can use a structure listingprogram to generate a structure listing from the COBOL code for
the finished program.
8/4/2019 Ch03_slides
25/25
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 25
A structure listing for the customer maintenanceprogram0000-PROCESS-CUSTOMER-MAINT
1000-PROCESS-KEY-MAP
1100-RECEIVE-KEY-MAP
1200-EDIT-KEY-MAP
1300-READ-CUSTOMER-RECORD
1400-SEND-DATA-MAP (C)
1500-SEND-KEY-MAP (C)
2000-PROCESS-ADD-CUSTOMER
2100-RECEIVE-DATA-MAP (C)
2300-WRITE-CUSTOMER-RECORD
1500-SEND-KEY-MAP (C)
3000-PROCESS-CHANGE-CUSTOMER
2100-RECEIVE-DATA-MAP (C)
3100-READ-CUSTOMER-FOR-UPDATE (C)
3200-REWRITE-CUSTOMER-RECORD
1500-SEND-KEY-MAP (C)
4000-PROCESS-DELETE-CUSTOMER
3100-READ-CUSTOMER-FOR-UPDATE (C)
4100-DELETE-CUSTOMER-RECORD
1500-SEND-KEY-MAP (C)