Application Development and Automation 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: 
Read only

Posting IDOC within same system

Jay71
Participant
0 Likes
4,602

Hi all,

we have a requirement where i am asked to post journal entry in SAP.

i proposed to use BAPI but client wants only IDOC.

My doubt is within same system can i trigger an inbound IDOC.

if yes kindly let me know the configuration steps. I know the design is wrong but client is not ready for BAPI

Regards,

Jayaram

1 ACCEPTED SOLUTION
Read only

Subhankar
Active Contributor
0 Likes
3,068

Hi Jayaram,

yes can post IDOC in the same client. I had a development same to you.

1. First get the IDOC basic Type and Message Type. (Standard or Custom)

2. Create and process code to process the IDOC.

3. Use the FM IDOC_INBOUND_WRITE_TO_DB to create the inbound IDOC.

4. Use the FM IDOC_START_INBOUND to process the IDOC.

Sample code

form sub_create_idoc .

  • Local data declaration

data: l_wa_control_records type edidc, "#EC NEEDED

l_i_control_records type standard table of edidc initial size 0.

clear: wa_edidc,

v_process_data.

  • Populate control data

perform sub_pop_control_dat.

  • Populate master record for deal type in a deal group

perform sub_poulate_deal_type.

  • Populate the master record in sequence as basic type /IRM/AGRMNTS01

perform sub_populate_i_edidd_seq.

  • Create inbound idoc

call function 'IDOC_INBOUND_WRITE_TO_DB'

exporting

pi_do_handle_error = 'X'

pi_return_data_flag = ' '

importing

pe_idoc_number = wa_edidc-docnum

pe_inbound_process_data = v_process_data

tables

t_data_records = i_edidd

changing

pc_control_record = wa_edidc

exceptions

idoc_not_saved = 1

others = 2.

if sy-subrc = 0.

  • Commit work

commit work .

l_wa_control_records = wa_edidc.

wa_edidc-docrel = '640'.

wa_edidc-status = '64'.

append wa_edidc to l_i_control_records.

v_process_data-mandt = sy-mandt . "client

v_process_data-evcode = c_evcode. "Process code

v_process_data-edivr2 = '6'.

v_process_data-evenid = c_evenid. "even id

  • Process the inbound idoc

call function 'IDOC_START_INBOUND'

exporting

pi_inbound_process_data = v_process_data

pi_called_online = c_check "'X'

succ_show_flag = c_check "'X'

tables

t_control_records = l_i_control_records

exceptions

invalid_document_number = 1

error_before_call_application = 2

inbound_process_not_possible = 3

old_wf_start_failed = 4

wf_task_error = 5

serious_inbound_error = 6

others = 7.

Hi all,

we have a requirement where i am asked to post journal entry in SAP.

i proposed to use BAPI but client wants only IDOC.

My doubt is within same system can i trigger an inbound IDOC.

if yes kindly let me know the configuration steps. I know the design is wrong but client is not ready for BAPI

Regards,

Jayaram

10 REPLIES 10
Read only

ThomasZloch
Active Contributor
0 Likes
3,068

Yes it is possible, and not so unusual in my opinion. IDocs provide central monitoring of the data that is flying around.

You can find lots of information on the "how to" part, please search.

Thomas

Read only

0 Likes
3,068

hi ,

I have done scenarios where i sent idocs to other systems and received inbound idocs.

Now for this case i configured my inbound idoc in partner type LS with my process code.

now when i use master_idoc_distribute in my report and trigger the idoc i get error no 29 with status saying as recipent system is same logical system so stopped to avaid endless loop!

how do i solve this error. now if i take the same idoc and go to we19 and change the logical system and run it works fine.

regards,

jayaram

Read only

0 Likes
3,068

Hi,

Please see the instructions below

Steps : 

u2022Create a Dummy Logical System. 
u2022Goto T-Code SALE-> sending and Receiving Systems -> Logical Systems -> New entries.Enter SYSID_CLNT, but this one is Dummy so use the first 2 characters of the SYSID and prefix 'D' then underscore and then the Client number.

E.g.: If ERP_100 is the logical system of the R/3 then create ERD_100 as the dummy system.
u2022Create Port for the Original System, (ERP_100) 
u2022Goto WE21 and select Transactional Port and press the Create button. Name the Port as "SAP" contatenated with the SYSID in our example it would be SAPERP Select the appropriate version and enter the RFC dest of the system that you are working on in this case it will be 'ERP'.
u2022Create Partner Profile in partner type LS: 
u2022Receiver Side ( Outbound to ) :  In Partner type LS name ERD_100create the Outbound Parameters, give the Message type, Receiver Port same as the port we created in step 2. Enter the Basic type.

