Sample 3: User Fields, Calculation and Logical Conditions Editors

Task: List cruises which use charter yacht type ATLANTIC 29. Display end date of cruise under start date and present the information in the format DD.MM.YY. Display the text 'too late' instead of the data sets (files) for cruises which start after 7.1.1991.

The steps in this transaction are performed in a logical order. The order in which the steps are carried out is different to the order in the previous sample transactions.

The data in the fields START-DATE and END-DATE is stored in the format YYYYMMDD which is difficult to read at a glance (you can confirm this by adding a report using the file SAG-TOURS-E-CRUISE which has the selection criteria AA and the display fields START-DATE and END-DATE). The following is an example where Y = year, M= month and D = day:

graphics/graphic36.gif

The report requires that the date be presented with the format DD.MM.YY. To do this, you must create three user fields from the field START-DATE: one with the year information, one with the month information and one with the day information. You then join the user fields together in the order day, month, year with periods (.) using the Joining Fields (Concatenation) function in the Calculation Editor as shown in the following diagram:

graphics/graphic37.gif

You then do the same for the field END-DATE.

Transaction Specification

Primary File SAG-TOURS-E-CRUISE
User Fields MY-START-DATE
MY-START-YEAR
MY-START-MONTH
MY-START-DAY
MY-END-DATE
MY-END-YEAR
MY-END-MONTH
MY-END-DAY
Display Fields 1: CRUISE-ID
2: START-HARBOR
3: DESTINATION-HARBOR
4A: MY-START-DATE
4B: MY-END-DATE
Selection Criteria CHARTER-YACHT-TYPE = 'ATLANTIC 29'
CalculationStatement MY-START-DATE=MY-START-DAY!'.'!MY-START-MONTH!'.'!MY-START-YEAR MY-END-DATE=MY-END-DAY!'.'!MY-END-MONTH!'.'!MY-END-YEAR
Logical Conditions Statement 1 I < START-DATE GT 19910701
1 T < MY-START-DATE = 'TOO LATE
1 T < MY-END-DATE = ' '

This section covers the following topics:


Create the Transaction SAMPLE3

Start of instruction setTo add a transaction

  1. Issue the ADD TRANSACTION SAMPLE3 command.

    The Add Transaction window appears.

  2. Type "User Fields and Editors" in the Description field (optional).

Start of instruction setTo Choose a File

The report requires data from the 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 Fields

The report requires data stored in the fields CRUISE-ID, START-HARBOR and DESTINATION-HARBOR.

  • Type CRUISE-ID, START-HARBOR and DESTINATION-HARBOR beneath each other in the Field Name column.

    Or:
    Choose the fields using the Asterisk List function as described in Step 3 of the section Sample 1.

Start of instruction setTo Determine Display Sequence for Horizontal Output

  1. Type "1" in the Sequence column next to the field CRUISE-ID.

  2. Type "2" in the Sequence column next to the field START-HARBOR.

  3. Type "3" in the Sequence column next to the field DESTINATION-HARBOR.

Start of instruction setTo Define User Fields

