Requirement: Business wants an inbound IDoc to be validated before processing to ensure that if certain conditions are not met, even though standard SAP approves, the IDoc should not be processed. The IDoc should be moved to a status which can be reviewed, changed and reprocessed.

1. Change the processing FM: Instead of using standard FM, create a new FM, configure it for the specific idoc and if all validations are passed, call standard FM within the custom FM. This is a simple way to protect accidental processing where only certain Basic Types needs to be addressed and standard FM is used for a number of different IDoc.

2. Modify the standard FM: Most of the standard FMs would provide enhancement spots to be used for custom code. Find a spot that comes earliest and ensures that no processing of data has started yet. If possible, put filters to ensure that unintended consequences can be avoided. Append a status message to the IDoc Status itab in global fields. This should stop any further processing and put the IDoc in the desired status.

Another possible solution is to find BADIs which can be implemented but usually, they occur after the fact which puts the requirement in jeopardy in case some processing or status change has to happen before updating the status.