Saturday, November 17, 2012

Extracting a Selected Subset of Records to Create a Test File


 

Chapter 13. Extracting a Selected Subset of Records to Create a Test File

In Chapter 2. "Browsing a Data File" you created temporary selection criteria and in Chapter 7. "Copying Selected PDS Members" you learned about the Copy utility. In this chapter you learn how to create permanent selection criteria with the File-AID Selection utility (option 6). You then use the selection criteria in the File-AID Copy utility (option 3.3) to create test data by extracting a subset of the records of the sample inventory file (FASAMP.INVFILE) to a test file (FASAMP.INVFILE2).

13.1 Accessing the Selection Criteria Function (Option 6)

The Selection Criteria function is option 6 on the File-AID Primary Option Menu.
Steps:
  1. Enter a 6 in the OPTION field on the File-AID Primary Option Menu (not shown here).
  2. Press <Enter>. File-AID displays the Selection Criteria - Dataset Specification screen as illustrated in Figure 13-1.

13.2 Specifying the Selection Criteria Datasets

You must specify a partitioned selection dataset to save your criteria members when using this function. The attributes of the dataset are:
DSORG=PO,RECFM=VB,LRECL=300,BLKSIZE=x (x = 304 or more)
A sample Selection dataset (FASAMP.SELCRIT) is created for you with your other training files. Create a new member "INVSEL" to select inventory file records that have a status of "AVAIL". Use record layouts to define your selection using formatted field selection criteria.
When you define or maintain formatted field selection criteria members, you must specify a single record layout or an XREF member.
Figure 13-1. Selection Criteria - Dataset Specification Screen
+--------------------------------------------------------------------------------+
| File-AID --------  Selection Criteria - Dataset Specification  ----------------|
| COMMAND ===>                                                                   |
|                                                                                |
| Specify Selection Criteria Member to be Created or Edited:                     |
|    Selection dataset name   ===> FASAMP.SELCRIT                                |
|    Member name              ===> INVSEL     (Blank or pattern for member list) |
|                                                                                |
| Specify Record Layout and XREF Information:                                    |
|    Record layout usage      ===> S          (S = Single; X = XREF; N = None)   |
|                                                                                |
|    Record layout dataset    ===> FASAMP.LAYOUTS                                |
|    Member name              ===> INVFILE    (Blank or pattern for member list) |
|                                                                                |
|    XREF dataset name        ===>                                               |
|    Member name              ===>            (Blank or pattern for member list) |
|                                                                                |
| -------------------------------------------------------------------------------|
| This function creates and maintains existing File-AID selection criteria. You  |
| can then apply these criteria in other functions (BROWSE, EDIT, COPY, COMPARE, |
| and PRINT).                                                                    |
|                                                                                |
| Specify either a record layout dataset and/or an XREF dataset when creating or |
| maintaining formatted selection criteria.                                      |
|                                                                                |
+--------------------------------------------------------------------------------+

Steps:
  1. Type FASAMP.SELCRIT in the selection Dataset name field.
  2. Type INVSEL in the selection Member name field. If this member exists, you see the member and are able to specify and save changes. If this is a new member, you define and save a new criteria member. If you leave this field blank or use a mask (for example, MEM*), a member list is displayed from which you can select a member for criteria display and modification.
  3. Type S in the Record layout usage field.
  4. Type FASAMP.LAYOUTS in the Record layout dataset name field.
  5. Type INVFILE in the layout Member name field.
  6. Press <Enter>. File-AID displays the Selection Criteria Menu screen as illustrated in Figure 13-2.

13.3 Defining Formatted Field Selections

The Selection Criteria Menu lets you access the three components of selection criteria:
OPTIONS Control selection based on record counts
FORMATTED Use record layout to define tests for record data
UNFORMATTED Define tests for record data without using layouts (by specifying location, length, operator, and data for each field to be tested).
In this example, you are going to define one test with formatted selection criteria. Criteria Menu option 2 lets you access the Formatted Selection Criteria screen.
Figure 13-2. Selection Criteria Menu Screen
+--------------------------------------------------------------------------------+
| File-AID - Selection Criteria Menu - USERID9.FASAMP.S      CREATE NEW CRITERIA |
| OPTION ===> 2                                                                  |
|                                                                - Status -      |
|       1  OPTIONS      - Enter selection criteria options         default       |
|       2  FORMATTED    - Edit formatted selection criteria        0   sets      |
|       3  UNFORMATTED  - Edit unformatted selection criteria      0   sets      |
|                                                                                |
|                                                                                |
| Member list description ===> SELECT AVAIL PARTS                                |
|                                                                                |
|     Long    ===> ______________________________________________________________|
| Description ===> ______________________________________________________________|
|                                                                                |
|                                                                                |
|                                                                                |
|                                                                                |
|                                                                                |
|                                                                                |
| Use VIEW command to display selection criteria summary                         |
| Use SAVE command to write selection criteria request                           |
| Use END to save selection criteria & return to dataset specification           |
| Use CANCEL to cancel changes & return to dataset specification                 |
|                                                                                |
+--------------------------------------------------------------------------------+

