4 5 5 More Complex Example

LANSA Web Functions

4.5.5 More Complex Example

Imagine you have a more complex RDML function, which has three screens. It might look something like the following example. Using the re-entrant technique, you use a CASE statement and direct the processing to the correct part of the function based on the last screen processed.

FUNCTION   OPTIONS(*DIRECT *WEBEVENT)

...

CASE      OF_FIELD(#RENTRY)

WHEN      VALUE_IS('= 1')

CHANGEFIELD(#RENTRY) TO(2)

...

DISPLAY   FIELDS(...) USER_KEYS((01 SUBMIT))

WHEN      VALUE_IS('= 2')

CHANGE    FIELD(#RENTRY) TO(*NULL)

...

DISPLAY   FIELDS(...) USER_KEYS((01 RETURN))

OTHERWISE 

CHANGE    FIELD(#RENTRY) TO(1)

...

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

ENDCASE

In this example, the #RENTRY field is set in each branch of the CASE statement in order to control how the function will execute the next time it is called.