Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of Inbound Idoc for the Outbound Idoc in same client

Former Member
0 Kudos

Hi,

My requirement:

Whenver an PO is created an Outbound IDOC is generated in system ABC with client 100.I want to pass this IDOC data to create an Inbound Idoc for Sales Order(SO) in the same client.

It would be helpful if anyone can answer on how to Transfer the Outbound Idoc after it crosses the port.

I found there is a field for function module in WE21,can this be used to get the requirement done.

Please suggest.

Regards,

Amar

1 REPLY 1

Former Member
0 Kudos

Example of a program that create and post an inbound idoc....maybe that will help you:


report  zzinbound_idoc.

data: g_idoc_control_record like edi_dc40 occurs 0 with header line.
data: g_edidd like edi_dd40 occurs 0 with header line.
data: g_e1bpache09 like e1bpache09.

parameter: mode type c default 'A'.

refresh: g_idoc_control_record, g_edidd.
clear:   g_idoc_control_record, g_edidd.

*-----------------------*
*-Build Control Record -*
*-----------------------*
g_idoc_control_record-mestyp  = 'ACC_DOCUMENT'.   "Message type
g_idoc_control_record-idoctyp = 'ACC_DOCUMENT03'. "IDOC type
g_idoc_control_record-direct  = '2'.              "Direction

* Receiver
case sy-sysid.
  when 'DE2'.
    g_idoc_control_record-rcvpor = 'SAPDE2'.     "Port
    g_idoc_control_record-rcvprn = 'IDOCLEGACY'. "Partner number
endcase.

g_idoc_control_record-rcvprt = 'LS'.             "Partner type
g_idoc_control_record-rcvpfc = ''.               "Partner function

* Sender
g_idoc_control_record-sndpor = 'A000000002'.      "tRFC Port

case sy-sysid.
  when 'DE2'.
    g_idoc_control_record-sndprn = 'IDOCLEGACY'. "Partner number
endcase.

g_idoc_control_record-sndprt = 'LS'.             "Partner type
g_idoc_control_record-sndpfc = ''.               "Partner function
g_idoc_control_record-refmes = 'Customer clearing'.
append g_idoc_control_record.


*----------------------*
*-Build Idoc Segments -*
*----------------------*
*---E1KOMG
clear g_edidd.
clear g_e1bpache09.

g_edidd-segnam               = 'E1BPACHE09'.
g_edidd-segnum               = 1.

move g_e1bpache09 to g_edidd-sdata.
append g_edidd.



*--------------*
*-Create idoc -*
*--------------*

*-Syncronous
if mode = 'S'.
  call function 'IDOC_INBOUND_SINGLE'
    exporting
      pi_idoc_control_rec_40              = g_idoc_control_record
*     PI_DO_COMMIT                        = 'X'
*   IMPORTING
*     PE_IDOC_NUMBER                      =
*     PE_ERROR_PRIOR_TO_APPLICATION       =
    tables
      pt_idoc_data_records_40             = g_edidd
    exceptions
      idoc_not_saved                      = 1
      others                              = 2.

  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

*-Asynchronus
else.
  call function 'IDOC_INBOUND_ASYNCHRONOUS'
    in background task as separate unit
    tables
      idoc_control_rec_40 = g_idoc_control_record
      idoc_data_rec_40    = g_edidd.

  commit work.

endif.

write: / 'Well done!'.