The report requires the following user fields as described at the beginning of this section: - MY-START-DATE - MY-START-YEAR - MY-START-MONTH - MY-START-DAY - MY-END-DATE - MY-END-YEAR - MY-END-MONTH - MY-END-DAY

  1. Enter MY-START-DATE in the Field Name column.

    The Define User Field window appears.

  2. Type "A" in the Format field.

  3. Type "8" in the Length field:

     11:35                      ***** Super Natural *****                 1998-02-09
     SAMPLE3                          - Worksheet -                           SN3011
                                                                                    
     Ref DB    Field Name      +-----------------Define User Field-----------------+
     AA  1K    CRUISE-ID ..... ! Field: MY-START-DATE                              !
     AJ  1K    START-HARBOR .. !                                                   !
     AK  1K    DESTINATION-HAR ! Name or value .. MY-START-DATE___________________ !
     BE        my-start-date__ ! Format ......... a                                !
     BF        _______________ ! Length ......... 8__                              !
     BG        _______________ ! Dec. places ....                                  !
     BH        _______________ ! Subfield of .... ________________________________ !
     BI        _______________ ! Offset ......... ___                              !
     BJ        _______________ ! Dynamic input .. _                                !
     BK        _______________ !                                                   !
     BL        _______________ +---------------------------------------------------+
       
    
  4. Press Enter.

    The user field MY-START-DATE is created.

  5. Enter MY-START-YEAR in the Field Name column.

    The Define User Field window appears.

  6. Type "A" in the Format field.

  7. Type "2" in the Length field:

    This user field is going to take part of the value of the database field START-DATE.

  8. Type START-DATE in the Subfield Of field.

    This user field is going to take the third (3rd) and fourth (4th) characters of the field START-DATE, so you must tell Super Natural to ignore the first two characters.

  9. Type " 2" in the Offset field.

     11:50                      ***** Super Natural *****                 1998-02-09
     SAMPLE3                          - Worksheet -                           SN3011
                                                                                    
     Ref DB    Field Name      +-----------------Define User Field-----------------+
     AA  1K    CRUISE-ID ..... ! Field: MY-START-YEAR                              !
     AJ  1K    START-HARBOR .. !                                                   !
     AK  1K    DESTINATION-HAR ! Name or value .. MY-START-YEAR___________________ !
     BE   U    MY-START-DATE . ! Format ......... a                                !
     BF        my-start-year__ ! Length ......... 2__                              !
     BG        _______________ ! Dec. places .... _                                !
     BH        _______________ ! Subfield of .... start-date______________________ !
     BI        _______________ ! Offset ......... 2__                              !
     BJ        _______________ ! Dynamic input .. _                                !
     BK        _______________ !                                                   !
     BL        _______________ +---------------------------------------------------+
        
    
  10. Press Enter.

    The user field MY-START-YEAR is created.

  11. Enter MY-START-MONTH in the Field Name column.

    The Define User Field window appears.

  12. Type "A" in the Format field.

  13. Type "2" in the Length field:

    This user field is also going to take part of the value of the database field START-DATE.

  14. Type START-DATE in the Subfield Of field.

    This user field is going to take the fifth (5th) and sixth (6th) characters of the field START-DATE, so you must tell Super Natural to ignore the first four characters.

  15. Type " 4" in the Offset field.

     11:54                      ***** Super Natural *****                 1998-02-09
     SAMPLE3                          - Worksheet -                           SN3011
                                                                                    
     Ref DB    Field Name      +-----------------Define User Field-----------------+
     AA  1K    CRUISE-ID ..... ! Field: MY-START-MONTH                             !
     AJ  1K    START-HARBOR .. !                                                   !
     AK  1K    DESTINATION-HAR ! Name or value .. MY-START-MONTH__________________ !
     BE   U    MY-START-DATE . ! Format ......... a                                !
     BF   U    MY-START-YEAR . ! Length ......... 2__                              !
     BG        my-start-month_ ! Dec. places .... _                                !
     BH        _______________ ! Subfield of .... start-date_____________________  !
     BI        _______________ ! Offset ......... 4__                              !
     BJ        _______________ ! Dynamic input .. _                                !
     BK        _______________ !                                                   !
     BL        _______________ +---------------------------------------------------+
      
    
  16. Press Enter.

    The user field MY-START-MONTH is created.

  17. Enter MY-START-DAY in the Field Name column.

    The Define User Field window appears.

  18. Type "A" in the Format field.

  19. Type " 2" in the Length field:

    This user field is also going to take part of the value of the database field START-DATE.

  20. Type START-DATE in the Subfield Of field.

    This user field is going to take the seventh (7th) and eighth (8th) characters of the field START-DATE, so you must tell Super Natural to ignore the first six characters.

  21. Type "6" in the Offsetfield.

     11:59                      ***** Super Natural *****                 1998-02-09
     SAMPLE3                          - Worksheet -                           SN3011
                                                                                    
     Ref DB    Field Name      +-----------------Define User Field-----------------+
     AA  1K    CRUISE-ID ..... ! Field: MY-START-DAY                               !
     AJ  1K    START-HARBOR .. !                                                   !
     AK  1K    DESTINATION-HAR ! Name or value .. MY-START-DAY____________________ !
     BE   U    MY-START-DATE . ! Format ......... a                                !
     BF   U    MY-START-YEAR . ! Length ......... 2__                              !
     BG   U    MY-START-MONTH  ! Dec. places .... _                                !
     BH        my-start-day___ ! Subfield of .... start-date______________________ !
     BI        _______________ ! Offset ......... 6__                              !
     BJ        _______________ ! Dynamic input .. _                                !
     BK        _______________ !                                                   !
     BL        _______________ +---------------------------------------------------+
     
    
  22. Press Enter.

    The user field MY-START-DAY is created.

  23. Create the other user fields as shown in the table below:

    Field Format Length Subfield Of Offset
    MY-END-DATE A 8    
    MY-END-YEAR A 2 END-DATE 2
    MY-END-MONTH A 2 END-DATE 4
    MY-END-DAY A 2 END-DATE 6

