Hey everyone, I’m stuck with a validation issue in SAP MIRO. I’m using BADI MRM_HEADER_CHECK to check if a reference number is already used. When it is, I show an error message. The problem is, this error locks all the fields on the screen. I need to keep two specific fields editable so the user can fix the issue.
I’ve tried several approaches:
Changing the message type to ‘S’ with the DISPLAY LIKE ‘E’ option, but that didn’t work
Checking the SY-DINNR value, which is 6000 at the breakpoint
Looping over the screen fields with LOOP AT SCREEN, but I couldn’t locate the desired ones
Here’s an example of my BADI code:
ASSIGN ('(SAPLMR1M)RBKPV') TO <fs_values>.
IF <fs_values>-REFNUM = existing_ref-num.
MESSAGE 'Reference already exists' TYPE 'E'.
ENDIF.
I cannot modify code outside my BADI, such as the PAI and PBO modules. Does anyone have suggestions on how to keep the two fields editable while still showing the error? Thanks!
I’ve encountered a similar issue in SAP MIRO, and I can share what worked for me. Instead of using a standard error message, consider implementing a custom message handling approach within your BADI. You can use the MESSAGE… RAISING statement to raise an exception, then catch it in a TRY…CATCH block. This allows you to control the message display and field behavior more precisely.
Here’s a rough outline of the approach:
TRY.
IF <fs_values>-REFNUM = existing_ref-num.
MESSAGE e000(your_msg_class) WITH 'Reference already exists' RAISING duplicate_reference.
ENDIF.
CATCH cx_sy_no_handler INTO DATA(lx_no_handler).
" Handle the exception and set field properties
ENDTRY.
By handling the exception, you can then use the SET SCREEN statement to modify the field properties for your specific fields, keeping them editable while locking others. This method gives you more control over the screen behavior while still maintaining the error state.