Skip to Content
Author's profile photo Former Member

Creating an Inbound IDOC in the same system.

The requirement is to create an Inbound IDOC in the same system. The input data can be from an input file with values in it.

We can create a custom program and call function module ‘IDOC_INBOUND_WRITE_TO_DB’ to create the Inbound IDOC.

1. Populating the Data Record:


  DATA:  lst_MATHEAD TYPE E1segment1,  
              lst_KEY   
TYPE E1segment2,

  DATA: li_idoc_data        TYPE STANDARD TABLE OF edidd,

             lw_idoc_data      TYPE edidd.

  CONSTANTS: lc_MATHEAD TYPE edilsegtyp  VALUE ‘HEAD’,
                        lc_KEY 
TYPE edilsegtyp  VALUE ‘KKEY’.

* Header
Populate lw_idoc_data-sdata.
lw_idoc_data-hlevel =  01.
lw_idoc_data-segnam = <Header Segment Name>.
APPEND lw_idoc_data TO li_idoc_data.
CLEAR : lw_idoc_data.

* Item
LOOP AT <Item Data>.
Populate lw_idoc_data-sdata.
lw_idoc_data-hlevel =  02.
lw_idoc_data-segnam = <Item Segment Name>.
APPEND lw_idoc_data TO li_idoc_data.
CLEAR : lw_idoc_data.
ENDLOOP.

2. Populating the Control Record:

Getting the name of the current logical system we are working in:

CALL FUNCTION ‘OWN_LOGICAL_SYSTEM_GET’
IMPORTING
OWN_LOGICAL_SYSTEM                   = lv_logsys
.
IF SY-SUBRC <> 0.
ENDIF.

lw_edidc-SNDPRN = lw_edidc-rcvprn = lv_logsys.

lw_edidc-status = ’64’.
lw_edidc-direct = ‘2’.     
lw_edidc-stdmes =
‘ARTMAS’.
lw_edidc-mestyp =
‘ARTMAS’.

SELECT  single sndprt
FROM edp21
INTO l_sndprt
WHERE sndprn = lv_logsys

AND   mestyp = ‘ARTMAS’

AND   mescod =
AND   mesfct = .

IF sy-subrc EQ 0.
rec_edidc-rcvprt = l_sndprt.
rec_edidc-sndprt = l_sndprt.
ENDIF.

lw_edidc-idoctp = ‘ARTMAS05’.

lw_edidc-rcvpor = maintained in Set
lw_edidc-sndpor  =  maintained in Set


3. Call the IDOC creating Function module:

DATA: lw_edids TYPE edids,

           lv_sysubrc  TYPE sysubrc.

CALL FUNCTION ‘IDOC_INBOUND_WRITE_TO_DB’
EXPORTING
pi_status_message      = lw_edids
IMPORTING
pe_state_of_processing = lv_sysubrc
TABLES
t_data_records         = li_idoc_data
CHANGING
pc_control_record      = lw_edidc
EXCEPTIONS
idoc_not_saved         =
1
OTHERS                 = 2.

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Did you ever manage this? I'm creating iDocs from a mix of bespoke tables and SAP standard and just want them to post into the same client. It either moans about the Partner Profiles or hangs because of a "No filters , No conversion , No version change ." issue

      Thanks in advance!

      Author's profile photo Jakub L
      Jakub L

      IDOC_INBOUND_WRITE_TO_DB only saves the IDOC in database. But it does not pass through application.

      If we want to process IDOC we have to call:
      1. DB_COMMIT
      2. IDOC_START_INBOUND

      just after IDOC_INBOUND_WRITE_TO_DB