=====================================================================
     Row Level EEPS in Forms
     =====================================================================
     PRODUCT: R:BASE            VERSION: 4.5
     =====================================================================
     AREA: FORMS                CATALOG: FORMS, REPORTS & LABELS
     =====================================================================
 
     In R:Base 4.5 users now have the ability to use row level Entry/exit 
     procedures in a form in addition to field level procedures. A row 
     level Entry/exit procedure is executed at one of four times:
 
     *       On entry into a row
     *       On exit from a row, before saving the row
     *       On exit from a row, after saving the row
     *       After leaving a section (table)
 
     Row level entry exit procedures allow for much greater flexibility of 
     data manipulation in forms. Instead of putting an EEP on every field 
     to make sure it executes no matter what field the user is on, you can 
     put a single EEP at the row level. Row level EEPs are assigned on the 
     Table settings screen. 
 
     A practical example of a row level EEP is illustrated using a modified 
     version of the form Tranform in the Concomp sample database. 
     Specifically, the form is updated to allow for greater control of 
     inventory management. A customer may order one or many products and 
     each product may exist in one or several locations. Each location 
     maintains a certain product inventory level. As a product is ordered 
     from a particular inventory location, an inventory count is taken. If 
     the inventory count falls below a preset level, the user is informed 
     that the reorder point has been reached for that product at its' 
     selected location. The user is then prompted if they'd like to see a 
     list of alternate locations for the selected product. If the user 
     chooses an alternate product location, the reorder point for the 
     alternate selection will also be checked. After the reorder point is 
     checked, the prodlocation table is updated to reflect the inventory 
     depletion. Keep in mind that if the user does not select an alternate 
     product location, the updates will still occur using the original 
     selections. This works because the product reorder point was set at a 
     relatively high level, 100 units. If a lower reorder point, for 
     example 20 units, is set the EEP may be altered so the user is forced 
     to choose an alternate product location to fill the order. All of the 
     form modifications were made to the Transdetail table in the form 
     Tranform. The located fields were reordered, new fields added and 
     expressions added.
 
     This figure illustrates the new format of the Transdetail tiers:
 
            vmodel        vlocation            vprod
              |              |                    |
              |              |                    |
      model: S  E location: S E Product Name: S               E
      Detail#: S E Quantity: SE price: S      E extprice: S       E
                |             |           |                  |
                |             |           |                  |
           Detailnum       vunits       vprice            vextprice
 
     Notice that Detailnum is the only column located, all the other fields 
     are variables. 
 
     Here is a list of the required variables. Keep in mind that most of 
     these are already defined in Tranform. The vprice and vprod 
     expressions are modified to change the WHERE clause comparison value 
     from model to vmodel. The expression model = .vmodel is added to save 
     the model value to the table.
 
     1. TEXT    :   vprod     =  prodname IN product WHERE model = .vmodel
     2. CURRENCY:   vprice    =  listprice IN product WHERE model = .vmodel
     3. CURRENCY:   vextprice =  (.vunits * .vprice)
     4. CURRENCY:   price     =  (.vprice)
     5. INTEGER :   units     =  (.vunits)
     6. INTEGER :   vtransid  =  transid
     7. TEXT    :   model     =  (.vmodel)
     
     A field level EEP is placed on the vmodel field to display a pop-up 
     menu for selection of a model and location. An EEP is used instead of 
     a double column pop-up because both values, the model and the 
     location, are needed. The pop-up defined in the field settings would 
     return only one value.
 
     *(model.eep -- choose model and location)
 
     CHOOSE vmod FROM #VALUES FOR +
     (model + ',' + ' ' + location) +
     FROM prodlocation AT 15 3 CLEAR
     IF vmod = '[Esc]' THEN
     RETURN
     ENDI
     -- Parse the model and location values 
     -- into separate variables
     SET VAR vmodel = +
     ((SSUB(.vmod,1)))
     SET VAR vlocation = +
     (LJS((SSUB(.vmod,2)),4))
     RECALC
     RETURN
     
     An EEP is already used in Tranform (tranupd.rmd on vunits  ) to 
     calculate the extended price and net amount and update the Transmaster 
     table. Leave this EEP on the form. The following EEP, update.eep, is 
     placed as a row level EEP in the Table setting screen to execute upon 
     exit from the row, but before the row is saved to the table. This 
     lets the user change the location the product is pulled from before 
     the row is saved.
 
     *(update.eep -- check product availability)
 
     --Get the inventory count for the selected product and location
 
     LABEL R_check
     SELECT onhand INTO VOnhand IVOnhand FROM prodlocation +
     WHERE model = .vmodel and location = .vlocation
     --Check to see if product has reached reorder point
     IF VOnhand <= 100 THEN
     PAUSE 2 USING 'Reorder point reached, hit any key to continue'
     DIALOG 'View list of alternate locations?' vresponse vend YES
     IF vresponse = 'YES' THEN
     CHOOSE valt FROM #VALUES FOR (model +','+' '+ location) +
     FROM prodlocation WHERE model = .vmodel
     SET VAR vloc = (SSUB(.valt,2))
     SET VAR vloc1 = (LJS(.vloc,5))
     SET VAR vlocation = .vloc1
     GOTO R_check
     ENDI
     ENDI
     SET MESS OFF
     --Update the prodlocation table to show proper inventory depletion
     WRITE 'Updating location table' AT 24 25
     UPDATE prodlocation SET onhand = (onhand - .vunits) WHERE +
     model = .vmodel and location = .vlocation
     SET MESS ON
     --Clear variable values and prepare to enter the next row of data.
     SET VAR vmodel    TEXT = ' ', +
     vlocation  TEXT = ' ', +
     vprod    TEXT = ' ', +
     vunits    INT = NULL, +
     vprice    CUR = NULL, +
     vextprice  CUR = NULL
     RECALC
     RETURN