SAP IDOC_INBOUND_WRITE_TO_DB Function Module for Inbound IDoc with structure EDI_DD saved in database
IDOC_INBOUND_WRITE_TO_DB is a standard idoc inbound write to db SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Inbound IDoc with structure EDI_DD saved in database processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for idoc inbound write to db FM, simply by entering the name IDOC_INBOUND_WRITE_TO_DB into the relevant SAP transaction such as SE37 or SE38.
Function Group: EDIR
Program Name: SAPLEDIR
Main Program: SAPLEDIR
Appliation area: S
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function IDOC_INBOUND_WRITE_TO_DB pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'IDOC_INBOUND_WRITE_TO_DB'"Inbound IDoc with structure EDI_DD saved in database.
EXPORTING
* PI_STATUS_MESSAGE = "
* PI_DO_HANDLE_ERROR = 'X' "
* PI_NO_DEQUEUE = ' ' "
* PI_RETURN_DATA_FLAG = 'X' "
* PI_RFC_MULTI_CP = ' ' "SAP character set identification
IMPORTING
PE_IDOC_NUMBER = "IDoc number
PE_STATE_OF_PROCESSING = "Processing status
PE_INBOUND_PROCESS_DATA = "
CHANGING
PC_CONTROL_RECORD = "IDoc Control Record
TABLES
T_DATA_RECORDS = "IDoc Data Records
* T_LINKED_OBJECTS = "
EXCEPTIONS
IDOC_NOT_SAVED = 1
IMPORTING Parameters details for IDOC_INBOUND_WRITE_TO_DB
PI_STATUS_MESSAGE -
Data type: EDIDSOptional: Yes
Call by Reference: No ( called with pass by value option)
PI_DO_HANDLE_ERROR -
Data type: EDIGENERAL-ERRHANDLEDefault: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)
PI_NO_DEQUEUE -
Data type: EDI_HELP-UNLOCKDefault: ' '
Optional: Yes
Call by Reference: No ( called with pass by value option)
PI_RETURN_DATA_FLAG -
Data type: EDIGENERAL-RET_FLAGDefault: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)
PI_RFC_MULTI_CP - SAP character set identification
Data type: CPCODEPAGEDefault: ' '
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for IDOC_INBOUND_WRITE_TO_DB
PE_IDOC_NUMBER - IDoc number
Data type: EDIDC-DOCNUMOptional: No
Call by Reference: No ( called with pass by value option)
PE_STATE_OF_PROCESSING - Processing status
Data type: SY-SUBRCOptional: No
Call by Reference: No ( called with pass by value option)
PE_INBOUND_PROCESS_DATA -
Data type: TEDE2Optional: No
Call by Reference: No ( called with pass by value option)
CHANGING Parameters details for IDOC_INBOUND_WRITE_TO_DB
PC_CONTROL_RECORD - IDoc Control Record
Data type: EDIDCOptional: No
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for IDOC_INBOUND_WRITE_TO_DB
T_DATA_RECORDS - IDoc Data Records
Data type: EDIDDOptional: No
Call by Reference: No ( called with pass by value option)
T_LINKED_OBJECTS -
Data type: SWOTOBJIDOptional: Yes
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
IDOC_NOT_SAVED -
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for IDOC_INBOUND_WRITE_TO_DB Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_idoc_not_saved | TYPE STRING, " | |||
| lv_pe_idoc_number | TYPE EDIDC-DOCNUM, " | |||
| lt_t_data_records | TYPE STANDARD TABLE OF EDIDD, " | |||
| lv_pc_control_record | TYPE EDIDC, " | |||
| lv_pi_status_message | TYPE EDIDS, " | |||
| lt_t_linked_objects | TYPE STANDARD TABLE OF SWOTOBJID, " | |||
| lv_pi_do_handle_error | TYPE EDIGENERAL-ERRHANDLE, " 'X' | |||
| lv_pe_state_of_processing | TYPE SY-SUBRC, " | |||
| lv_pi_no_dequeue | TYPE EDI_HELP-UNLOCK, " ' ' | |||
| lv_pe_inbound_process_data | TYPE TEDE2, " | |||
| lv_pi_return_data_flag | TYPE EDIGENERAL-RET_FLAG, " 'X' | |||
| lv_pi_rfc_multi_cp | TYPE CPCODEPAGE. " ' ' |
|   CALL FUNCTION 'IDOC_INBOUND_WRITE_TO_DB' "Inbound IDoc with structure EDI_DD saved in database |
| EXPORTING | ||
| PI_STATUS_MESSAGE | = lv_pi_status_message | |
| PI_DO_HANDLE_ERROR | = lv_pi_do_handle_error | |
| PI_NO_DEQUEUE | = lv_pi_no_dequeue | |
| PI_RETURN_DATA_FLAG | = lv_pi_return_data_flag | |
| PI_RFC_MULTI_CP | = lv_pi_rfc_multi_cp | |
| IMPORTING | ||
| PE_IDOC_NUMBER | = lv_pe_idoc_number | |
| PE_STATE_OF_PROCESSING | = lv_pe_state_of_processing | |
| PE_INBOUND_PROCESS_DATA | = lv_pe_inbound_process_data | |
| CHANGING | ||
| PC_CONTROL_RECORD | = lv_pc_control_record | |
| TABLES | ||
| T_DATA_RECORDS | = lt_t_data_records | |
| T_LINKED_OBJECTS | = lt_t_linked_objects | |
| EXCEPTIONS | ||
| IDOC_NOT_SAVED = 1 | ||
| . " IDOC_INBOUND_WRITE_TO_DB | ||
ABAP code using 7.40 inline data declarations to call FM IDOC_INBOUND_WRITE_TO_DB
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| "SELECT single DOCNUM FROM EDIDC INTO @DATA(ld_pe_idoc_number). | ||||
| "SELECT single ERRHANDLE FROM EDIGENERAL INTO @DATA(ld_pi_do_handle_error). | ||||
| DATA(ld_pi_do_handle_error) | = 'X'. | |||
| "SELECT single SUBRC FROM SY INTO @DATA(ld_pe_state_of_processing). | ||||
| "SELECT single UNLOCK FROM EDI_HELP INTO @DATA(ld_pi_no_dequeue). | ||||
| DATA(ld_pi_no_dequeue) | = ' '. | |||
| "SELECT single RET_FLAG FROM EDIGENERAL INTO @DATA(ld_pi_return_data_flag). | ||||
| DATA(ld_pi_return_data_flag) | = 'X'. | |||
| DATA(ld_pi_rfc_multi_cp) | = ' '. | |||
Search for further information about these or an SAP related objects