Version 4.2.6 for Mainframes
 —  Editors  —

Invoking a Map with WRITE USING MAP

In this session, you will create and execute the example program PROG002 to test the effects of the WRITE USING MAP statements, which invoke the maps MAP002 and MAP003.

Start of instruction setTo create PROG002

  1. In the Command line of the Edit Map menu, enter the following:

    EDIT PROG002

    The program editor is invoked and the source code of PROG002 is displayed in the editing area.

  2. At the program editor's command prompt, enter the following:

    SAVE PROG002

    A copy of program PROG001 is saved as a source object under the name PROG002 in the current Natural library in the current system file.

  3. At the program editor's command prompt, enter the following:

    READ PROG002

    The source code of program PROG002 is displayed in the editing area of the program editor.

  4. Replace the DISPLAY statements with the source code lines shown in boldface below:

    PROG002:

    ** Example 'PROG002': Example program for the Map Tutorial              
    ************************************************************************
    DEFINE DATA LOCAL                                                       
    01 PERS-VIEW VIEW OF EMPLOYEES                                          
      02 NAME                                                               
      02 FIRST-NAME                                                         
      02 CITY                                                               
    *                                                                       
    01 #NAME (A20)                                                          
    01 #CITY (A20)                                                          
    END-DEFINE                                                              
    *                                                                       
    REPEAT                                                                  
      /*                                                                    
      INPUT USING MAP 'MAP001'                                              
      /*                                                                    
      IF #CITY NE ' ' AND #NAME NE ' '                                      
        FIND PERS-VIEW WITH NAME = #NAME AND CITY = #CITY                   
          IF NO RECORDS FOUND                                               
            REINPUT 'NO ONE BY THIS NAME LIVING IN THIS CITY.'
                    MARK *#CITY                         
          END-NOREC                                     
          /*                                            
          AT START OF DATA                              
            WRITE 'THE FOLLOWING EMPLOYEES LIVE IN' CITY
          END-START                                     
          WRITE USING MAP 'MAP003'                      
          /*                                            
        END-FIND                                        
      ELSE                                              
        IF #NAME NE ' '                                 
          FIND PERS-VIEW WITH NAME = #NAME              
            IF NO RECORDS FOUND                         
              REINPUT 'PLEASE TRY ANOTHER NAME.'        
            END-NOREC                                   
            /*                                          
            WRITE USING MAP 'MAP002'                    
            /*                                          
          END-FIND                                      
        END-IF
      END-IF  
      /*      
    END-REPEAT
    END
  5. When you have made all changes, at the program editor's prompt, enter the following:

    STOW

    The source of PROG002 is updated and a cataloged object is created and stored in the current Natural library in the current system file.

Start of instruction setTo execute PROG002

  1. At the program editor's command prompt, enter the following:

    PROG002
  2. The program starts to execute and MAP001 appears.

  3. Enter the name JONES and leave the second input field empty.

  4. Press ENTER.

    The list produced by the program now uses MAP002:

    Page      1                                                  07-12-14  17:12:41
                                                                                   
    NAME: JONES                VIRGINIA             CITY: TULSA                    
    NAME: JONES                MARSHA               CITY: MOBILE                   
    NAME: JONES                ROBERT               CITY: MILWAUKEE                
    NAME: JONES                LILLY                CITY: BEVERLEY HILLS           
    NAME: JONES                EDWARD               CITY: CAMDEN                   
    NAME: JONES                MARTHA               CITY: KALAMAZOO                
    NAME: JONES                LAUREL               CITY: BALTIMORE                
    NAME: JONES                KEVIN                CITY: DERBY                    
    NAME: JONES                GREGORY              CITY: NOTTINGHAM               
    
    
    
    
                                                                              
    
  5. Press ENTER.

    MAP001 appears.

  6. Leave the name JONES and enter the city DERBY.

  7. Press ENTER.

    The list produced by the program now uses MAP003:

    Page      2                                                  07-12-14  17:15:18
                                                                                   
    THE FOLLOWING EMPLOYEES LIVE IN DERBY                                          
    NAME: JONES                FIRST NAME:  KEVIN                                  
                                                                                   
                                                                                   
                                                                                   
                                                                                   
                                                                                   
    
  8. Press ENTER.

    MAP001 appears.

  9. In the first position of the NAME input field, enter a period (.).

    The Edit Map menu appears.

You have successfully completed this tutorial.

Top of page