ILE COBOL Programmer's Guide

Using Subfiles for a Display File

To use a subfile for a display file in an ILE COBOL program, you must specify the SUBFILE phrase with the input/output operation. Valid subfile operations are:

Subfiles can be processed sequentially with the READ SUBFILE NEXT MODIFIED statement, or processed randomly by specifying a relative key value. A relative key is an unsigned number that can be used directly by the system to locate a record in a file.

The TRANSACTION file must be an externally described file. In ILE COBOL, access to the subfile is done with a relative record number, except when READ SUBFILE NEXT MODIFIED is used. If the SUBFILE phrases are used with a TRANSACTION file, the SELECT statement in the Environment Division must state that ACCESS MODE IS DYNAMIC and must specify a RELATIVE KEY.

If more than one display device is acquired by a display file, there is a separate subfile for each individual display device. If a subfile has been created for a particular display device acquired by a TRANSACTION file, all input operations that refer to a record format for the subfile are performed against the subfile belonging to that device. Any operations that reference a record format name that is not designated as a subfile are processed as an input/output operation directly to the display device.

Some typical uses of subfiles are summarized in Table 27.

Table 27. Uses of Subfiles

Use Meaning
Display Only The workstation user reviews the display.
Display With Selection The user requests more information about one of the items on display.
Modification The user modifies one or more of the records.
Input Only (with no validity checking) A subfile is used for a data-entry function.
Input Only (with validity checking) A subfile is used for a data-entry function, and the records are checked as well.
Combination of Tasks A subfile can be used as a display with modification.

Figure 141. Data Description Specifications for a Subfile Record Format


 ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....
      A* THIS IS THE DISPLAY DEVICE FILE FOR PAYUPDT ** PAYUPDTD
      A* ACCOUNTS RECEIVABLE INTERACTIVE PAYMENT UPDATE
      A*
      A
      A          R SUBFILE1                  SFL (1)
      A                                      TEXT('SUBFILE FOR CUSTOMER PAYMENT'
      A*
      A            ACPPMT         4A  I  5  4TEXT('ACCEPT PAYMENT')
      A                                 (2)  VALUES('*YES' '*NO') (3)
      A  51                                  DSPATR(RI MDT)
      A N51                                  DSPATR(ND PR)
      A*
      A            CUST           5   B  5 15TEXT('CUSTOMER NUMBER')
      A  52                         (4)      DSPATR(RI)
      A  53                                  DSPATR(ND)
      A  54                                  DSPATR(PR)
      A*
      A            AMPAID         8 02B  5 24TEXT('AMOUNT PAID')
      A                                      CHECK(FE) (5)
      A                                      AUTO(RAB) (6)
      A                                      CMP(GT 0) (7)
      A  52                                  DSPATR(RI)
      A  53                                  DSPATR(ND)
      A  54                                  DSPATR(PR)
      A*
      A            ECPMSG        31A  O  5 37TEXT('EXCEPTION MESSAGE')
      A  52                                  DSPATR(RI)
      A  53                                  DSPATR(ND)
      A  54                                  DSPATR(BL)
      A*
      A            OVRPMT         8Y 2O  5 70TEXT('OVERPAYMENT')
      A                                      EDTCDE(1) (8)
      A  55                                  DSPATR(BL) (9)
      A N56                                  DSPATR(ND)
      A*
      A            STSCDE         1A  H      TEXT('STATUS CODE')
      A          R CONTROL1                  TEXT('SUBFILE CONTROL')
      A                                      SFLCTL(SUBFILE1) (10)
      A                                      SFLSIZ(17) (11)
      A                                      SFLPAG(17) (12)
      A  61                                  SFLCLR (13)
      A  62                                  SFLDSP (14)
      A  62                                  SFLDSPCTL (15)
      A                                      OVERLAY
      A                                      LOCK (16)
      A*
      A                                      HELP(99 'HELP KEY') (17)
      A                                      CA12(98 'END PAYMENT UPDATE')
      A                                      CA11(97 'IGNORE INPUT')
      A*                                     (18)
      A  99                                  SFLMSG(' F11 - IGNORE INVALID INPUT+
      A                                                      F12 - END PAYMENT +
      A                                      UPDATE')
      A*
      A                                  1  2'CUSTOMER PAYMENT UPDATE PROMPT'
      A                                  1 65'DATE'
      A                                  1 71DATE EDTCDE(Y)
      A  63                              3  2'ACCEPT'
      A  63                              4  2'PAYMENT'
      A                                  3 14'CUSTOMER'
      A                                  3 26'PAYMENT'
      A  64                              3 37'EXCEPTION MESSAGE'
      A*
      A          R MESSAGE1                  TEXT('MESSAGE RECORD')
      A                                      OVERLAY
      A                                      LOCK
      A*
      A  71                             24  2' ACCEPT PAYMENT VALUES: (*NO
*YES)
DSPATR(RI)

The data description specifications (DDS) for a subfile record format describe the records in the subfile:

(1)
The SFL keyword identifies the record format as a subfile.

(2)
The line and position entries define the location of the fields on the display.

(3)
The VALUES keyword specifies that the user can only specify *YES or *NO as values for the ACPPMT field.

(4)
The usage entries define whether the named field is to be an output (O), input (I), output/input (B), or hidden (H) field.

(5)
The entry CHECK(FE) specifies that the user cannot skip to the next input field without pressing one of the field exit keys.

(6)
The entry AUTO(RAB) specifies that data entered into the field AMPAID is to be automatically right-justified, and the leading characters are to be filled with blanks.

(7)
The entry CMP(GT 0) specifies that the data entered for the field AMPAID is to be compared to zero to ensure that the value is greater than zero.

(8)
The EDTCDE keyword specifies the desired editing for output field OVRPMT. EDTCDE(1) indicates that the field OVRPMT is to be printed with commas, decimal point, and no sign. Also, a zero balance will be printed, and leading zeros will be suppressed.

(9)
The DSPATR keyword is used to specify the display attributes for the named field when the corresponding indicator status is true. The attributes specified are:

The subfile control record format defines the attributes of the subfile, the search input field, constants, and command keys. The keywords used indicate the following:

(10)
SFLCTL identifies this record as a subfile control record and names the associated subfile record (SUBFILE1).

(11)
SFLSIZ indicates the total number of records to be included in the subfile (17).

(12)
SFLPAG indicates the total number of records in a page (17).

(13)
SFLCLR indicates when the subfile should be cleared (when indicator 61 is on).

(14)
SFLDSP indicates when to display the subfile (when indicator 62 is on).

(15)
SFLDSPCTL indicates when to display the subfile control record (when indicator 62 is on).

(16)
The LOCK keyword prevents the workstation user from using the keyboard when the CONTROL1 record format is initially displayed.

(17)
HELP allows the user to press the Help key and sets indicator 99 on.

(18)
SFLMSG identifies the constant as a message that is displayed if indicator 99 is on.

In addition to the control information, the subfile control record format defines the constants to be used as column headings for the subfile record format. Refer to Figure 141 for an example of the subfile control record format.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]