Step 6 Extend the Details WebRoutine to add new employee skill

LANSA WAM

Step 6. Extend the Details WebRoutine to add new employee skill

WAM060 - Employee Maintenance using Advanced Weblets

In this step you will extend the WebRoutine Details to insert a new employee skill.

  • A New Skill push button on the Skills tab will refresh the grid with a blank first entry.
  • The SKILCODE will now be an input field in the list EMPSKLS and the hidden field SC will no longer be needed.
  • The SKILCODE column in the grid will be customized using a Dynamic select box.
  • The Dynamic select box will be populated with a list of skills from the table SKLTAB. A new method routine will build this list.
  • When the Skills Save button is processed, an employee skill will be inserted if the DATEACQR field is zero

1.  Change the definition of list EMPSKLS so that SKILCODE is input capable, removing the hidden field SC. Your code should look like the following:

Def_List Name(#empskls) Fields(#SKILCODE #GRADE #COMMENT #DATEACQ (#dateacqr *hidden) (#empno *hidden)) Type(*Working) Entrys(*max)

 

2.  Delete the definition of field SC and remove all code which refers to it.

3.  Define a Group_by SKL_LIST for fields SKILCODE, GRADE, COMMENT, DATEACQ, DATAECQR. This will be used to clear employee skills list fields before adding a blank entry for insert.

4.  Define a working list SKILLS containing fields SKILCODE, SKILDESC. This list will mapped for output to populate the skill code Dynamic select box.

     LANSA definition statements can be placed anywhere in your code. It is usual to place them at the top of the program code.

     Your new code should look like the following:

Group_By Name(#skl_list) Fields(#skilcode #grade #comment #dateacq #dateacqr)

Def_List Name(#skills) Fields(#skilcode #skildesc) Type(*Working) Entrys(*max)

 

5.  Add a new When clause to the Details WebRoutine, that will handle a request from the New Skill button to add a blank entry as the first entry in the employee skills list. This will allow insert of a new employee skill.

     The logic should be based on the following:

  • When = N
  • Change SKL_LIST to default values
  • Add entry to EMPSKLS after *Start
  • Message 'Complete new skill inthe first list entry'
  •      Your new code should look like the following:

    * add new top row to skills list
    When (= N)
    #skl_list := *default
    Add_Entry To_List(#empskls) After(*START)
    Message Msgtxt('Complete new skill in the first list entry')

     

    6.  When processing a list entry, a value of zero for Date Acquired (DATEACQR) means the entry is new.

         Add the following new logic to the CASE loop, for when STDRENTRY = S.

         New code is shown in red.

    When (= S)
    Selectlist Named(#empskls)
    If (#dateacqr *NE *zeroes)
    Update Fields(#empskls) In_File(pslskl) With_Key(#empno #skilcode) Val_Error(*next)
    Else
    Insert Fields(#empskls) To_File(pslskl) Val_Error(*next)

    Endif
    Endselect
    If_Status Is(*okay)
    Message Msgtxt('Skills for ' + #empno + ' were changed')
    Endif

     

    7.  Create a method routine BuildSkills to populate the skills list SKILLS.

    a.  Clear the list SKILLS

    b.  Select all records from file SKLTAB and add entries to list SKILLS

    c.  Position to the first entry

         Your code should look like the following:

    Mthroutine Name(BuildSkills)
    Clr_List Named(#skills)
    Select Fields(#skills) From_File(skltab)
    Add_Entry To_List(#skills)
    Endselect
    Get_Entry Number(1) From_List(#skills)
    Endroutine
     

    8.  Add an output web_map for the SKILLS list to the Details WebRoutine as JSON data. Your code should look like the following:

    Web_Map For(*output) Fields((#skills *JSON))

    9.  Invoke the BuildSkills method at the end of the Details WebRoutine. Your code should look like the following. New code is shown in red.

    Endcase

    #com_owner.BuildSkills

    Endroutine

     

    10. Compile your WAM.

    11. Open the Details WebRoutine in the Design view.

    12.  Select the Skills tab, and select the Grid weblet. On the Details tab use the Ellipsis button for the grid_col_properties value to open the Design of …. dialog. With SKILCODE field selected, select the Customize Column check box and then click OK to close the dialog.

    13. Drop a Dynamic select box into the Skill Code column. See the image below showing how the editor will highlight the column when the cursor is in the correct position.

         Adjust the width of the dropdown so that it can display skill description.

    14. Select the Dynamic select box and set up its properties as shown:

    Property

    Value

    listName

    SKILLS

    codeField

    SKILCODE

    captionField

    SKILDESC

     

    15. Add a push button with image weblet into the into the single row table below the grid. Set up the button properties as:

    Property Value

    caption

    New Skill

    left_relative_image

    icons/normal/16/contract_16.png

    on_click_wrname

    Details

    submitExtraFields

    Field Name: STDRENTRY

     

    Literal Value: N

     

         Adjust the width of the push button to display the caption as single line.    

         Remove the place holder characters from table cell.

    16. Select the Details tab page and then Save your changes. Your Skills tab page should look like the following:

    17. Retest your WAM. Select an employee and select the Skills tab. The Dynamic select box for skills should display the correct skill description in each row.

  • Click the New Skill button to add a new row at the top of the skills grid.
  • Select a skill and complete the grade, comment and date acquired column. Note that the date acquired is a six digit date in the format DD/MM/YY.
  • Click the Save button to process the skills in the EMPSKLS list and update or insert to the employee skills file.
  • Validation errors will display messages at the top of the page.