2.4 Example of a Procedural Function

A simple header / detail function is a good example of a procedural function which requires the transaction server. If you execute the FRENQ02 template, you can create a procedural function which requests search information and then displays the detailed results.

The overall structure of the RDML in the function might appears 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

When the function encounters the REQUEST statement, a page is sent to client browser and the function must wait for a response from the user. The function is still active and the transaction server maintains the state of the function. When the user responds, the function continues until the DISPLAY statement when a page of search results is sent back to the client browser. The function is still active and the transaction server continues to maintain the state.

If the browser’s Back button is used to return to the REQUEST page, the transaction server will detect the sequence error when the REQUEST page is submitted to the Web Server again. The transaction server knows that the LANSA function is expecting input from the DISPLAY statement and not the REQUEST statement. The DISPLAY page will be sent to the client browser again with an error message.

With Web applications, you may wish to allow the user to go back and change the requested information using the browser’s Back button. WEBEVENT functions are designed specifically for this type of functionality.

 

WEB001 - Types of LANSA Web Functions