Step 1 Create iiiWAM040 iii Employee Update Enhanced

LANSA WAM

Step 1. Create iiiWAM040 - iii Employee Update - Enhanced

WAM040 - Add dropdown lists for Department and Section

In this step you will create iiiEmpUpdate_MK2 –Employee Update Enhanced, by copying WAM iiiEmpUpdate and then add logic to handle working lists for departments and sections.

1.  Select WAM iiiEmpUpdate on the Favorites/Last Opened tab and use the context menu to copy it.

2.  In the Create WAM dialog define your new WAM as – iiiEmpUpdate_MK2 – Employee Update  Enhanced.

3.  In the Active Designs dialog, leave the Begin and Details WebRoutine checked. You are creating a copy of iiiEmpUpdate including its layouts  (XSL).

4.  In the new WAM, iiiEmpUpdate_MK2, define working lists for department and section fields. Define the lists immediately following the Begin_com. Your code should look like the following:

Def_List Name(#deptdd) Fields(#deptment #deptdesc) Type(*Working) Entrys(*max)

Def_List Name(#sectdd) Fields(#section #secdesc) Type(*Working) Entrys(*max)

 

5.  Create a method routine BuildDD1 to clear and build the department list, DeptDD. This routine will require the following logic:

a.  Map for input a variable based on DEPTMENT. This will enable the routine to position the list to the current value of DEPTMENT.

b.  Clear the list DEPTDD

c.  Add entries to DEPTDD for all records in file DEPTAB – Department code table

d.  Reset DEPTMENT to the input variable value.

     Your completed code should look like the following:

Mthroutine Name(BuildDD1)
Define_Map For(*input) Class(#deptment) Name(#i_dept)
Clr_List Named(#deptdd)
Select Fields(#deptdd) From_File(deptab)
Add_Entry To_List(#deptdd)
Endselect
#deptment := #i_dept
Endroutine

 

6.  Create a method routine BuildDD2 to clear and build the sections list, SectDD. This routine will require the following logic:

a.  Map for input a variable based on DEPTMENT. This will enable the routine to rebuild the list of sections for  the current value of DEPTMENT.

b.  Map for input a variable based on SECTION. This will enable the routine to position the list to the current value of SECTION.

c.  Set DEPTMENT to the value of the input variable.

d.  Clear the list SectDD

e.  Add entries to the list from the SECTAB – Section code table, using DEPTMENT as key.

f.  If the passed variable for SECTION is not blank, set SECTION to the value of the input variable

     Your completed code should look like the following:

Mthroutine Name(BuildDD2)
Define_Map For(*input) Class(#deptment) Name(#i_dept)
Define_Map For(*input) Class(#section) Name(#i_sect)
#deptment := #i_dept
Clr_List Named(#sectdd)
Select Fields(#sectdd) From_File(sectab) With_Key(#deptment)
Add_Entry To_List(#sectdd)
Endselect
If (#i_sect *NE *blanks)
#section := #i_sect
Endif
Endroutine

7.  In this step you will make changes to your existing Details WebRoutine.

a.  Add the lists DeptDD and SectDD to the web_map with a JSON attribute. Your code should look like the following:

Web_Map For(*BOTH) Fields(#EMPDATA (#deptdd *json) (#sectdd *json))

 

b.  At the end of the Details WebRoutine invoke the new method routines, passing the value of DEPTMENT and SECTION as required. Your WebRoutine should look like the following. Unchanged code isn't shown.

WebRoutine Name(Details) Desc('Employee Details')
Web_Map For(*BOTH) Fields(#EMPDATA (#deptdd *json) (#sectdd *json))
. . . .
. . . .
Endcase
#com_owner.BuildDD1 I_Dept(#deptment)
#com_owner.BuildDD2 I_Dept(#deptment) I_Sect(#section)
Endroutine
 

8.  Compile your WAM.