In this step, you will add RDMLX code, defining three WebRoutines.
Webroutine Name(NavMain) Desc('Navigation Home')
Endroutine
Webroutine Name(NavCall) Desc('Navigation CALL')
Endroutine
Webroutine Name(NavTrans) Desc('Navigation TRANSFER')
EndroutineWebRoutineWebRoutine
Def_List Name(#EMPLST) Fields(#EMPNO) Type(*WORKING) Entrys(*MAX)
Clr_List Named(#EMPLST)
Select Fields(#EMPNO) From_File(PSLMST)
Add_Entry To_List(#EMPLST)
Endselect
Group_By Name(#empdata) Fields(#surname #givename #address1 #address2 #address3 #postcode #phonehme #phonebus #deptment #section #salary #startdte #termdate)
Hint: Use the F4 Command Assistant to define the Group_By. Use the Fields in File tab to select fields from file PSLMST. |
WEB_MAP FOR(*BOTH) FIELDS(#EMPNO #EMPDATA (#EMPLST *PRIVATE))
Web_Map For(*both) Fields((#stdrentry *hidden))
Case Of_Field(#STDRENTRY)
When Value_Is('= A')
Fetch Fields(#EMPDATA) From_File(PSLMST) With_Key(#EMPNO)
Message Msgtxt("Logic executed within this WebRoutine.")
When Value_Is('= B')
Transfer Toroutine(NavTrans)
Message Msgtxt("This message will not be displayed.")
When Value_Is('= C')
Call Webroutine(NavCall)
Message Msgtxt("Back from the CALL.")
When Value_Is('= D')
Message Msgtxt("Back from the TRANSFER.")
When Value_Is('= E')
#EMPDATA := *DEFAULT
Endcase
WebRoutine
Define Field(#empnow) Reffld(#empno)
#empnow := #empno
Clr_List Named(#EMPLST)
Select Fields(#EMPNO) From_File(PSLMST)
Add_Entry To_List(#EMPLST)
Endselect
If (#empnow *NE *blanks)
#empno := #empnow
Endif
Your WAM at this stage should appear as follows:
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_WAM)
Web_Map For(*both) Fields((#stdrentry *hidden))
Group_By Name(#empdata) Fields(#surname #givename #address1 #address2 #address3 #postcode #phonehme #phonebus #deptment #section #salary #startdte #termdate)
Webroutine Name(NavMain) Desc('Navigation Home')
Web_Map For(*both) Fields(#empdata (#emplst *private))
Def_List Name(#EMPLST) Fields(#EMPNO) Type(*WORKING) Entrys(*MAX)
Case Of_Field(#STDRENTRY)
When Value_Is('= A')
Fetch Fields(#EMPDATA) From_File(PSLMST) With_Key(#EMPNO)
Message Msgtxt("Logic executed within this WebRoutine.")
When Value_Is('= B')
Transfer Toroutine(NavTrans)
Message Msgtxt("This message will not be displayed.")
When Value_Is('= C')
Call Webroutine(NavCall)
Message Msgtxt("Back from the CALL.")
When Value_Is('= D')
Message Msgtxt("Back from the TRANSFER.")
When Value_Is('= E')
#EMPDATA := *DEFAULT
Endcase
*
Define Field(#empnow) Reffld(#empno)
#empnow := #empno
Clr_List Named(#EMPLST)
Select Fields(#EMPNO) From_File(PSLMST)
Add_Entry To_List(#EMPLST)
Endselect
If (#empnow *NE *blanks)
#empno := #empnow
Endif
Endroutine
Webroutine Name(NavCall) Desc('Navigation CALL')
Endroutine
Webroutine Name(NavTrans) Desc('Navigation TRANSFER')
Endroutine
End_ComWebRoutineWebRoutineWebRoutineWebRoutine
Note: It is necessary to rebuild the list of employees (EMPLST) every time the NavMain WebRoutine is executed in order to populate the dropdown list of employee numbers. There are better ways to handle this, which will be covered in later exercises. |
Create the WEB_MAP for NavCall.
The WEB_MAP will be very similar to the one in NavMain:
Add the following WEB_MAP statements to the WebRoutine:
Web_Map For(*BOTH) Fields(#EMPNO)
Web_Map For(*OUTPUT) Fields(#EMPDATA)
Add the FETCH to NavCall.
Fetch Fields(#EMPDATA) From_File(PSLMST) With_Key(#EMPNO)
Your finished NavCall WebRoutine should appear as follows:
Webroutine Name(NavCall) Desc('Navigation CALL')
Web_Map For(*BOTH) Fields(#EMPNO)
Web_Map For(*OUTPUT) Fields(#EMPDATA)
Fetch Fields(#EMPDATA) From_File(PSLMST) With_Key(#EMPNO)
Endroutine Create the WEB_MAP for WebRoutine NavTrans. These WEB_MAPs will be identical to NavCall.
Web_Map For(*BOTH) Fields(#EMPNO)
Web_Map For(*OUTPUT) Fields(#EMPDATA)
Add the FETCH, set STDRENTRY to 'D' and TRANSFER back to NavMain.
Fetch Fields(#EMPDATA) From_File(PSLMST) With_Key(#EMPNO)
#STDRENTRY := 'D'
Transfer Toroutine(NavMain)
Your finished NavTrans WebRoutine should appear as follows:
Webroutine Name(NavTrans) Desc('Navigation TRANSFER')
Web_Map For(*BOTH) Fields(#EMPNO)
Web_Map For(*OUTPUT) Fields(#EMPDATA)
Fetch Fields(#EMPDATA) From_File(PSLMST) With_Key(#EMPNO)
#STDRENTRY := 'D'
Transfer Toroutine(NavMain)
EndroutineSave and compile the WAM.