In this step, you will add the RDMLX code consisting of multiple WebRoutines to the newly created WAM.

  1. Immediately following the BEGIN_COM, insert the following RDMLX code to create a WebRoutine named WMdemo:
         Webroutine Name(WMdemo) Desc('WEB_MAP WR1')
    Endroutine
  2. All fields in the WebRoutine will be both incoming and outgoing, so they will be specified FOR(*BOTH). By default, all of the fields will be displayed as input fields. You could write the following WEB_MAP statement for the WebRoutine:
         WEB_MAP FOR(*BOTH) FIELDS(#EMPNO #GIVENAME #SURNAME #ADDRESS1 #POSTCODE (#STDRENTRY *HIDDEN))
     
         However, a GROUP_BY may be used in a WEB_MAP, so you will use the following code:
         Begin_Com Role(*EXTENDS #PRIM_WAM)
    Group_By Name(#Empdata) Fields(#empno #surname #givename #address1 #postcode)
    Webroutine Name(WMdemo) Desc('WEB_MAP WR1')
    Web_Map For(*BOTH) Fields(#empdata (#stdrentry *hidden))
    . . . WebRoutine

  3. Add the code to initialize the fields in the WebRoutine. Since EMPNO is both incoming to and outgoing from the WebRoutine, its value should never be lost. If EMPNO is blank, that means it is the first time entering the WebRoutine. You will retrieve a valid employee number by simply reading the first record from the Personnel Master.
         If Cond(#empno = *blanks)
    Select Fields(#empdata) From_File(pslmst)
    Leave
    Endselect
    Endif


    Note the following about this code:

    The SELECT loop with an unconditional LEAVE, will return values for the first record read. Typically you should not rely on values returned outside a SELECT loop because the returned values may be unpredictable. This technique has been used for the sake of simplicity. An alternative could be:
         Fetch Fields(#EMPDATA) From_file(PSLMST)
    With no key specified, the FETCH will return the first record in the file.

  4. A Read button will be required to read data from the Personnel Master file when an Employee Number has been entered on the web page. The read will do a FETCH on the Personnel Master, using EMPNO as the key and will be triggered by a button calling the WebRoutine with a STDRENTRY value of 'R'.
         If Cond(#stdrentry = R)
    Fetch Fields(#empdata) From_File(pslmst) With_Key(#empno)
    Endif

    Your finished WebRoutine should appear as follows:
         Group_By Name(#Empdata) Fields(#empno #surname #givename #address1 #postcode)
    Webroutine Name(WMdemo) Desc('WEB_MAP WR1')
    Web_Map For(*BOTH) Fields(#empdata (#stdrentry *hidden))
    If Cond(#empno = *blanks)
    Select Fields(#empdata) From_File(pslmst)
    Leave
    Endselect
    Endif
    If Cond(#stdrentry = R)
    Fetch Fields(#empdata) From_File(pslmst) With_Key(#empno)
    Endif
     
    EndroutineWebRoutine