Sample 6: File Link

Task: Find both the name and type of the yacht in which a customer sailed on a cruise starting on March 9 1991. the customer is very tall and remembers that the yacht had head room of more than 1m95cm.

Information about cruise starting dates is stored in the fileSAG-TOURS-E-CRUISE. Yacht names and technical specifications are stored in the file SAG-TOURS-E-YACHT. Because you need information from two files, you must link them using the INCLUDE command.

For further information on linking files, see INCLUDE command and What is File Linking? in Files in the User's Guide.

Super Natural searches the primary and secondary files as follows when the transaction is run:

  1. A search is made in the SAG-TOURS-E-CRUISE file for all records which meet the selection criterion START-DATE = 19910309. The following records are found:

graphics/graphic74.gif

  1. When a record is found in the primary file, Super Natural takes the value of its link field (ID-YACHT) and searches the secondary file for records whose link field (YACHT-ID) has the same value. The following records are found:

graphics/graphic75.gif

  1. The selection criterion HEAD-ROOM > 1.95 is applied to the records found in the secondary file. The following record is found.

graphics/graphic76.gif

Transaction Specification

Primary File SAG-TOURS-E-CRUISE
Link field in primary file ID-YACHT
Secondary File SAG-TOURS-E-YACHT
Link field in secondary file YACHT-ID
Selection Criteria START-DATE = 19910309 AND HEAD-ROOM > 1.95
Display fields 1: YACHT-NAME
2: YACHT TYPE
3: START-DATE
4: HEAD-ROOM

This section covers the following topics:


Create the Transaction SAMPLE6

Start of instruction setTo Add a Transaction

  1. Issue the ADD TRANSACTION SAMPLE6 command.

    The Add Transaction window appears.

  2. Type "File Link" in the Description field (optional).

Start of instruction setTo Choose a Primary File

The report requires data from the primary file SAG-TOURS-E-CRUISE.

  1. Type SAG-TOURS-E-CRUISE in the File Name field.

  2. Press Enter.

    The Worksheet appears.

Start of instruction setTo Choose Secondary File

  1. Issue the INCLUDE command.

    The Include Files window appears.

  2. Enter SAG-TOURS-E-YACHT in the Secondary File field. You can also use the Asterisk (*) List function.

     17:31                      ***** Super Natural *****                 1998-05-13
     SAMPLE6                          - Worksheet -                           SN3011
                                                                                    
     Ref DB    Field Name    +--------------------Include Files--------------------+
     BE        _____________ !                                                     !
     BF        _____________ ! Primary File ..... SAG-TOURS-E-CRUISE______________ !
     BG        _____________ ! Secondary File ... sag-tours-e-yacht_______________ !
     BH        _____________ !                                                     !
     BI        _____________ ! Add Lookup File .. ________________________________ !
     BJ        _____________ ! Process Lookups .. _                                !
     BK        _____________ !                                                     !
     BL        _____________ +-----------------------------------------------------+
     BM        ________________________________   ___   ___   __   __   __   __     
     BN        ________________________________   ___   ___   __   __   __   __     
     BO        ________________________________   ___   ___   __   __   __   __     
     BP        ________________________________   ___   ___   __   __   __   __     
     BQ        ________________________________   ___   ___   __   __   __   __     
     BR        ________________________________   ___   ___   __   __   __   __     
                                                                                    
                                                                                    
     Fill in required definitions                                                   
     Command ===>                                                                   
     Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
           Help        Exit              Flip                                Canc   
    

    The Define File Link window appears.

  3. Type ID-YACHT in the Link Field in Primary File field.

  4. Type YACHT-ID in the Link Field in Secondary File field.

     17:31                      ***** Super Natural *****                 1998-05-13
     SAMPLE6                          - Worksheet -                           SN3011
                                                                                    
     Ref DB    Field Name    +--------------- +----------Define File Link----------+
     BE        _____________ !                !                                    !
     BF        _____________ ! Primary File . ! Primary File                       !
     BG        _____________ ! Secondary File !   SAG-TOURS-E-CRUISE               !
     BH        _____________ !                ! Link field in primary file         !
     BI        _____________ ! Add Lookup Fil !   id-yacht________________________ !
     BJ        _____________ ! Process Lookup ! From position .. ...               !
     BK        _____________ !                !   to position .. ...               !
     BL        _____________ +--------------- !                                    !
     BM        ______________________________ ! Secondary File                     !
     BN        ______________________________ !   SAG-TOURS-E-YACHT                !
     BO        ______________________________ ! Link field in secondary file       !
     BP        ______________________________ !   yacht-id________________________ !
     BQ        ______________________________ !                                    !
     BR        ______________________________ +------------------------------------+
     
    

    The fields ID-YACHT and YACHT-ID are used as link fields because they both have the format N8 and contain comparable data. You can also use the Asterisk (*) List function to review the field list for each file.

  5. Press Enter.

    The Define File Link window closes.

  6. Press Enter.

    The Include Files window closes.

Start of instruction setTo Choose Fields

