Figure 131 shows the associated DDS for a basic inquiry program that uses the ILE COBOL TRANSACTION file.
....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
A* CUSTOMER MASTER INQUIRY FILE ** CUSMINQ
A*
A REF(CUSMSTP)
A R CUSPMT TEXT('CUSTOMER PROMPT')
A CA01(15 'END OF PROGRAM')
A 1 3'CUSTOMER MASTER INQUIRY'
A 3 3'CUSTOMER NUMBER'
A CUST R I 3 20
A 99 ERRMSG('CUSTOMER NUMBER NOT FOUND +
A PRESS RESET, THEN ENTER A VALID NU+
A MBER' 99)
A 98 ERRMSG('EOF CONDITION IN READ, +
A PROGRAM ENDED' 98)
A 5 3'USE F1 TO END PROGRAM, USE ENTE+
A R TO RETURN TO PROMPT SCREEN'
A R CUSFLDS TEXT('CUSTOMER DISPLAY')
A CA01(15 'END OF PROGRAM')
A OVERLAY
A 8 3'NAME'
A NAME R 8 11
A 9 3'ADDRESS'
A ADDR R 9 11
A 10 3'CITY'
A CITY R 10 11
A 11 3'STATE'
A STATE R 11 11
A 11 21'ZIP CODE'
A ZIP R 11 31
A 12 3'A/R BALANCE'
A ARBAL R 12 17The data description specifications (DDS) for the display device file (CUSMINQ) to be used by this program describe two record formats: CUSPMT and CUSFLDS.
The CUSPMT record format contains the constant 'Customer Master Inquiry', which identifies the display. It also contains the prompt 'Customer Number' and the input field (CUST) where you enter the customer number. Five underscores appear under the input field CUST on the display where you are to enter the customer number. The error message:
Customer number not found
is also included in this record format. This message is displayed if indicator 99 is set to ON by the program. In addition, this record format defines a function key that you can press to end the program. When you press function key F1, indicator 15 is set to ON in the ILE COBOL program. This indicator is then used to end the program.
The CUSFLDS record format contains the following constants:
These constants identify the fields to be written out from the program. This record format also describes the fields that correspond to these constants. All of these fields are described as output fields (blank in position 38) because they are filled in by the program; you do not enter any data into these fields. To enter another customer number, press Enter in response to this record. Notice that the CUSFLDS record overlays the CUSPMT record. Therefore, when the CUSFLDS record is written to the display, the CUSPMT record remains on the display.
In addition to describing the constants, fields, and attributes for the display, the record formats also define the line numbers and horizontal positions where the constants and fields are to be displayed.
....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....
A* THIS IS THE CUSTOMER MASTER FILE ** CUSMSTP
A
A
A UNIQUE
A R CUSMST TEXT('CUSTOMER MASTER RECORD')
A CUST 5 TEXT('CUSTOMER NUMBER')
A NAME 25 TEXT('CUSTOMER NAME')
A ADDR 20 TEXT('CUSTOMER ADDRESS')
A CITY 20 TEXT('CUSTOMER CITY')
A STATE 2 TEXT('STATE')
A ZIP 5 00 TEXT('ZIP CODE')
A SRHCOD 6 TEXT('CUSTOMER NUMBER SEARCH CODE')
A CUSTYP 1 00 TEXT('CUSTOMER TYPE 1=GOV 2=SCH +
A 3=BUS 4=PVT 5=OT')
A ARBAL 8 02 TEXT('ACCOUNTS REC. BALANCE')
A ORDBAL 8 02 TEXT('A/R AMT. IN ORDER FILE')
A LSTAMT 8 02 TEXT('LAST AMT. PAID IN A/R')
A LSTDAT 6 00 TEXT('LAST DATE PAID IN A/R')
A CRDLMT 8 02 TEXT('CUSTOMER CREDIT LIMIT')
A SLSYR 10 02 TEXT('CUSTOMER SALES THIS YEAR')
A SLSLYR 10 02 TEXT('CUSTOMER SALES LAST YEAR')
K CUSTThe data description specifications (DDS) for the database file that is used by this program describe one record format: CUSMST. Each field in the record format is described, and the CUST field is identified as the key field for the record format.
5722WDS V5R4M0 060210 LN IBM ILE COBOL CBLGUIDE/INQUIRY ISERIES1 06/02/15 14:57:34 Page 2
S o u r c e
STMT PL SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE
1 000100 IDENTIFICATION DIVISION.
2 000200 PROGRAM-ID. INQUIRY.
000300* SAMPLE TRANSACTION INQUIRY PROGRAM USING 1 DISPLAY DEVICE
000400
3 000500 ENVIRONMENT DIVISION.
4 000600 CONFIGURATION SECTION.
5 000700 SOURCE-COMPUTER. IBM-ISERIES.
6 000800 OBJECT-COMPUTER. IBM-ISERIES.
7 000900 INPUT-OUTPUT SECTION.
8 001000 FILE-CONTROL.
9 001100 SELECT CUST-DISPLAY
10 001200 ASSIGN TO WORKSTATION-CUSMINQ
11 001300 ORGANIZATION IS TRANSACTION
12 001400 CONTROL-AREA IS WS-CONTROL.
13 001500 SELECT CUST-MASTER
14 001600 ASSIGN TO DATABASE-CUSMSTP
15 001700 ORGANIZATION IS INDEXED
16 001800 ACCESS IS RANDOM
17 001900 RECORD KEY IS CUST OF CUSMST
18 002000 FILE STATUS IS CM-STATUS.
002100
19 002200 DATA DIVISION.
20 002300 FILE SECTION.
21 002400 FD CUST-DISPLAY.
22 002500 01 DISP-REC.
002600 COPY DDS-ALL-FORMATS OF CUSMINQ.
23 +000001 05 CUSMINQ-RECORD PIC X(80). <-ALL-FMTS
+000002* INPUT FORMAT:CUSPMT FROM FILE CUSMINQ OF LIBRARY CBLGUIDE <-ALL-FMTS
+000003* CUSTOMER PROMPT <-ALL-FMTS
24 +000004 05 CUSPMT-I REDEFINES CUSMINQ-RECORD. <-ALL-FMTS
25 +000005 06 CUSPMT-I-INDIC. <-ALL-FMTS
26 +000006 07 IN15 PIC 1 INDIC 15. <-ALL-FMTS
+000007* END OF PROGRAM <-ALL-FMTS
27 +000008 07 IN99 PIC 1 INDIC 99. <-ALL-FMTS
+000009* CUSTOMER NUMBER NOT FOUND PRESS RESET, THEN ENT <-ALL-FMTS
28 +000010 07 IN98 PIC 1 INDIC 98. <-ALL-FMTS
+000011* EOF CONDITION IN READ, PROGRAM ENDED <-ALL-FMTS
29 +000012 06 CUST PIC X(5). <-ALL-FMTS
+000013* CUSTOMER NUMBER <-ALL-FMTS
+000014* OUTPUT FORMAT:CUSPMT FROM FILE CUSMINQ OF LIBRARY CBLGUIDE <-ALL-FMTS
+000015* CUSTOMER PROMPT <-ALL-FMTS
30 +000016 05 CUSPMT-O REDEFINES CUSMINQ-RECORD. <-ALL-FMTS
31 +000017 06 CUSPMT-O-INDIC. <-ALL-FMTS
32 +000018 07 IN99 PIC 1 INDIC 99. <-ALL-FMTS
+000019* CUSTOMER NUMBER NOT FOUND PRESS RESET, THEN ENT <-ALL-FMTS
33 +000020 07 IN98 PIC 1 INDIC 98. <-ALL-FMTS
+000021* EOF CONDITION IN READ, PROGRAM ENDED <-ALL-FMTS
+000022* INPUT FORMAT:CUSFLDS FROM FILE CUSMINQ OF LIBRARY CBLGUIDE <-ALL-FMTS
+000023* CUSTOMER DISPLAY <-ALL-FMTS
34 +000024 05 CUSFLDS-I REDEFINES CUSMINQ-RECORD. <-ALL-FMTS
35 +000025 06 CUSFLDS-I-INDIC. <-ALL-FMTS
36 +000026 07 IN15 PIC 1 INDIC 15. <-ALL-FMTS
+000027* END OF PROGRAM <-ALL-FMTS
5722WDS V5R4M0 060210 LN IBM ILE COBOL CBLGUIDE/INQUIRY ISERIES1 06/02/15 14:57:34 Page 3
STMT PL SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE
+000028* OUTPUT FORMAT:CUSFLDS FROM FILE CUSMINQ OF LIBRARY CBLGUIDE <-ALL-FMTS
+000029* CUSTOMER DISPLAY <-ALL-FMTS
37 +000030 05 CUSFLDS-O REDEFINES CUSMINQ-RECORD. <-ALL-FMTS
38 +000031 06 NAME PIC X(25). <-ALL-FMTS
+000032* CUSTOMER NAME <-ALL-FMTS
39 +000033 06 ADDR PIC X(20). <-ALL-FMTS
+000034* CUSTOMER ADDRESS <-ALL-FMTS
40 +000035 06 CITY PIC X(20). <-ALL-FMTS
+000036* CUSTOMER CITY <-ALL-FMTS
41 +000037 06 STATE PIC X(2). <-ALL-FMTS
+000038* STATE <-ALL-FMTS
42 +000039 06 ZIP PIC S9(5). <-ALL-FMTS
+000040* ZIP CODE <-ALL-FMTS
43 +000041 06 ARBAL PIC S9(6)V9(2). <-ALL-FMTS
+000042* ACCOUNTS REC. BALANCE <-ALL-FMTS
002700
44 002800 FD CUST-MASTER.
45 002900 01 CUST-REC.
003000 COPY DDS-CUSMST OF CUSMSTP.
+000001* I-O FORMAT:CUSMST FROM FILE CUSMSTP OF LIBRARY CBLGUIDE CUSMST
+000002* CUSTOMER MASTER RECORD CUSMST
+000003* USER SUPPLIED KEY BY RECORD KEY CLAUSE CUSMST
46 +000004 05 CUSMST. CUSMST
47 +000005 06 CUST PIC X(5). CUSMST
+000006* CUSTOMER NUMBER CUSMST
48 +000007 06 NAME PIC X(25). CUSMST
+000008* CUSTOMER NAME CUSMST
49 +000009 06 ADDR PIC X(20). CUSMST
+000010* CUSTOMER ADDRESS CUSMST
50 +000011 06 CITY PIC X(20). CUSMST
+000012* CUSTOMER CITY CUSMST
51 +000013 06 STATE PIC X(2). CUSMST
+000014* STATE CUSMST
52 +000015 06 ZIP PIC S9(5) COMP-3. CUSMST
+000016* ZIP CODE CUSMST
53 +000017 06 SRHCOD PIC X(6). CUSMST
+000018* CUSTOMER NUMBER SEARCH CODE CUSMST
54 +000019 06 CUSTYP PIC S9(1) COMP-3. CUSMST
+000020* CUSTOMER TYPE 1=GOV 2=SCH 3=BUS 4=PVT 5=OT CUSMST
55 +000021 06 ARBAL PIC S9(6)V9(2) COMP-3. CUSMST
+000022* ACCOUNTS REC. BALANCE CUSMST
56 +000023 06 ORDBAL PIC S9(6)V9(2) COMP-3. CUSMST
+000024* A/R AMT. IN ORDER FILE CUSMST
57 +000025 06 LSTAMT PIC S9(6)V9(2) COMP-3. CUSMST
+000026* LAST AMT. PAID IN A/R CUSMST
58 +000027 06 LSTDAT PIC S9(6) COMP-3. CUSMST
+000028* LAST DATE PAID IN A/R CUSMST
59 +000029 06 CRDLMT PIC S9(6)V9(2) COMP-3. CUSMST
+000030* CUSTOMER CREDIT LIMIT CUSMST
60 +000031 06 SLSYR PIC S9(8)V9(2) COMP-3. CUSMST
+000032* CUSTOMER SALES THIS YEAR CUSMST
61 +000033 06 SLSLYR PIC S9(8)V9(2) COMP-3. CUSMST
+000034* CUSTOMER SALES LAST YEAR CUSMST
003100
62 003200 WORKING-STORAGE SECTION.
5722WDS V5R4M0 060210 LN IBM ILE COBOL CBLGUIDE/INQUIRY ISERIES1 06/02/15 14:57:34 Page 4 STMT PL SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 63 003300 01 ONE PIC 1 VALUE B"1". 64 003400 01 CM-STATUS PIC X(2). 65 003500 01 WS-CONTROL. 66 003600 02 WS-IND PIC X(2). 67 003700 02 WS-FORMAT PIC X(10). 003800 68 003900 PROCEDURE DIVISION. 69 004000 DECLARATIVES. 004100 DISPLAY-ERR-SECTION SECTION. 004200 USE AFTER STANDARD EXCEPTION PROCEDURE ON CUST-DISPLAY. 004300 DISPLAY-ERR-PARAGRAPH. 70 004400 MOVE ONE TO IN98 OF CUSPMT-O 71 004500 WRITE DISP-REC FORMAT IS "CUSPMT" 004600 END-WRITE 72 004700 CLOSE CUST-MASTER 004800 CUST-DISPLAY. 73 004900 STOP RUN. 005000 END DECLARATIVES. 005100 005200 MAIN-PROGRAM SECTION. 005300 MAINLINE. 74 005400 OPEN INPUT CUST-MASTER 005500 I-O CUST-DISPLAY. 005600 75 005700 MOVE ZERO TO IN99 OF CUSPMT-O 76 005800 WRITE DISP-REC FORMAT IS "CUSPMT" 1 005900 END-WRITE 77 006000 READ CUST-DISPLAY RECORD 006100 END-READ 006200 78 006300 PERFORM UNTIL IN15 OF CUSPMT-I IS EQUAL TO ONE 006400 79 006500 MOVE CUST OF CUSPMT-I TO CUST OF CUSMST 80 006600 READ CUST-MASTER RECORD 2 006700 INVALID KEY 3 81 006800 MOVE ONE TO IN99 OF CUSPMT-O 82 006900 WRITE DISP-REC FORMAT IS "CUSPMT" 007000 END-WRITE 83 007100 READ CUST-DISPLAY RECORD 007200 END-READ 007300 NOT INVALID KEY 84 007400 MOVE CORRESPONDING CUSMST TO CUSFLDS-O *** CORRESPONDING items for statement 84: *** NAME *** ADDR *** CITY *** STATE *** ZIP *** ARBAL *** End of CORRESPONDING items for statement 84 85 007500 WRITE DISP-REC FORMAT IS "CUSFLDS" 007600 END-WRITE 86 007700 READ CUST-DISPLAY RECORD 007800 END-READ 87 007900 IF IN15 OF CUSPMT-I IS NOT EQUAL TO ONE 88 008000 MOVE ZERO TO IN99 OF CUSPMT-O 89 008100 WRITE DISP-REC FORMAT IS "CUSPMT" 008200 END-WRITE 90 008300 READ CUST-DISPLAY RECORD 008400 END-READ 008500 END-IF 008600 END-READ 008700 008800 END-PERFORM 008900 91 009000 CLOSE CUST-MASTER 009100 CUST-DISPLAY. 92 009200 GOBACK. * * * * * E N D O F S O U R C E * * * * *
The complete source listing for this program example is shown here. In particular, note the FILE-CONTROL and FD entries and the data structures generated by the Format 2 COPY statements.
The WRITE operation at 1 writes the CUSPMT format to the display. This record prompts you to enter a customer number. If you enter a customer number and press Enter, the next READ operation then reads the record back into the program.
The READ operation at 2 uses the customer number (CUST) field to retrieve the corresponding CUSMST record from the CUSMSTP file. If no record is found in the CUSMSTP file, the INVALID KEY imperative statements at 3 are performed. Indicator 99 is set on and the message:
Customer number not found
is displayed when the format is written. The message is conditioned by indicator 99 in the DDS for the file. When you receive this message, the keyboard locks. You must press the Reset key in response to this message to unlock the keyboard. You can then enter another customer number.
If the READ operation retrieves a record from the CUSMSTP file, the WRITE operation writes the CUSFLDS record to the display workstation. This record contains the customer's name, address, and accounts receivable balance.
You then press Enter, and the program branches back to the beginning. You can enter another customer number or end the program. To end the program, press F1, which sets on indicator 15 in the program.
When indicator 15 is on, the program closes all files and processes the GOBACK statement. The program then returns control to the individual who called the ILE COBOL program.
This is the initial display written by the WRITE operation at 1 :
Customer Master Inquiry
Customer Number ________
Use F3 to end program, use enter key to return to prompt screen
This display appears if a record is found in the CUSMSTP file for the customer number entered in response to the first display:
Customer Master Inquiry
Customer Number 1000
Use F3 to end program, use enter key to return to prompt screen
Name EXAMPLE WHOLESALERS LTD.
Address ANYWHERE STREET
City ACITY
State IL Zipcode 12345
A/R balance 137.02
This display appears if the CUSMSTP file does not contain a record for the customer number entered in response to the first display:
Customer Master Inquiry
Customer Number
Use F3 to end program, use enter key to return to prompt screen
Customer number not found, press reset, then enter valid number
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.