cancel
Showing results for 
Search instead for 
Did you mean: 

Packspec BADI implementation error processing incorrect

0 Kudos

I have implemented the BAdi (/SCWM/EX_PS_CORE_VALIDATE) to validate that the quantity classification value is set in the packspec. The code for the same is as follows :-
IF iv_action = 'M' AND is_level-display_seq is NOT INITIAL and is_level-quancla IS INITIAL.
MESSAGE e013(/scdl/bo) WITH 'Quantity classification must exist for all levels' INTO DATA(lv_text).
cv_field_name = 'QUANCLA'.
RAISE error.
ENDIF.

The BAdI generates the error message correctly on the UI when the value is not set, however, once the error is raised, it becomes impossible to navigate anywhere on the screen (especially to the Warehouse tab where the value is to be set). This probably happens because now that a few values have been set, even an action as simple as navigating to another tab first calls the packspec validation methods and hits the BAdi, thereby continuously raising the error message on any further action.
Another interesting thing to note here is that if the Target Qty field is cleared and then even if the ‘ENTER’ key is simply pressed, the first level_change check produces no error, so the SET_PACKMAT_ATTRIBUTES method is called ahead, in which validation occurs again through the BAdi, but in the change method call, if sy-subrc <> 0, it is totally ignored (why?), so that there is no error message even if Qty Classification is not set, and the packspec can be saved (WHICH SHOULD NOT BE ALLOWED).

This is the corresponding validation call stack

Z_CL_AD_PS_IMP → METHOD /SCWM/IF_EX_PS_CORE_VALIDATE~LEVEL_VALIDATE
/SCWM/CL_PACKSPEC_LEVEL → METHOD BADI_VALIDATE

/SCWM/CL_PACKSPEC_LEVEL → METHOD VALIDATE
/SCWM/PPELIPAK_PAPAK_IMP → METHOD CHECK_DATA

/SCWM/CL_PPELIPAK_CNTL → METHOD PA_MAINT_INT

/SCWM/CL_PPELIPAK_CNTL → METHOD PA_MAINT

/SCWM/CL_PPELIPAK_CNTL → METHOD LEVEL_MAINT

/SCWM/CL_PACKSPEC_LEVEL → METHOD CHANGE

/SCWM/CL_PACKSPEC_MODEL → METHOD CHANGE_LEVEL

/SCWM/SAPLUI_PACKSPEC → /SCWM/LUI_PACKSPECI05 → FORM MAINT_LEVEL

/SCWM/SAPLUI_PACKSPEC → /SCWM/LUI_PACKSPECI05 → MODULE (PAI) MAINT_LEVEL

PAI MODULE → MAINT_LEVEL

So that raises a twofold question
1. Once the error is raised as expected, how does one enable the processing to continue without triggering the error message for every subsequent action?
2. If some field is blank, due to which the code reaches the “ignore” part of the code, how to ensure that the validation still occurs?

Any help will be really appreciated, since I think this has to do with the way the code itself was designed.

Accepted Solutions (0)

Answers (0)