How to allow editing specific fields after error message in SAP MIRO?

I’m working on a validation in SAP MIRO using the BADI MRM_HEADER_CHECK. When the “reference” field is a duplicate, I show an error message. The problem is, this error locks all fields, preventing the user from fixing the issue.

I need to keep the error message type as ‘E’ to lock most fields, but I want to let the user edit two specific fields (marked in red on the screen).

I’ve tried a few things:

  • Checking SY-DINNR (it’s 6000 at the breakpoint)
  • Using LOOP AT SCREEN (can’t see the field names I need)
  • MESSAGE with ‘S’ type displayed as ‘E’ (didn’t work)

I can’t change code outside my BADI. Here’s what I have so far:

ASSIGN ('(SAPLMR1M)RBKPV') TO <data_container>.
IF <data_container>-REFERENCE_NUM = existing_reference-number.
  MESSAGE error_text TYPE 'E'.
ENDIF.

Any suggestions on how to keep those two fields editable after the error? Thanks!

As someone who’s worked extensively with SAP MIRO and custom validations, I can share a workaround that might help. Instead of using MESSAGE TYPE ‘E’, try using SET CURSOR FIELD and DISPLAY to achieve a similar effect while keeping specific fields editable.

Here’s an approach I’ve used successfully:

DATA: lv_field TYPE string.

IF <data_container>-REFERENCE_NUM = existing_reference-number.
  lv_field = 'RBKPV-REFERENCE_NUM'.
  SET CURSOR FIELD lv_field.
  MESSAGE error_text TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.

This method sets the cursor to the problematic field and displays an error message without locking all fields. It maintains the visual impact of an error while allowing edits to your specified fields.

Remember to test thoroughly, as this approach can behave slightly differently across various SAP versions and customizations. If you need further assistance, let me know the specific field names you’re trying to keep editable.

Having dealt with similar issues in SAP MIRO, I can suggest an alternative approach. Instead of using the standard MESSAGE statement, consider implementing a custom function module that allows for more granular control over field editability. This method involves creating a function module that interacts with the screen fields directly, setting specific ones as editable while keeping others locked.

Here’s a high-level overview of the steps:

  1. Create a custom function module.
  2. Use CALL SCREEN to display your error message.
  3. In the PBO of this screen, set the desired fields as editable using LOOP AT SCREEN.
  4. Handle the user’s response in the PAI.

This approach requires more initial setup but offers greater flexibility in managing field editability after error messages. It’s particularly useful when you need to maintain strict control over which fields remain editable in error scenarios.