Steps:
  1. Type 2 (Formatted Criteria) in the OPTION field.
  2. Type SELECT AVAIL PARTS in the Member list description field.
  3. Press <Enter>.

13.4 Viewing a Layout in Column Location Order

Issue the SHOW OFFSET command to see the offset of each layout field.
Many other commands are provided to give you control of the criteria definition process. You may specify multiple field tests within one criteria or you can create a new test by issuing the INSERT or REPEAT commands.
Figure 13-3. Formatted Selection Criteria - Request Offset Display
+--------------------------------------------------------------------------------+
| File-AID --- Formatted Selection Criteria -------------------------------------|
| COMMAND ===> SHOW OFFSET                                      SCROLL ===> PAGE |
| SC010- Valid commands are: INSERT, DELETE, REPEAT, VIEW, SAVE, CANCEL, PROFILE |
| ---- FIELD LEVEL/NAME ------- -FORMAT- RO ----+----1----+----2----+----3----+- |
| ******************************* TOP OF DATA ********************************   |
| 1 INV-PART-NO                  15/AN                                           |
| 2 INV-DESCRIPTION              40/AN                                           |
|                            (POS 38-40)                                         |
| 3 INV-UNIT-OF-MEASURE           2/AN                                           |
| 4 INV-UNIT-PRICE                4/PS                                           |
| 5 INV-STOCK-INFO(1) OCCURS 2 TIMES  SYNC                                       |
|                                18/GRP                                          |
|   6 INV-WAREHOUSE(1)            3/AN                                           |
|   7 INV-STATUS(1)               6/AN                                           |
|   8 INV-QTY-DATE(1) SYNC        9/GRP                                          |
|     9 INV-QTY-ON-HAND(1)        3/PS                                           |
|     10 INV-LAST-ORDER-DATE(1)   6/AN                                           |
|   11 INV-BO-QTY-DATE REDEFINES INV-QTY-DATE                                    |
|   11 INV-BO-QTY-DATE(1) SYNC    9/GRP                                          |
|     12 INV-QTY-BACKORDERED(1)   3/PS                                           |
|     13 INV-BACKORDER-DATE(1)    6/AN                                           |
| 5 INV-STOCK-INFO(2)            18/GRP                                          |
|   6 INV-WAREHOUSE(2)            3/AN                                      (1/5)|
|   7 INV-STATUS(2)               6/AN                                           |
+--------------------------------------------------------------------------------+

Steps:
  1. Type SHOW OFFSET in the COMMAND field.
  2. Press <Enter>.

13.5 Defining Formatted Field Selection Criteria

