Sie sind auf Seite 1von 25

CICS, C3 2001, Mike Murach & Associates, Inc.

Slide 1
Chapter 3
How to design
a CICS program
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 2
Objectives
1. 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 summary
of 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.
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 3
The program overview for the customer
maintenance program
Program 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, the
program should respond by displaying the key map.
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 4
The program overview for the customer
maintenance program (continued)
Processing
specifications
2. On the key map, the user enters a customer number and selects a
processing 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 program
INVMENU 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.
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).
*
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 6
The screen layout for the key map
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 7
The screen layout for the data map
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 each
of those events.
Be sure to include a response to the user action that causes the
program 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 can
omit this step from the event/response chart and it will be
assumed.
Identify the context of 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.
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 9
A beginning event/response chart for the
customer 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 displayed
cancel 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.
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 10
Event contexts for the customer maintenance
program
Context 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.
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 11
The final event/response chart for the customer
maintenance program
Event 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
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 error
message.
Get key
Get key
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 error
message.
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
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 14
A general procedure for designing the first two
levels of a structure chart
1. Draw the top-level module and give it a name that represents the
entire program.
2. Decide what event processing should be implemented as separate
modules, and draw a box subordinate to the top-level module for
each one.
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 if
the response requires more than a few COBOL statements to
implement.
If the COBOL statements for implementing the top-level module
require more than a page or two, consider creating additional
second-level modules to simplify the coding in the top-level
module.
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 16
The first two levels of the structure chart
for the customer maintenance program
Process
customer
maintenance
Process
change
customer
Process
add
customer
Process
key
map
Process
delete
customer
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 17
An alternative design for the customer
maintenance program
Process
key
map
Process
add
customer
Process
change
customer
Process
delete
customer
Process
data
map
Process
customer
maintenance
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 18
A general procedure for designing one leg of a
structure chart
1. Draw one subordinate module for each function that the control
module at the top of the leg needs to do.
2. Use the same thought process for the next level of modules. If
any 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-level
modules consists of just one function.
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 19
Guidelines for designing the legs of a structure
chart
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 the
statements are easy to locate and modify.
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 20
The process-key-map leg of the customer
maintenance program
Process
key
map
Edit
key
data
Send
data
map
Send
key
map
Receive
key
map
Read
customer
record
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 21
The final structure chart for the customer maintenance
program
Send
data
map
Send
key
map
Receive
key
map
Edit
key
data
Process
add
customer
Write
customer
record
Receive
data
map
Send
key
map
Send
key
map
Rewrite
customer
record
Read
customer
for update
Receive
data
map
Read
customer
for update
Delete
customer
record
Send
key
map
Process
change
customer
Process
delete
customer
Read
customer
record
Process
customer
maintenance
Process
key
map
Send
data
map
Send
key
map
0000
1000 2000 3000 4000 1400 1500
1100 1200 1400 1500
1300
2100 2300 1500
2100 3100 3200 1500
3100 4100 1500
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 22
How to identify common modules
To identify a common module (a module that appears more than
once in a structure chart), shade its upper right corner.
If a common module has subordinate modules, you need to include
them 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 program
thats executed using the COBOL Call statement).
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 leaving
large enough gaps for subordinate modules.
After the first two levels, number the modules down each leg in
appropriate 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.
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 any
modern 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 listing
program to generate a structure listing from the COBOL code for
the finished program.
CICS, C3 2001, Mike Murach & Associates, Inc. Slide 25
A structure listing for the customer maintenance
program
0000-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)

Das könnte Ihnen auch gefallen