The report requires data stored in the fields YACHT-NAME, YACHT-TYPE, START-DATE and HEAD-ROOM.

  • Choose the fields as described in Step 3 of Sample 1.

Start of instruction setTo Determine Display Sequence for Horizontal Output

  1. Type " 1" in the Sequence column next to the field YACHT-NAME.

  2. Type "2" in the Sequence column next to the field YACHT-TYPE.

  3. Type "3" in the Sequence column next to the field START-DATE.

  4. Type "4" in the Sequence column next to the field HEAD-ROOM.

    The Worksheet now looks like this:

     17:36                      ***** Super Natural *****                 1998-05-13
     SAMPLE6                          - Worksheet -                           SN3011
                                                                                    
     Ref DB    Field Name                         Seq   S/C  Func Def  Info Del     
     AE  1K 2  START-DATE .....................   3__   ___   __   __   __   __     
     AL  1K    ID-YACHT .......................   ___   ___   __   __   __   __     
     BE  2K    YACHT-ID .......................   ___   ___   __   __   __   __     
     BF  2K    YACHT-NAME .....................   1__   ___   __   __   __   __     
     BK  2K    YACHT-TYPE .....................   2__   ___   __   __   __   __     
     BQ  2     HEAD-ROOM ......................   4__   ___   __   __   __   __     
     BS        ________________________________   ___   ___   __   __   __   __     
     BT        ________________________________   ___   ___   __   __   __   __     
     BU        ________________________________   ___   ___   __   __   __   __     
     BV        ________________________________   ___   ___   __   __   __   __     
     BW        ________________________________   ___   ___   __   __   __   __     
     BX        ________________________________   ___   ___   __   __   __   __     
     BY        ________________________________   ___   ___   __   __   __   __     
     BZ        ________________________________   ___   ___   __   __   __   __     
                                                                                    
                                                                                    
     Fill in required definitions                                                   
     Command ===>                                                                   
     Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
           Help  Next  Exit  Field Incl  Flip  -     +           Sel   Run   Canc   
    

    The "2"s in the DB column indicate that the fields they are next to are in the secondary file.

Start of instruction setTo Define Selection Criteria

  1. Issue the SELECTION command. You can also abbreviate this command to SEL.

    The Selection Editor appears.

    The report requires information on a cruise which started on 9 March 1991 and used a yacht which had more head room than 1.95m.

  2. Enter START-DATE = 19910309 AND HEAD-ROOM > 1.95 in the editor area.

     17:37                      ***** Super Natural *****                 1998-05-13
     SAMPLE6                       - Selection Editor -                      SNZUL-S
                                                                                    
                                                                                    
           1  < START-DATE = 19910309 AND HEAD-ROOM > 1.95                   >    1 
           2  <                                                              >    2 
           3  <                                                              >    3 
           4  <                                                              >    4 
           5  <                                                              >    5 
           6  <                                                              >    6 
           7  <                                                              >    7 
           8  <                                                              >    8 
           9  <                                                              >    9 
          10  <                                                              >   10 
          11  <                                                              >   11 
          12  <                                                              >   12 
          13  <                                                              >   13 
          14  <                                                              >   14 
          15  <                                                              >   15 
                                                                                    
     SELECTION lines are correct                                                    
     Command ===>                                                                   
     Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
           Help  Next  Exit  Field Check Flip  -     +           Cont  Run   Canc   
    

Start of instruction setTo Run the Transaction

  1. Issue the RUN command.

    Because the headers of the fields you have chosen for display are too wide to fit on the standard page, the Report Line Length window appears.

  2. Mark the option "Change to Report Type Vertical".

     17:37                      ***** Super Natural *****                 1998-05-13
     SAMPLE6                       - Selection Editor -                      SNZUL-S
                                                                                    
                               +----------------Report Line Length-----------------+
           1  < START-DATE = 1 !                                                   !
           2  <                ! The selected fields required a line size of .. 79 !
           3  <                ! The field headers required a line size of .... 82 !
           4  <                ! The available Online  line size at present ... 79 !
           5  <                !                                                   !
           6  <                !   -  Enlarge Available Line Size                  !
           7  <                !   x  Change to Report Type Vertical List          !
           8  <                !   _  Truncate Headers                             !
           9  <                !   _  Remove Excess Fields                         !
          10  <                !   _  Remove Excess Fields and Truncate Headers    !
          11  <                !   _  Modify Transaction                           !
          12  <                !                                                   !
          13  <                +---------------------------------------------------+
          
    
  3. Press Enter.

    The report is generated. Part of the resulting report is shown below:

     17:44:38  START-DATE = 19910309 AND HEAD-ROOM > 1.95                 1998-05-13
     ISAMPL6                                                                1       
                                                                                    
     YACHT-NAME ..................... CASABLANCA                                    
     YACHT-TYPE ..................... PACIFIC 52                                    
     START-DATE ..................... 19910309                                      
     HEAD-ROOM ...................... 2.05                                          
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
     Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
                 Print Exit              Flip        +     Posi  <     >     Canc