You can choose records for processing by defining one or more conditions that a record must meet in order to be selected. With formatted selection criteria, you can select records based on the value of a specified field within the record layout. To search for a specific field value, you must define a test condition for that field. The test condition consists of the field name, a relational operator, and the value for which you want to test.
The relational operator is entered under the RO column on the screen and can be specified in a letter or symbolic format (for example, "equal to" can be specified as EQ or =). The field value is entered to the right of the relational operator.
In this example, you define a test for INV-STATUS (1) equal to "AVAIL". Notice how each element of an array is displayed with its subscript.
Figure 13-4. Formatted Selection Criteria - Specifying a Test
+--------------------------------------------------------------------------------+
| File-AID --- Formatted Selection Criteria ----------------- COLUMNS 00001 00111|
| COMMAND ===> END                                              SCROLL ===> PAGE |
| CRITERIA NUMBER:  1 OF  1  INVENTORY-RECORD                LAYOUT LENGTH:   189|
| ---- FIELD NUMBER/NAME ------ COLUMNS- RO ----+----1----+----2----+----3----+- |
| ******************************* TOP OF DATA ********************************   |
| 1 INV-PART-NO                     0                                            |
| 2 INV-DESCRIPTION                15                                            |
|                                  52                                            |
| 3 INV-UNIT-OF-MEASURE            55                                            |
| 4 INV-UNIT-PRICE                 57                                            |
| 5 INV-STOCK-INFO(1) OCCURS 2 TIMES  SYNC                                       |
|                                  61                                            |
|   6 INV-WAREHOUSE(1)             61                                            |
|   7 INV-STATUS(1)                64    EQ AVAIL                                |
|   8 INV-QTY-DATE(1) SYNC         70                                            |
|     9 INV-QTY-ON-HAND(1)         70                                            |
|     10 INV-LAST-ORDER-DATE(1)    73                                            |
|   11 INV-BO-QTY-DATE REDEFINES INV-QTY-DATE                                    |
|   11 INV-BO-QTY-DATE(1) SYNC     70                                            |
|     12 INV-QTY-BACKORDERED(1)    70                                            |
|     13 INV-BACKORDER-DATE(1)     73                                            |
| 5 INV-STOCK-INFO(2)              79                                            |
|   6 INV-WAREHOUSE(2)             79                                       (1/5)|
|   7 INV-STATUS(2)                82                                            |
+--------------------------------------------------------------------------------+

Steps:
  1. Type EQ in the RO column next to the field name INV-STATUS(1).
  2. Type AVAIL in the data area to define the test "INV-STATUS(1) EQUAL TO AVAIL".
  3. Type END in the COMMAND field to return to the Criteria Menu; you do not need to specify any more criteria for this example.
  4. Press <Enter>.
More About Formatted Selection Criteria
  • When your test condition includes more than one field, File-AID links the tests together (the tests are ANDed) and requires that all the conditions be true before it selects a record.
  • You can use the REPEAT or INSERT command to add a new selection criteria set. Sets are ORed together and only one of the test sets must be true. If a record fails to match CRITERIA NUMBER 1 in an ORed condition, File-AID tests the record to see if CRITERIA NUMBER 2 matches. This process continues until a record has been tested for each set. As soon as a record matches any set, File-AID selects it.
  • Use FWD and BACK commands (RIGHT, LEFT) to scroll among multiple criteria sets.
  • Use the DELETE command to remove a set.

13.6 Saving Your Permanent Selection Criteria Member

Notice that the status for FORMATTED criteria now shows "1 sets" to reflect the test you just defined.
When you enter the END primary command from the Selection Criteria menu, File-AID automatically stores the selection criteria member (INVSEL) in the selection criteria dataset (FASAMP.SELCRIT).
Figure 13-5. Selection Criteria Menu. Specifying END to Save Selection Criteria.
+--------------------------------------------------------------------------------+
| File-AID - Selection Criteria Menu - USERID9.FASAMP.SELCRIT(INVSEL) -----------|
| OPTION ===> END                                                                |
|                                                                - Status -      |
|       1  OPTIONS      - Enter selection criteria options         default       |
|       2  FORMATTED    - Edit formatted selection criteria        1   sets      |
|       3  UNFORMATTED  - Edit unformatted selection criteria      0   sets      |
|                                                                                |
|                                                                                |
| Member list description ===> SELECT AVAIL PARTS____________                    |
|                                                                                |
|     Long    ===> ______________________________________________________________|
| Description ===> ______________________________________________________________|
|                                                                                |
|                                                                                |
|                                                                                |
|                                                                                |
|                                                                                |
|                                                                                |
| Use VIEW command to display selection criteria summary                         |
| Use SAVE command to write selection criteria request                           |
| Use END to save selection criteria & return to dataset specification           |
| Use CANCEL to cancel changes & return to dataset specification                 |
|                                                                                |
+--------------------------------------------------------------------------------+

Steps:
  1. Type END in the OPTION field.
  2. Press <Enter>. File-AID displays the Selection Criteria - Dataset Specification screen (see Figure 13-6) with the message: CRITERIA MEMBER SAVED.