Start of instruction setTo Determine Display Sequence for Vertical Output

The field MY-START-DATE is to be displayed above the field MY-END-DATE and to the right of the other display fields.

  1. Type "4A" in the Sequence column next to the field MY-START-DATE.

  2. Type "4B" in the Sequence column next to the field MY-END-DATE.

Start of instruction setTo Change Header of Vertical Output Column

  1. Enter "OD" in the Definition (Def) column next to the fieldMY-START-DATE.

    The Define User Field Output window appears.

  2. Enter "Cruise From To" in the Heading fields as shown in the following diagram:

     14:01                      ***** Super Natural *****                 1998-02-09
     SAMPLE3                          - Worksheet -                           SN3011
                                                                                    
     Ref DB    Field Na +-----------------Define User Field Output-----------------+
     AA  1K    CRUISE-I ! Field: MY-START-DATE                                     !
     AE  1K 2  START-DA !                                                          !
     AH  1K 2  END-DATE ! Format/Length ....... A8                                 !
     AJ  1K    START-HA ! Numeric sign ........ _ (Y/N)                            !
     AK  1K    DESTINAT ! Output length ....... 8__                                !
     AP  1  2  CHARTER- !        dec. places .. _                                  !
     BE   U    MY-START ! Heading ............. CRUISE________________________     !
     BF   U    MY-START !                         FROM________________________     !
     BG   U    MY-START !                         TO__________________________     !
     BH   U    MY-START ! Edit mask                                                !
     BI   U    MY-END-D !   ______________________________________________________ !
     BJ   U    MY-END-Y ! Suppress identical values .. _ (Y/N)                     !
     BK   U    MY-END-M ! Print zero values .......... _ (Y/N)                     !
     BL   U    MY-END-D !                                                          !
                        +----------------------------------------------------------+
     
    

    The Worksheet now has the following entries:

     13:25                      ***** Super Natural *****                 1998-02-09
     SAMPLE3                          - Worksheet -                           SN3011
                                                                                    
     Ref DB    Field Name                         Seq   S/C  Func Def  Info Del     
     AA  1K    CRUISE-ID ......................   1__   ___   __   __   __   __     
     AJ  1K    START-HARBOR ...................   2__   ___   __   __   __   __     
     AK  1K    DESTINATION-HARBOR .............   3__   ___   __   __   __   __     
     BE   U    MY-START-DATE ..................   4A_   ___   __   __   __   __     
     BF   U    MY-START-YEAR ..................   ___   ___   __   __   __   __     
     BG   U    MY-START-MONTH .................   ___   ___   __   __   __   __     
     BH   U    MY-START-DAY ...................   ___   ___   __   __   __   __     
     BI   U    MY-END-DATE ....................   4B_   ___   __   __   __   __     
     BJ   U    MY-END-YEAR ....................   ___   ___   __   __   __   __     
     BK   U    MY-END-MONTH ...................   ___   ___   __   __   __   __     
     BL   U    MY-END-DAY .....................   ___   ___   __   __   __   __     
     BM        ________________________________   ___   ___   __   __   __   __     
     BN        ________________________________   ___   ___   __   __   __   __     
     BO        ________________________________   ___   ___   __   __   __   __     
                                                                                    
                                                                                    
     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   
    

    Notice that the user fields are marked with a 'U' in the DB Column.

