I am implementing some checks, mainly authorization, on program start and want to abort the program if the user is not allowed to execute it. Explicit auth object assignment via SE93 does not fit for me because it lacks flexibility.
I tried to do it in LOAD-OF-PROGRAM
event in two ways:
- through
RETURN
statement - by throwing message with type
E
Both resulted to dump Illegal interruption of the event LOAD-OF-PROGRAM
, which is indeed corresponds to ABAP docu:
The event block must be fully executed, otherwise a runtime error occurs
This means that statements can be specified that exit the event block without returning to it.
I interpret the passage This means that statements can be specified that exit the event block without returning to it in the way that neither of the exit statements are allowed in this block. Is my understanding correct?
Now I do abortion/validation in INITIALIZATION block:
INITIALIZATION.
IF do_validate( ) = abap_false.
MESSAGE 'You are busted!' TYPE 'E'.
ENDIF
The problem is that my program has multiple selection screens and INITIALIZATION
block is triggered several times. Yes, of course I can differentiate them by screen number, but doing this in LOAD-OF-PROGRAM
seems more logical as it is executed only once per program.
The question: is there some way to achieve that in LOP event or other best practice and why?