More About Selection Criteria Menu
  • If you want to review the criteria you created before you save it, the VIEW primary command summarizes the specified options and all of the sets of formatted and unformatted selection criteria into a scrollable display.
  • The SAVE command saves your changes but remains on the Selection Criteria Menu screen.
  • The CANCEL command lets you exit without saving your member. Any entries you have made are lost and no new member is created.
  • If you do not specify any options or change any of the default values, File-AID reads all of the records starting at the beginning of the dataset and stopping when the "Number of Records to Select" default (established in 0.2 Selection Parameters) is reached. File-AID is distributed with a default of "ALL" for "Number of Records to Select". Use the "1 OPTIONS" menu choice to view and change this value for this selection criteria, and/or use option 0.2 to set a different permanent default for yourself.

13.7 Exiting the Selection Criteria Utility

Use the END command to exit the Selection Criteria function and return to the File-AID Primary Option Menu now.
Steps:
  1. Enter the END command (or press PF3) to redisplay the Primary Option Menu.
  2. Press <Enter>.
Figure 13-6. Selection Criteria Function. CRITERIA MEMBER SAVED Message.
+--------------------------------------------------------------------------------+
| File-AID --------  Selection Criteria - Dataset Speci    CRITERIA MEMBER SAVED |
| COMMAND ===> END                                                               |
|                                                                                |
| Specify Selection Criteria Member to be Created or Edited:                     |
|    Selection dataset name   ===> FASAMP.SELCRIT                                |
|    Member name              ===> INVSEL     (Blank or pattern for member list) |
|                                                                                |
| Specify Record Layout and XREF Information:                                    |
|    Record layout usage      ===> S          (S = Single; X = XREF; N = None)   |
|                                                                                |
|    Record layout dataset    ===> FASAMP.LAYOUTS                                |
|    Member name              ===> INVFILE    (Blank or pattern for member list) |
|                                                                                |
|    XREF dataset name        ===>                                               |
|    Member name              ===>            (Blank or pattern for member list) |
|                                                                                |
| -------------------------------------------------------------------------------|
| This function creates and maintains existing File-AID selection criteria. You  |
| can then apply these criteria in other functions (BROWSE, EDIT, COPY, COMPARE, |
| and PRINT).                                                                    |
|                                                                                |
| Specify either a record layout dataset and/or an XREF dataset when creating or |
| maintaining formatted selection criteria.                                      |
|                                                                                |
+--------------------------------------------------------------------------------+

13.8 Accessing the Copy Utility (3.3)

Now that you have defined and saved your selection criteria, you can use your criteria with the Copy utility to extract a subset of records from a master file to create a test file.
The Copy utility is located on the Extended Utilities menu (option 3). You can access it directly by accessing option 3.3 from the Primary Option Menu.
Steps:
  1. From the File-AID Primary Option Menu (Figure 13-7), select File-AID option 3.3.
  2. Press <Enter>. File-AID displays the Copy Utility screen as illustrated in Figure 13-8.
Figure 13-7. File-AID Primary Option Menu. Selecting 3.3 COPY Utility.
+--------------------------------------------------------------------------------+
| File-AID 8.0.0 -------------  Primary Option Menu  ----------------------------|
| OPTION ===> 3.3                                                                |
|                                                                                |
|   0  PARAMETERS  - Specify ISPF and File-AID parameters     USERID   - USERID9 |
|   1  BROWSE      - Display file contents                    PF KEYS  - 24      |
|   2  EDIT        - Create or change file contents           TERMINAL - 3278    |
|   3  UTILITIES   - File-AID/SPF extended utilities          TIME     - 14:28   |
|   5  PRINT       - Print file contents                      JULIAN   - 94.160  |
|   6  SELECTION   - Create or change selection criteria      DATE     - 94/06/09|
|   7  XREF        - Create or change record/layout cross reference              |
|   8  VIEW        - View interpreted record layout                              |
|   9  REFORMAT    - Convert file from one format to another                     |
|  10  COMPARE     - Compare file contents                                       |
|   C  CHANGES     - Display summary of File-AID changes                         |
|   T  TUTORIAL    - Display information about File-AID                          |
|   X  EXIT        - Terminate File-AID and return to ISPF                       |
|                                                                                |
|      Use the END command to terminate File-AID                                 |
|                                                                                |
|                                                                                |
|                                                                                |
|                                                                                |
|       Copyright (c) 1982,1994, an unpublished work by Compuware Corporation.   |
|                              All Rights Reserved.                              |
+--------------------------------------------------------------------------------+

13.9 Specifying the "FROM" and "TO" Datasets and Selection Criteria Member