u2022Sender Side ( Inbound From ): In partner type LS name ERP_100 create the Inbound Parameters, give the appropriate message type and the process code.
u2022Now create the stand alone program to send the IDoc:   
u2022The program will at some point calls the MASTER_IDOC_DISTRIBUTE function module. When you pass the EDIDC structure it will be populated as follows:
i_edidc-mestyp = message type.
i_edidc-idoctp = basic type.
i_edidc-rcvprt = 'LS'.
Concatenate 'SAP' sy-sysid into l_port.  
i_edidc-RCVPOR = l_port.
i_edidc-rcvprn = 'ERD_000'.
CONCATENATE sy-sysid '_' sy-mandt
INTO l_sndprn.
i_edidc-SNDPRN = l_sndprn.
i_edidc-sndprt = 'LS'.
i_edidc-sndpor = l_port.
u2022Observe that the Sender port and the receiver port is the same, this does the trick. The outbound Idoc is sent on the port SAPERP with the Sender as ERP_100 and receiver as ERD_100 and then the Inbound Idoc is also sent to the same port SAPERP with the Sender as ERP_100 and receiver as ERD_100.

or follow the link:

[Idocs|https://wiki.sdn.sap.com/wiki/display/ABAP/ALE,IDOC]

KR Jaideep,

Read only

0 Likes
3,068

HI,

i am getting below error

"receiver of idoc is the same logical system"

i followed all the steps u mentioned...this is the same error i am getting from the first....

Regards,

Jayaram

Read only

0 Likes
3,068

just define a dummy "sender logical system", so that you don't get this error.

Read only

former_member203501
Active Contributor
0 Likes
3,068

Hi Jayaram,

you can send an idoc in one system but in different clients....lets say it is 100 and 110....for this you need to create logical systems, partnter profiles, ports, function modules...if it is custom....process codes...please search any documentation for IDOCs in SDN.....that is helpful for config.

Regards,

Venkat

Read only

Subhankar
Active Contributor
0 Likes
3,069

Hi Jayaram,

yes can post IDOC in the same client. I had a development same to you.

1. First get the IDOC basic Type and Message Type. (Standard or Custom)

2. Create and process code to process the IDOC.

3. Use the FM IDOC_INBOUND_WRITE_TO_DB to create the inbound IDOC.

4. Use the FM IDOC_START_INBOUND to process the IDOC.

Sample code

form sub_create_idoc .

  • Local data declaration

data: l_wa_control_records type edidc, "#EC NEEDED

l_i_control_records type standard table of edidc initial size 0.

clear: wa_edidc,

v_process_data.

  • Populate control data

perform sub_pop_control_dat.

  • Populate master record for deal type in a deal group

perform sub_poulate_deal_type.

  • Populate the master record in sequence as basic type /IRM/AGRMNTS01

perform sub_populate_i_edidd_seq.

  • Create inbound idoc

call function 'IDOC_INBOUND_WRITE_TO_DB'

exporting

pi_do_handle_error = 'X'

pi_return_data_flag = ' '

importing

pe_idoc_number = wa_edidc-docnum

pe_inbound_process_data = v_process_data

tables

t_data_records = i_edidd

changing

pc_control_record = wa_edidc

exceptions

idoc_not_saved = 1

others = 2.

if sy-subrc = 0.

  • Commit work

commit work .

l_wa_control_records = wa_edidc.

wa_edidc-docrel = '640'.

wa_edidc-status = '64'.

append wa_edidc to l_i_control_records.

v_process_data-mandt = sy-mandt . "client

v_process_data-evcode = c_evcode. "Process code

v_process_data-edivr2 = '6'.

v_process_data-evenid = c_evenid. "even id

  • Process the inbound idoc

call function 'IDOC_START_INBOUND'

exporting

pi_inbound_process_data = v_process_data

pi_called_online = c_check "'X'

succ_show_flag = c_check "'X'

tables

t_control_records = l_i_control_records

exceptions

invalid_document_number = 1

error_before_call_application = 2

inbound_process_not_possible = 3

old_wf_start_failed = 4

wf_task_error = 5

serious_inbound_error = 6

others = 7.

Read only

0 Likes
3,068

Hi subhakar,

thank you ur solution worked perfectly and i am able to complete my required

thanks,

jayaram

Read only

VivekG
Participant
0 Likes
3,068

Hi Subhankar,

I have a similar requirement of posting inbound idoc in the same client. I have some doubts.....Do we need to give idoc no ourselves while calling FM 'IDOC_INBOUND_WRITE_TO_DB'?? OR It'll be coming out of this FM??

Also do we need to create a partner profile with the process code passed above??Please paste the program properly. That will be of great help.

Please help...

Vivek Gupta

Read only

0 Likes
3,068

Hi Jayaram,

   I Have seen the query that you have been posted long back and hope you solved it too.

   I have got the same scenario now to upload the master data to the infotypes 1000, 1001, 1005 and 1005 using IDOC like yours.

   I had transfer between different clients in SAP but this is bit different for me, the CODE which is given by SUBAKAR is enough to complete this thing or not?

   My Qestion IS the Above mention two function module is enough for this or not? no need of process code for this right, simply loop the data records of the IDOC segment is enough for this or not?

   Please help Me .....