Start of instruction setTo Define Selection Criteria

The report requires data for cruises of charter yacht type ATLANTIC 29.

  1. Issue the SELECTION command.

    You can abbreviate this command to SEL.

    The Selection Editor appears.

  2. Enter "CHARTER-YACHT-TYPE = 'ATLANTIC 29'" in the editor area.

Note:
The field CHARTER-YACHT-TYPE now appears in the Field Name column of the Worksheet.

Start of instruction setTo Present Start Date and End Date of Cruise in the Format DD.MM.YY.

  1. Issue the CALCULATION command. You can abbreviate this command to CAL.

    The Calculation Editor appears. The first result field in the editor area will be the user field MY-START-DATE and will be composed of the user fields MY-START-YEAR, MY-START-MONTH and MY-START-DAY separated by periods (.). You use the Joining Fields (concatenation) function to join the fields and periods.

  2. Type "MY-START-DATE = MY-START-DAY".

  3. Type the Joining Fields operator valid for your site.

    If you do not know which operator to use, ask your Super Natural administrator.

    Or:
    Issue the CONTINUE command. This command is allocated to PF10.

    The Fields - Operators window appears.

  4. Select Select Operator.

     14:24                      ***** Super Natural *****                 1998-02-10
     SAMPLE3                     - Calculation Editor -                      SNZUL-C
                                                                                    
                                                          +---Fields - Operators---+
           1  < MY-START-DATE=MY-START-DAY                !                        !
           2  <                                           !   _  Invoke Field List !
           3  <                                           !   _  ROUNDED           !
           4  <                                           !   _  Define User Field !
           5  <                                           !   x  Select Operator   !
           6  <                                           !                        !
           7  <                                           ! Mark to replace:       !
           8  <                                           !                        !
           9  <                                           +------------------------+
          
    
  5. Press Enter.

    The Joining Fields window appears.

  6. Select the joining fields operator.

     12:09                      ***** Super Natural *****                 1998-05-24
     SAMPLE3                     - Calculation Editor -                      SNZUL-C
                                                                                    
                                                  +---------Joining Field----------+
           1  < MY-START-DATE=MY-START-DAY        !                                !
           2  <                                   !   _  !  Joining Field Operator !
           3  <                                   !                                !
           4  <                                   ! Mark to replace: _             !
           5  <                                   !                                !
           6  <                                   +--------------------------------+
           7  <                                           ! Mark to replace:       !
           8  <                                           !                        !
           9  <                                           +------------------------+
          
    
  7. Press Enter.

    The joining fields operator valid at your site is entered at the end of the calculation statement.

  8. Issue the CONTINUE command. This command is allocated to PF10.

    The Field or Value window appears.

  9. Select Alphanumeric Constant.

     14:34                      ***** Super Natural *****                 1998-02-09
     SAMPLE3                     - Calculation Editor -                      SNZUL-C
                                                                                    
                                                 +---------Field or Value----------+
           1  < MY-START-DATE = MY-START-DAY !   !                                 !
           2  <                                  !   X  Alphanumeric Constant      !
           3  <                                  !   _  Hex Constant               !
           4  <                                  !   _  Define Dynamic Input Field !
           5  <                                  !   _  Invoke Field List          !
           6  <                                  !                                 !
           7  <                                  +---------------------------------+
             
    
  10. Press Enter.

  11. Enter a period (.) in the Alphanumeric Constant window which appears.

    A period (.) is entered in quotation marks (' ') at the end of the calculation statement.

    For further information on constants see Constants in Fields in the User's Guide.

  12. Type the rest of the calculation statement as shown in the following diagram using the joining fields operator valid at your site.

     14:06                      ***** Super Natural *****                 1998-02-09
     SAMPLE3                     - Calculation Editor -                      SNZUL-C
                                                                                    
                                                                                    
           1  < MY-START-DATE=MY-START-DAY!'.'!MY-START-MONTH!'.'!           >    1 
           2  < MY-START-YEAR                                                >    2 
           3  < MY-END-DATE=MY-END-DAY!'.'!MY-END-MONTH!'.'!                 >    3 
           4  < MY-END-YEAR                                                  >    4 
           5  <                                                              >    5 
           6  <                                                              >    6 
           7  <                                                              >    7 
           8  <                                                              >    8 
           9  <                                                              >    9 
          10  <                                                              >   10 
          11  <                                                              >   11 
          12  <                                                              >   12 
          13  <                                                              >   13 
          14  <                                                              >   14 
          15  <                                                              >   15 
                                                                                    
                                                                                    
     Command ===>                                                                   
     Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
           Help  Next  Exit  Field Check Flip  -     +           Cont  Run   Canc   
    

    For further information on joining fields and the joining fields operator, see Joining Fields in Editors in the User's Guide.

