IDoc Part 6: Inbound Process Code and Custom Function Module
Preview · a free account unlocks the full lesson
Build a custom inbound IDoc: own message type and basic type, the standard inbound function module interface (IDOC CONTRL, IDOC DATA, IDOC STATUS, RETURN VARIABLES, WORKFLOW RESULT), process code in WE42, assignment in WE57/BD51, and correct status handling.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 3 covered using SAP's own inbound function modules; when a partner sends data that SAP has no standard IDoc for, you need to build your own custom inbound function module instead.
A custom inbound function module follows SAP's fixed interface shape: IDOC_CONTRL, IDOC_DATA, and IDOC_STATUS on the way in, plus RETURN_VARIABLES and WORKFLOW_RESULT on the way out, along with INPUT_METHOD and MASS_PROCESSING controlling how it's called.
For every IDoc it processes, the function module appends exactly one status record — either 53 or 51 — and a corresponding entry in RETURN_VARIABLES, tagged "Processed_IDOCs" or "Error_IDOCs." Registration ties several pieces together: WE57 links the function module to a basic type and message type, BD51 declares its input type (0 for mass processing, 1 for single IDoc, which allows dialog), WE42 maps a process code to the function module, and WE20's partner profile references that process code.
One rule that must never be broken: the function module must never issue COMMIT WORK itself, since the IDoc framework handles the commit, and it must never halt with MESSAGE E — errors need to go into IDOC_STATUS instead.
The objects you need to create are: one or more segments in WE31 (for example Z1PROJHDR), a basic type in WE30 (ZPROJECT01), a message type in WE81 (ZPROJECT), and their assignment together in WE82. Then build the function module itself, say Z_IDOC_INPUT_ZPROJECT, copying its interface signature from an existing one like IDOC_INPUT_ORDERS.
Register it in WE57 against the basic type and message type, with direction 2 for inbound and type F for function module. In BD51, register its input type — 0 if mass processing should be allowed, 1 if it should process a single IDoc with dialog possible.
In WE42, create process code ZPRJ pointing to the function module, and in WE20, add inbound parameter ZPROJECT to the relevant partner profile, pointing to process code ZPRJ.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Interview questions on this topic
Related SAP topics
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
- WE57Assign Message Type to IDoc Type and Object Type
- IDOC_INPUT_ORDERSInbound IDoc Processing for Sales Orders
- WE19IDoc Test Tool
- BD87IDoc Reprocessing
- WE42Inbound IDoc process code assignment
- WE31IDoc Segment Editor
- WE02IDoc Display and Status Analysis
- BAPI_TRANSACTION_ROLLBACKBAPI_TRANSACTION_ROLLBACK Rollback Logic and Pitfalls
- WE30IDoc Type Editor for Basic Types and Extensions
- WE20WE20 Partner Profile Maintenance
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.