Sample application programs. IBM iSeries
Werbung
Werbung
Figure 7. Flow of control between COBOL programs and run units in CICS/400
Sample application programs
Disclaimer:
Chapter 3. Preparing and writing CICS applications in COBOL
27
The ACCT sample application contains programming source code for your consideration. This sample has not been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, performance or function of the programs. All programs herein are provided to you “as is”. IBM EXPRESSLY DISCLAIMS ALL
WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
A set of sample application programs, called ACCT, is provided as an example of how CICS commands can be used in a program written in the COBOL language.
All ACCT objects are in the QCICSSAMP library.
If the COBOL compiler is installed on your system, you can modify the ACCT
sample programs. Figure 8 is a screen showing the members of file QLBLSRC that
contain the source for the ACCT application programs. Note that the TYPE of the members containing CICS code is CICSCBL.
Library . . . . Position
Type options, press Enter.
Account file record format
ACCTSET CICS BMS Source
Index file record format
Bottom
Parameters or command
===>
Figure 8. ACCT sample screen: Working with the ACCT samples
The BMS maps used by the ACCT sample are contained in a single mapset. The source for this mapset is in member ACCTSET of file QMAPSRC. The TYPE of the source members is CICSMAP.
Data declarations used by the ACCT sample
v
The data for each account for the ACCT sample is stored in a physical file,
ACCTFIL, in the QCICSSAMP library. The record format for this file is declared to a program by copying the copybook ACCTFIL into the working storage section. The source for the copybook is in member ACCTFIL of file QDDSSRC. v
The ACCT sample uses a physical file, ACCTIX, as an index of the account data by customer name. The copybook for the record format is called ACIXREC and the source is in ACCTIX; both ACIXREC and ACCTIX are members of file
QDDSSRC. Note that logical files can be used to provide alternative indexes into a physical file.
28
CICS for iSeries Application Programming Guide V5
Defining resources for the ACCT sample
A sample program, CRTSAMP, is provided to simplify resource definition for the
ACCT sample. This program creates a CICS group, called ACCT, and other necessary resources for a control region. You specify the name of the control region and the library in which the resources are created as parameters for the program.
When the CICS resources have been defined, the control region is started.
To run the CRTSAMP program, enter:
CALL CRTSAMP library-name sys-id where sys-id is the name of the sample control region to be created and library-name is the library that the CICS resources are stored in. These are required parameters. The source for CRTSAMP is in member CRTSAMP of file
QCLSRC in library QCICSSAMP.
Running the ACCT sample
1. Use CRTSAMP to create a control region and the CICS group, ACCT, that defines all the CICS resources needed to run the ACCT sample.
2. Start a CICS user shell for the control region created in step 1.
3. When the user shell has started, enter the transaction identifier ACCT to start the
ACCT sample. The BMS map shown in Figure 9 is displayed at the terminal.
ACCOUNT FILE: MENU
____________ FIRST NAME: _______
FOR INDIVIDUAL RECORDS, ENTER:
MAY BE PARTIAL.
REQUEST TYPE: _ ONLY FOR PRINT
REQUESTS.
D = DISPLAY A = ADD X = DELETE
P = PRINT M = MODIFY
Figure 9. ACCT sample screen: Menu
Note:
The input fields in Figure 9 are marked with underscores, but these do not
appear on the actual screen.
If you press the
CLEAR key, the application ends and control passes back to CICS.
To request a function, fill in the appropriate fields on the map and press
ENTER
. If the request is invalid, the menu map is redisplayed, with a message that describes the error.
Displaying an account record
To display an account record, starting from the ACCT menu display, enter ‘D’ in the
REQUEST TYPE field and the account number in the
ACCOUNT field and press
ENTER
. The account details are displayed. Figure 10 on page 30 is an example of
what the screen might look like following a request to display an account record.
Chapter 3. Preparing and writing CICS applications in COBOL
29
ACCOUNT FILE: RECORD DISPLAY
ADDRESS: 1, The House
OTHERS WHO MAY CHARGE:
NO. CARDS ISSUED: 1
CARD CODE: N APPROVED BY: ISW
CHARGE 1000.00
SPECIAL CODES: L
0.00
0.00
0.00 0.00
PRESS ’CLEAR’ OR ’ENTER’ WHEN FINISHED
Figure 10. ACCT sample screen: Displaying a record
Adding an account record
To add an account record, starting from the ACCT menu display, enter ‘A’ in the
REQUEST TYPE field and the account number in the
ACCOUNT field and press
ENTER
. If an account already exists with the account number specified, the application
returns to the menu with a message that describes the error. Figure 11 on page 31
shows the map displayed on the screen, with details for a new account already entered. The ACCOUNT NUMBER field is already set to the value entered on the menu.
To continue with the request, enter the account details into the map and press
ENTER ; otherwise press CLEAR to cancel the request. If any of the details added are invalid, the map is redisplayed with the current data, and the field containing the invalid data is highlighted with asterisks.
Note:
The
CARD CODE field indicates whether the card is lost (
L
), stolen (
S
), new (
N
), or reissued (
R
). No checking is done on the
REASON and
SPECIAL CODES fields.
30
CICS for iSeries Application Programming Guide V5
ACCOUNT FILE: NEW RECORD
OTHERS WHO MAY CHARGE:
NO. CARDS ISSUED: 1
CARD CODE: N APPROVED BY: ISW
FILL IN AND PRESS ’ENTER,’ OR ’CLEAR’ TO CANCEL
SPECIAL CODES: L
Figure 11. ACCT sample screen: Adding a new record
Searching by account holder’s name
You can search for account information by name, instead of by account number. To do this, you enter a name in the
SURNAME field and, optionally, in the
FIRST NAME field on the menu map, and press
ENTER
. If the name entered is not valid (not alphabetic), or no match can be found, the menu map is redisplayed with a
message. Figure 12 shows an example of the display returned when you search for
a name.
ACCOUNT FILE: MENU
MAY BE PARTIAL.
FOR INDIVIDUAL RECORDS, ENTER:
ONLY FOR PRINT
REQUESTS.
D = DISPLAY
P = PRINT
A = ADD
M = MODIFY
X = DELETE
1, The House 1000.00
Figure 12. ACCT sample screen: Searching by account holder’s name
Modifying an account record
To modify an account record, starting from the ACCT menu display, enter ‘M’ in the
REQUEST TYPE field and the account number in the
ACCOUNT field and press
ENTER
. If the account does not exist or is already in use, the application returns to the menu display with a message.
Chapter 3. Preparing and writing CICS applications in COBOL
31
Figure 13 shows an update map for an example account record Changes are made
to the record by typing over the current values. If an invalid change is made, the map is redisplayed and the field containing the invalid data is highlighted with asterisks.
ACCOUNT FILE: RECORD CHANGE
ADDRESS: 1, The House
OTHERS WHO MAY CHARGE:
NO. CARDS ISSUED: 1
CARD CODE: N APPROVED BY: ISW
CHARGE 1000.00
SPECIAL CODES: L
0.00
0.00
0.00 0.00
MAKE CHANGES AND ’ENTER’ OR ’CLEAR’ TO CANCEL
Figure 13. ACCT sample screen: Modifying a record
When you have entered your request, the record is updated and you are returned to the menu with a message confirming that the operation was successful.
Deleting an account record
To delete an account record, starting from the ACCT menu display, enter ‘X’ in the
REQUEST TYPE field and the account number to be deleted in the
ACCOUNT field and press
ENTER
. If the account does not exist or is already in use, the application
returns to the menu with a message informing you of the error. Figure 14 on page
33 is an account deletion map for an example account record.
32
CICS for iSeries Application Programming Guide V5
ACCOUNT FILE: DELETION
ADDRESS: 1, The House
OTHERS WHO MAY CHARGE:
NO. CARDS ISSUED: 1
CARD CODE: N APPROVED BY: ISW
CHARGE 1000.00
SPECIAL CODES: L
0.00
0.00
0.00 0.00
ENTER ’Y’ TO CONFIRM OR ’CLEAR’ TO CANCEL
Figure 14. ACCT sample screen: Deleting a record
You are asked to confirm the deletion request. When you have done so, the record is deleted and you are returned to the menu with a message confirming that the operation was successful.
Printing an account record
To do this, starting from the ACCT menu display, enter ‘P’ in the REQUEST TYPE field and the account number to be printed in the ACCOUNT field and press ENTER . If the account does not exist, or is already in use, the application returns to the menu with a message informing you of the error. When you have entered your request, the record is sent to the printer and you see a message confirming that the operation was successful.
To print the change log, enter the transaction identifier
ACLG from a blank entry screen in CICS. The change log is sent to the device specified to CICS as
L86O in the CICS terminal control table and you see a message confirming that the operation was successful.
Chapter 3. Preparing and writing CICS applications in COBOL
33
34
CICS for iSeries Application Programming Guide V5
Herunterladen
Werbung