Start of instruction setTo Define Logical Conditions

The report requires that the text 'Too Late' be displayed in the Cruise/To/From column for cruises which start later than July 1st 1991.

  1. Issue the LOGIC command. You can abbreviate this command to LOG.

    The Logical Conditions Editor appears.

  2. Type "START-DATE GT 19910701" in the IF line.

    The field START-DATE now appears in the Field Name column in the Worksheet.

  3. Type "MY-START-DATE = 'TOO LATE'" in the THEN line.

  4. Tab to the Clause Type column (on the right).

  5. Overtype the E which is already there with a T to create a new THEN line.

  6. Press Enter.

  7. Type "MY-END-DATE = ' '" in the new THEN line.

    The Logical Conditions Editor now contains the following entries:

     16:11                      ***** Super Natural *****                 1998-02-09
     SAMPLE3                  - Logical Conditions Editor -                  SNZUL-L
                                                                                    
                                                                                    
       1 I    < START-DATE GT 19910701                                       > I 1  
       1 T    < MY-START-DATE = 'TOO LATE'                                   > T 1  
       1 T    < MY-END-DATE = ' '                                            > T 1  
              <                                                              > _    
              <                                                              > _    
              <                                                              > _    
              <                                                              > _    
              <                                                              > _    
              <                                                              > _    
              <                                                              > _    
              <                                                              > _    
              <                                                              > _    
              <                                                              > _    
              <                                                              > _    
              <                                                              > _    
                                                                                    
     Define logic conditions or use CONTINUE                                        
     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

  • Run the transaction as described in Step 6 of the section Sample 1 earlier in this section.

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

     16:16:05  CHARTER-YACHT-TYPE = 'ATLANTIC 29'                         1998-02-09
     ISAMPLE3                                                               4       
                                                                                    
     CRUISE-ID     START-HARBOR      DESTINATION-HARBOR   CRUISE                    
                                                            FROM                    
                                                             TO                     
     --------- -------------------- -------------------- --------                   
                                                                                    
            97 KIEL                 KIEL                 8.6.91                     
                                                         22.6.91                    
            98 KIEL                 KIEL                 22.6.91                    
                                                         29.6.91                    
            99 KIEL                 KIEL                 29.6.91                    
                                                         10.8.91                    
           100 KIEL                 KIEL                 TOO LATE                   
                                                                                    
           101 KIEL                 KIEL                 TOO LATE                   
                                                                                    
           102 KIEL                 KIEL                 TOO LATE                   
                                                                                    
                                                                                    
                                                                                    
     Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
                 Print Exit              Flip        +                       Canc