Frequently, there are situations where one would like to perform actions prior to switching a hierarchy menu. Such actions may include e.g. the testing of conditions, the display of messages or the specific execution of processes. For example in case of entry reports, it is purposeful to provide the user the opportunity to save his settings prior to the switch.
The hierarchy menu events ("After update", "Upon click" and "Upon switch") take effect too late for this purpose. The switch itself can then no longer be prevented.
The function as problem solution
One solution is the command MENUHIERARCHYSHOWPOPUP ( [OBJ100] )
[OBJ100] = Hierarchy Menu
This may be placed over the actual hierarchy menu e.g. in a transparent individual field. Upon execution of the command, the hierarchy menu behaves as usual and the user does not notice any difference.
In the example set forth below, the user is merely warned prior to the switch and is given the possibility to cancel this switch. It would also be conceivable, however, to insert an option to directly save the data here.
An example for the command would be:
[<data_saved>] = 0 ;
QUESTION ( "Your data will be lost upon switch. Do you really want to change the year? "; "Change Year"; 0 ) = 0 ;
EMPTY ( ); //Answer: Cancel
MENUHIERARCHYSHOWPOPUP ( [OBJ100] ) // Answer: Yes
MENUHIERARCHYSHOWPOPUP ( [OB100] )
CANCEL ( )