A sample 3270 server script

The 3270 server script in Figure 1 shows script language statements generated using Blueworx Voice Response. This server retrieves information about employees from a 3270 host application, based on their telephone extension.

The name of the captured 3270 screen that is accessed first is Main_menu, and the input field has been defined as Extension_field. The name of the next captured 3270 screen is Employee_list_screen, and the defined output field is Mgr_phone_number. A telephone extension number is passed to the script as a parameter and used as a search argument in Extension_field on the Main_menu screen. If the search is successful, the script returns the phone number of the employee’s manager.

It is assumed that the 3270 host application has been invoked at session initialization time and that the session begins at the initial Main_menu screen.

Figure 1. Example of a 3270 server script
INPUT    extension
OUTPUT   manager_phone;
EXCEPTION Detect_More_Script, Hit_Clear_Script;
  # Make sure that the initial menu is displayed.  If not, then
  # let the exception handler handle it.
  # "Main_menu" uniquely identifies the captured initial screen
  CHECK_SCREEN( Main_menu );
  # Put the contents of the "extension" parameter into the
  # Extension_field on the Main_menu screen, and press ENTER to
  # initiate the search.
  PUT_FIELD( Main_menu.Extension_field, extension );
  # Make sure that a record was found by verifying the screen.
  screen_name = QUERY_SCREEN( );
  CASE screen_name OF
  WHEN "Employee_list_screen":
     # put the contents of the employee field into the "name" variable.
     GET_FIELD( Employee_list_screen.Employee_name, name );
     IF name != "Mr. CEO" THEN
        # Now, press PF5 to find out who this person reports to.
        SEND_KEY( PF5 );
        # Was a manager found?
        CHECK_SCREEN( Reports_to_screen );
        # Once we have the manager, get the phone number and put it
        # in the output variable called "manager_phone".
        GET_FIELD( Reports_to_screen.Mgr_phone_number, manager_phone)
        # Return to the main menu by pressing PF12 twice, and
        # return the manager_extension to the caller of this script.
        SEND_KEY( PF12, PF12 );
        manager_phone = " ";  # the CEO does not have a manager
  WHEN "Employee_not_found_screen":
     manager_phone = " ";
     # Clear the screen
     CALL  Hit_Clear_Script;