4 2 How Does WEBEVENT Work

LANSA Web Functions

4.2 How Does WEBEVENT Work?

If you execute the standard FRENQ02 template to create a procedural header/detail style function, it generates a function with REQUEST and DISPLAY screens. The overall structure of the RDML in the function might appear as follows:

FUNCTION        OPTIONS(*DIRECT)

GROUP_BY        NAME(#HEADER)...

DEF_LIST        LIST(#LIST)...

BEGIN_LOOP

REQUEST         FIELDS(#DEPTMENT)...

FETCH              FIELDS(#HEADER)...

SELECT             FIELDS(#LIST)...

ADD_ENTRY       TO_LIST(#LIST) 

ENDSELECT

DISPLAY            FIELDS(#HEADER)... BROWSELIST(#LIST)

...

END_LOOP

To convert this to a WEBEVENT function, you might divide the single function into two functions: FUNC001 and FUNC002. FUNC001 will REQUEST the information to be located and FUNC002 will DISPLAY the data.

The function structure would appear something like the following:

FUNC001:

     FUNCTION OPTIONS(*DIRECT *WEBEVENT)

     CHANGE FIELD(#DEPTMENT) TO(*DEFAULT)

     REQUEST FIELDS(#DEPTMENT)...USER_KEYS((01 SEARCH))

FUNC002:

     FUNCTION OPTIONS(*DIRECT *WEBEVENT)

     GROUP_BYNAME(#HEADER)...

     DEFINELIST(#LIST)...

     FETCHFIELDS(#DEPTMENT)... NOT_FOUND(R01) 

     SELECTFIELDS(#LIST)...

     ADD_ENTRYTO_LIST(#LIST) 

     ENDSELECT

R01: DISPLAYFIELDS(#HEADER)... BROWSELIST(#LIST)

When the user executes the LANSA WEBEVENT function, FUNC001 will simply send the REQUEST for the search data and then terminate. For example, it might ask for a Department Code. Within FUNC001, a user key is nominated. This user key is called Search and is linked to FUNC002.

After the user enters the data, the Search button will be pressed. This button is a link to the FUNC002 function. FUNC002 is called and the input data from FUNC001 is passed from the browser to FUNC002. Because this is a WEBEVENT function, the variables from FUNC001 are passed to FUNC002 as if FUNC002 were being called from within FUNC001. This is automatically handled by LANSA.

FUNC002 will take the search parameters from FUNC001 and select the data from the files to build a browse list with the results. FUNC002 will display these results and then it will terminate. Like FUNC001, it can nominate user keys and linked functions. For example, it might link back to FUNC001 or it might link to a FUNC003 which provides details of a selected transaction.

If the user presses the Back button in the browser, they can return to the REQUEST screen in FUNC001 and enter new data. When the user presses the Search button, FUNC002 is simply called once again. The information is exchanged so that FUNC002 can execute properly.

Note: If you are using browse lists, the lists should match exactly in FUNC001 and FUNC002 so that the data is passed properly. For more details, refer to 4.6 Automatic Data Exchange.

For a detailed example of writing WEBEVENT functions, refer to 4.5 WEBEVENT Example.

 

WEB003 - Coding WEBEVENT Functions