Preprocessing Rules
This concept involves application of processing rules
in layouts that, by design, affect the initial screen
displayed to the user.
    First, we define our data in the program that utilizes this rather esoteric approach as:

0010 DEFINE DATA LOCAL
0020 1 EMPLOYEES VIEW OF EMPLOYEES
0030   2 PERSONNEL-ID             
0040   2 NAME                     
0050   2 FIRST-NAME               
0060   2 M-NAME                   
0070   2 CITY                     
0080   2 ZIP                      
0090   2 COUNTRY                  
0100   2 DEPT                     
0110   2 JOB-TITLE                
0120 1 #GENERAL(A25)              
0130 1 #PID(A8)                   
0140 1 #NAME(A20)                 
0150 1 #FOUND-CV(C)               
0160 END-DEFINE

Next we'll build the layout.

 Ob _                                    Ob D CLS ATT  DEL    CLS ATT  DEL      
 .                                       .     T  D    Blnk    T  I    ?        
 .                                       .     A  D    _       A  I    )        
 .                                       .     A  N    ¨       M  D    &        
 .                                       .     M  I    :       O  D    +        
 .                                       .     O  I    (                        
 .                                       .                                      
 001   --010---+----+----+---030---+----+----+---050---+----+----+---070---+----
 +XXXXXXXX                Testing a Preprocessing Rule                +XXXXXXXX 
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       Help  Mset  Exit  Test  Edit  --    -     +     Full  <     >     Let                                           

Nothing unusual here. That's *DATX on the left and *TIMX on the right.
  Return to the Edit Map screen and type "D" in the code field.   On the Field and Variable Definitions screen we're going to define fields that are going to be used to pass information between the program through this layout and on into the map using the layout: a parameter data.   Press PF9.

 12:34:56           Field and Variable Definitions - Summary            02-04-01
                                                                                
 Cmd Field Name (Truncated)                             Mod Format Ar Ru Lin Col
 ___ *DATX_____________________________________________ S   D              1   2
 ___ *TIMX_____________________________________________ S   T              1  71
                                                                                
                                                                                
                                                                                
 +--------------------------- PARAMETER DEFINITIONS ---------------------------+
 | Cmd Name of Parameter (Truncated)                                 Format Ar |
 | __  #FOUND-CV___________________________________________________  C____     |
 | __  #GENERAL____________________________________________________  A25__     |
 | __  #NAME_______________________________________________________  A20__     |
 | __  #PID________________________________________________________  A8___     |
 | __  ____________________________________________________________  _____     |
 | __  ____________________________________________________________  _____     |
 | __  ____________________________________________________________  _____     |
 | __  ____________________________________________________________  _____     |
 | __  ____________________________________________________________  _____     |
 |                                                                             |
 +-----------------------------------------------------------------------------+
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       Help  Mset  Exit              --                Parm  Local       Let       

#FOUND-CV will be used to modify the attributes on the main map. #PID will transfer the personnel ID from the program to the main map.
  #NAME will be set by the preprocessing rule here in the layout. #GENERAL isn't doing anything.   Invoke the PF Key processing rule editor (you're still in the Map Editor building the layout) by typing "..p" in the left hand margin   This processing rule verifies whether or not a record exists for the specified ID. When there is a record, the name components are compressed into the parameter variable to be passed to the main screen as well as setting the control variable of the main screen.   On the other hand, when no record exists, a "message" is inserted into the parameter variable and because the control variable is unchanged, the user will be able to type information into the primary fields.   Under normal circumstances, the IF NO clause permits execution of the loop once after its internal statements are executed. Before that, all fields are set to empty status. If our program were coded without ESCAPE IMMEDIATE, the compress would execute putting empty values in the #NAME overlaying the "message" sitting there. ESCAPE IMMEDIATE branches to the END-FIND without any further processing thus bypassing the urge of the IF NO to process lines 0200 and 0210.

Rule ________________________________       *PF-KEY RULE                       
>                                      > + Rank 0    S 23   L 1     Struct Mode
TOP    ....+....10...+....+....+....30...+....+....+....50...+....+....+....70..
  0010 DEFINE DATA LOCAL                                                       
  0020 1 EMPLOYEES VIEW OF EMPLOYEES                                           
  0030 2 PERSONNEL-ID                                                          
  0040 2 NAME                                                                  
  0050 2 FIRST-NAME                                                            
  0060 2 M-NAME                                                                
  0070 2 CITY                                                                  
  0080 2 ZIP                                                                   
  0090 2 COUNTRY                                                               
  0100 2 DEPT                                                                  
  0110 2 JOB-TITLE                                                             
  0120 END-DEFINE                                                              
  0130 RESET #FOUND-CV                                                         
  0140 IF #NAME = ' '                             /* And it always is.
  0150 FIND EMPLOYEES WITH PERSONNEL-ID = #PID    /* Use the ID to find the
  0160 IF NO RECORDS FOUND                        /* record. If its not there
  0170 MOVE 'No Record Found' TO #NAME            /* set the variable and get
  0180 ESCAPE BOTTOM IMMEDIATE                    /* out. If a record is found
  0190 END-NOREC                                  /* then compress the name
  0200 COMPRESS FIRST-NAME M-NAME NAME INTO #NAME /* values into the variable
  0210 MOVE (AD=P) TO #FOUND-CV                   /* and set the control variable.
  0220 END-FIND                                   /* ESCAPE IMMEDIATE bypasses
  0230 END-IF                                     /* normal IF NO processing.
Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
      Help  Mset  Exit  Test        --    -     +     Split Sc=         Let    

STOW this map layout before generating the main screen.

 12:34:56               Define Map Settings for MAP                     02-04-01
                                                                               
 Delimiters           Format                         Context                   
 -----------------    ---------------------------    --------------------------
 Cls Att CD  Del      Page Size ...... 23            Device Check .... ________
  T   D      BLANK    Line Size ...... 79            WRITE Statement   _       
  T   I      ?        Column Shift ... 0 (0/1)       INPUT Statement   X       
  A   D      _        Layout ......... DDHMAP98     Help  ____________________
  A   I      )         dynamic ....... Y (Y/N)        as field default N (Y/N) 
  A   N      ¨        Zero Print ..... N (Y/N)                                 
  M   D      &        Case Default ... UC (UC/LC)                              
  M   I      :        Manual Skip .... N (Y/N)       Automatic Rule Rank  1    
  O   D      +        Decimal Char ... .             Profile Name .... SYSPROF 
  O   I      (        Standard Keys .. N (Y/N)                                 
                      Justification .. L (L/R)       Filler Characters         
                      Print Mode ..... __            ------------------------  
                                                     Optional, Partial ....    
                      Control Var .... ________      Required, Partial ....    
                                                     Optional, Complete ...    
                                                     Required, Complete ...    
                                                                               
Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
      Help        Exit                                                  Let    

Type the layout name into the LAYOUT parameter and mark the DYNAMIC parameter "Y". This keeps the preprocessing rule code out of the current map.

 Fld #PID                                                              Fmt A8   
 -------------------------------------------------------------------------------
 AD= MYT_______     ZP=         SG=        HE= _____________________   Rls 0    
 AL= _____          CD= __      CV= #FOUND-CV_______________________   Mod User 
 PM= __                         DY= ______________________________              
 EM= _______________________________________________________________            
                                                                                
 001   --010---+----+----+---030---+----+----+---050---+----+----+---070---+----
 +XXXXXXXX                Testing a Preprocessing Rule                +XXXXXXXX 
                                  Main Program                                  
  General Field ..+XXXXXXXXXXXXXXXXXXXXXXXXX                                    
                                                                                
  Personnel ID ....EXXXXXXX                                                     
  Name ...........&XXXXXXXXXXXXXXXXXXXX                                         
  City ...........:XXXXXXXXXXXXXXXXXXXX                                         
  Postal Code ....:XXXXXXXXXX                                                   
  Country ........:XXX                                                          
  Department .....:XXXXXX                                                       
  Job Title ......:XXXXXXXXXXXXXXXXXXXXXXXXX                                    
                                                                                
                                                                                
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       HELP  Mset  Exit  <---  --->  --    -     +           <     >     Let    

Load up the fields from the program using the Observation Window. Then attach the #FOUND-CV control variable to the #PID and #NAME variables.   STOW this map and bring bring the original program back into the editor.

0010 DEFINE DATA LOCAL            
0020 1 EMPLOYEES VIEW OF EMPLOYEES
0030   2 PERSONNEL-ID             
0040   2 NAME                     
0050   2 FIRST-NAME               
0060   2 M-NAME                   
0070   2 CITY                     
0080   2 ZIP                      
0090   2 COUNTRY                  
0100   2 DEPT                     
0110   2 JOB-TITLE                
0120 1 #GENERAL(A25)              
0130 1 #PID(A8)                   
0140 1 #NAME(A20)                 
0150 1 #FOUND-CV(C)               
0160 END-DEFINE                   
0170 INPUT #PID                   
0180 INPUT USING MAP 'DDHMAP99'
0190 END

All we need to do now is ask for a personnel ID and invoke the main screen. As a byproduct of the INPUT USING MAP "DDHMAP99" the layout is executed first and will fill in the #NAME variable with either a compressed name value or a message indicating that no data exists. Here's our test. We'll first enter a known ID and then test with a non-existent ID.

 
#PID 20000700   
 
 

Type 20000700 and press the ENTER key.

         
  02-04-01                Testing a Preprocessing Rule                 12:34:56 
                                  Main Program                                  
  General Field ..                                                              
                                                                                
  Personnel ID ... 20000700                                                     
  Name ........... JENNIFER G. HALL                                             
  City ........... _                                                            
  Postal Code ....                                                              
  Country ........                                                              
  Department .....                                                              
  Job Title ......                                                              
                                                                                
                                                                                
                                                                                
                                                                                

 

Because the number typed at the first prompt was current, the main screen displays the two values as protected.   The cursor is positioned at the first input field.   The values and the temporary protection were applied as a result of the preprocessing rule coded in the layout. Without the preprocessing rule the user would have to enter a value and press the ENTER key and press the ENTER key again to get back to the screen with valid (or invalid) data.   Here's the test with invalid data:

 
#PID 20000701   
 
 

Type 20000701 and press the ENTER key.

 02-04-01                Testing a Preprocessing Rule                 12:34:56 
                                  Main Program                                  
  General Field ..                                                              
                                                                                
  Personnel ID ... 20000701                                                     
  Name ........... No Record Found                                              
  City ...........                                                              
  Postal Code ....                                                              
  Country ........                                                              
  Department .....                                                              
  Job Title ......                                                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                

 

Since no record exists, the control variable was not
set to temporary protect so that the cursor is
positioned in the first input field, the ID.   Another processing rule may have to be generated to
handle this situation in lieu of passing control back
to the program where verification would have to be
executed.   Got a better idea? Better approach? Give us a shout!