The last dataset you referenced in any File-AID function or utility is automatically displayed in the FROM dataset name field. The TO dataset name field retains the last dataset name you specified in the Copy utility.
The Selection Criteria dataset and member you last referenced (in this case, through the Selection Criteria function) is displayed in the lower portion of the screen.
You must identify the FROM dataset and the TO dataset and whether or not you want to use selection criteria (Selection criteria usage field). You can choose to run your copy online at your terminal or in batch by specifying the processing option in the Process online or batch field.
In this example, specify an E in the Selection criteria usage field to use existing criteria in the online copy process.
Figure 13-8. Copy Utility Screen. Use Existing Selection Criteria.
+--------------------------------------------------------------------------------+
| File-AID ---------------------  Copy Utility  ---------------------------------|
| COMMAND ===>                                                                   |
|                                                                                |
| Specify "FROM" Dataset Information:                                            |
|    Dataset name   ===> FASAMP.INVFILE                                          |
|    Volume serial  ===>                      (If not cataloged)                 |
|                                                                                |
| Specify "TO" Dataset Information:                                              |
|    Dataset name   ===> FASAMP.INVFILE2                                         |
|    Volume serial  ===>                      (If not cataloged)                 |
|    Disposition    ===> OLD                  (OLD, MOD, NEW)                    |
|                                                                                |
|                                                                                |
| Specify Execution Information:                                                 |
|    Process online or batch    ===> O        (O = Online; B = Batch)            |
|                                                                                |
| Specify Selection Criteria Information:     (E = Existing; T = Temporary;      |
|    Selection criteria usage   ===> E         M = Modify; Q = Quick; N = None)  |
|    Selection dataset name     ===> FASAMP.SELCRIT                              |
|    Member name                ===> INVSEL   (Blank or pattern for member list) |
|                                                                                |
+--------------------------------------------------------------------------------+

Steps:
  1. Type FASAMP.INVFILE in the "FROM" Dataset name field.
  2. Type FASAMP.INVFILE2 in the "TO" Dataset name field.
  3. Type OLD in the Disposition field.
  4. Type an O in the Process online or batch field. If you specify to run the copy in batch, File-AID displays the standard JCL Specification screen where you can define the batch processing options.
  5. Type an E in the Selection criteria usage field. Note: Make sure you always check this field before you press Enter. The value last used remains set from session to session.
  6. Press <Enter>. File-AID executes the copy process immediately and returns with a confirmation message, 17 RECORDS COPIED.

13.10 Exiting the Copy Utility

Use PF3 (the END command) to exit the Copy utility and return to the File-AID Primary Option Menu now.
Figure 13-9. Copy Utility Screen. RECORDS COPIED Message.
+--------------------------------------------------------------------------------+
| File-AID ---------------------  Copy Utility  -------------- 17 RECORDS COPIED |
| COMMAND ===> END                                                               |
| ER050-41 records were read from USERID9.FASAMP.INVFILE                         |
| Specify "FROM" Dataset Information:                                            |
|    Dataset name   ===> FASAMP.INVFILE                                          |
|    Volume serial  ===>                      (If not cataloged)                 |
|                                                                                |
| Specify "TO" Dataset Information:                                              |
|    Dataset name   ===> FASAMP.INVFILE2                                         |
|    Volume serial  ===>                      (If not cataloged)                 |
|    Disposition    ===> OLD                  (OLD, MOD, NEW)                    |
|                                                                                |
|                                                                                |
| Specify Execution Information:                                                 |
|    Process online or batch    ===> O        (O = Online; B = Batch)            |
|                                                                                |
| Specify Selection Criteria Information:     (E = Existing; T = Temporary;      |
|    Selection criteria usage   ===> E         M = Modify; Q = Quick; N = None)  |
|    Selection dataset name     ===> FASAMP.SELCRIT                              |
|    Member name                ===> INVSEL   (Blank or pattern for member list) |
|                                                                                |
+--------------------------------------------------------------------------------+

Steps:
  1. Press PF1 (HELP) to view the long message associated with 17 RECORDS COPIED.
     ER050-41 records were read from USERID9.FASAMP.INVFILE
    
  2. Enter the END command (press PF3) until the File-AID Primary Option Menu is displayed.
  3. (Optional) Use File-AID Browse to view the FASAMP.INVFILE2 dataset in vertical formatted mode using the FASAMP.LAYOUTS record layout member INVFILE. Check that all INV-STATUS (1) fields have a value of AVAIL in them.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.