How to show error message in the initialization of WDA HCMPF
Some times we have to show error message when the form is 1st displayed. In HCMPF its bit tricky to show the error message from IF_HRASR00GEN_SERVICE~INITIALIZE of generic service. It never displays the error message when form is displayed even after filling the message_handler with the error message. Once form is initialized, from the do_operations we can show the error all messages.
There are at least two different ways to show the error message in the initialization of form.
1. Restriction using BADI
From the process of hrasr_dt transaction, we can use the BADI to restrict and show the appropriate error message to end users.
After implementing the badi, users will see the screen like this:
2. By Implementing post exit for method INITIALIZE_FORM of class CL_HRASR00_PROCESS_EXECUTE
The error message thrown by the INITIALIZE method of generic service has to be passed to et_messages in the INITIALIZE_FORM method. Passing error message to et_messages will show the error messages on the WD From.
After implementing the post method, users will see the screen like this:
The advantage of this way is, the WDA HCMPF form will be displayed and it will show the error message.