WebEvent Function 2

LANSA

WebEvent Function 2
In these steps you will create a function like WebEvent function set_203b but instead of the buttons re-invoking the same function, the buttons will invoke a different function.


1.Using the process SET_203, create a function named SET203C, with description Basic Webevent C.

Specify New function type 2, Copy existing Process SET_203 Function SET203B.

2.Locate the line where the field #FUNC_FIND is defined. Change its default value to the literal SET203D.

DEFINE FIELD(#FUNC_FIND) TYPE(*CHAR) LENGTH(010) DESC('Function called when FIND button pressed') DEFAULT(SET203D)

By doing this the value of the function passed to the HandleEvent Java Script routine will be SET203D (a function we will create a few steps later). This means that when the user clicks on the Find button, they will invoke function SET203D instead of function SET203C.


3.Remove the field #FULLNAME from the #PANELDATA group of fields.

4.Delete the lines in the CASE statement evaluating #S_CLICKED for the value FIND.CLICK.

WHEN VALUE_IS('= FIND.CLICK')
EXECUTE SUBROUTINE(FIND_EVENT)
5.Delete the lines that comprise the FIND_EVENT subroutine.

SUBROUTINE NAME(FIND_EVENT)
FETCH FIELDS(#SURNAME #GIVENAME) FROM_FILE(PSLMST) WITH_KEY(#EMPNO) IF_STATUS IS(*OKAY)
USE BUILTIN(BCONCAT) WITH_ARGS(#SURNAME #GIVENAME) TO_GET(#FULLNAME)
MESSAGE MSGTXT('Employee found. Message issued by function SET203B')
ELSE
MESSAGE MSGTXT('Employee not found. Message issued by function SET203B')
ENDIF
ENDROUTINE
**********
6.Change the function names in the messages in subroutines SUBM_EVENT and INIT_EVENT:

SUBROUTINE NAME(SUBM_EVENT)
MESSAGE MSGTXT('Submit subroutine executed. Message issued by function SET203C')
CHANGE FIELD(#EMPNO) TO(*BLANK)
ENDROUTINE
7.Using the process SET_203, create a function named SET203D, with description Basic Webevent D.

Specify New function type 2, Copy existing Process SET_203 Function SET203B.

8.Delete the statements where the fields #PROC_FIND, #FUNC_FIND, #PROC_SUBM AND #FUNC_SUBM are defined:

DEFINE FIELD(#PROC_FIND) TYPE(*CHAR) LENGTH(010) DESC('Process called when FIND button pressed') DEFAULT(*PROCESS)
DEFINE FIELD(#FUNC_FIND) TYPE(*CHAR) LENGTH(010) DESC('Function called when FIND button pressed') DEFAULT(*FUNCTION)
DEFINE FIELD(#PROC_SUBM) TYPE(*CHAR) LENGTH(010) DESC('Proc. called when SUBMIT button pressed') DEFAULT(*PROCESS)
DEFINE FIELD(#FUNC_SUBM) TYPE(*CHAR) LENGTH(010) DESC('Func. called when SUBMIT button pressed') DEFAULT(*FUNCTION)

9.Add the definition of a field for the Back button:

********** Component Name and Page: S_203BACK
DEFINE FIELD(#S_203BACK) TYPE(*CHAR) LENGTH(001)
10.Add the definition of the fields that will have the value of the process and function to invoke when the Back buttons is clicked (again, refer to the definition of the web component S_203BACK):

**********
DEFINE FIELD(#PROC_BACK) TYPE(*CHAR) LENGTH(010) DESC('Process called when BACK button pressed') DEFAULT('*PROCESS')
DEFINE FIELD(#FUNC_BACK) TYPE(*CHAR) LENGTH(010) DESC('Function called when BACK button pressed') DEFAULT(SET203C)
**********


Note the default value is function SET203C.

11.Remove the fields #PROC_FIND, #FUNC_FIND, #PROC_SUBM AND #FUNC_SUBM from the #PANELDATA group of fields and add #PROC_BACK and #FUNC_BACK and #S_203BACK all as hidden fields:

GROUP_BY NAME(#PANELDATA) FIELDS((#EMPNO *OUTPUT) (#FULLNAME *OUTPUT *NOID) (#S_CLICKED *HIDDEN) (#S_203BACK *HIDDEN) (#PROC_BACK *HIDDEN) (#FUNC_BACK *HIDDEN))

12.Delete the entire CASE statement and add the following subroutine call (make sure you add it before the REQUEST command):

********** Mainline
EXECUTE SUBROUTINE(FIND_EVENT)
**********

Remove the INIT_EVENT subroutine
Remove the SUBM_EVENT subroutine


13.In the FIND_EVENT subroutine, change the name of the function in both messages:

MESSAGE MSGTXT('Employee found. Message issued by function SET203D')
MESSAGE MSGTXT('Employee not found. Message issued by function SET203D’)
14Compile functions SET203C and SET203D. Execute function SET203C using your browser.