Skip to Content

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.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply