Custom idoc

of 25 /25
ALE-IDOC Scenario using Custom IDOC By SachinDabhade Aim: Transfer the data from one system to another using user customized IDOC. Sender System: Server: 172.25.8.185 Client: 200 Data from Z table: zsach1 ReceiverSystem: Server: 172.25.9.198 Client: 800 Data from Z table: zsach1 Data is fetched from Z table on the sender system and inserted it in the Z table of Receiver system using ALE/IDOC. Settings on the Sender End Table Creation T – Code SE11. The table contains data that is to be sent to Receiver. ALE Configuration T-Code – SALE

description

custome idoc

Transcript of Custom idoc

Page 1: Custom idoc

ALE-IDOC Scenario using Custom IDOC

By SachinDabhade

Aim: Transfer the data from one system to another using user customized IDOC.

Sender System: 

Server: 172.25.8.185

Client: 200

Data from Z table: zsach1 

ReceiverSystem:

Server: 172.25.9.198

Client: 800

Data from Z table: zsach1 

Data is fetched from Z table on the sender system and inserted it in the Z table of Receiver system using ALE/IDOC. 

Settings on the Sender End 

Table Creation T – Code SE11. The table contains data that is to be sent to Receiver. 

ALE Configuration 

T-Code – SALE 

 

Defining Logical System 

Page 2: Custom idoc

 

200 is our sender

800 is our receiver 

Assigning Client to Logical System 

 

200 is our sender

800 is our receiver 

Defining Target System for RFC Calls (Tcode – SM59)

Page 3: Custom idoc

 

Click on R/3 Connections and then Create TAB 

Step 1 

 

Step 2 

Page 4: Custom idoc

 

Save and test the connection. 

Defining Port 

The sender system is connected to the receiver system through this Port.

Continued...

ALE-IDOC Scenario using Custom IDOC

...Previous

Defining Partner Profiles 

Page 5: Custom idoc

 

The partner for client 200(Sender) is the client 800 (Receiver) 

Since this is a sender we have to define only Outbound Parameters in this case.

Here you can see the Message type is Z message type.  

2.   Maintaining Distribution Model ( TCode BD64 ) 

Page 6: Custom idoc

 

Create new Distribution Model 

Page 7: Custom idoc

Add Message Type 

 

Page 8: Custom idoc

 

Now Distribute this Model View  

 

Distribute it from Edit  Model View  Distribute

Continued...

ALE-IDOC Scenario using Custom IDOC

Page 9: Custom idoc

...Previous

Defining the Z Segment type

Tcode – WE31 

Defining the Basic Type

T Code WE30 

 

Click on New 

Page 10: Custom idoc

 

This will take you to next screen as follows 

 

Here you have connected the basic type to the segment type.

 Enter again and this will take you to screen as follows  

Page 11: Custom idoc

 

This shows the relation between the basic and the segment types. 

Next you need to make the entry of the segment in the system table.

Tcode : WE81 

 

Next is the following entry which is required. 

 

Page 12: Custom idoc

Here you are specifying the message type and the basic type and the release version. 

This is all about the configuration you need to do on the sender side.

Now on the sender side you also need a program that will fetch the required data, couple it in the IDOC format and post it. 

Here is a small piece of code that could be useful.

*&---------------------------------------------------------------------**&Report ZSACH_CUST_IDOC **& **&---------------------------------------------------------------------**& **& **&---------------------------------------------------------------------*report zsach_cust_idoc .parameters :p_logsys like tbdlst-logsys.data :gen_segment like edidd-segnam value 'ZSACH'.data :control_dat like edidc,gen_data like z1hdr .tables :zsach1.data: begin of inttab occurs 0,lname type z1hdr-lname,fname type z1hdr-fname,end of inttab.data :int_edidd like edidd occurs 0 with header line,int_edidc like edidc occurs 0 with header line.select * from zsach1 into corresponding fields of table inttab.ifsy-subrc ne 0.message 'no data' type 'I'.exit.endif.control_dat-mestyp = 'ZSACH'.control_dat-idoctp = 'ZSACH'.control_dat-rcvprt = 'LS'.control_dat-rcvprn = p_logsys.

loop at inttab.gen_data-lname = inttab-lname.gen_data-fname = inttab-fname.* GEN_DATA-SSN = INTTAB-SSN.* GEN_DATA-DOB = INTTAB-DOB.int_edidd-segnam = gen_segment.int_edidd-sdata = gen_data.appendint_edidd.endloop.call function 'MASTER_IDOC_DISTRIBUTE'exportingmaster_idoc_control = control_dat* OBJ_TYPE = ''* CHNUM = ''tables

Page 13: Custom idoc

communication_idoc_control = int_edidcmaster_idoc_data = int_ediddexceptionserror_in_idoc_control = 1error_writing_idoc_status = 2error_in_idoc_data = 3sending_logical_system_unknown = 4others = 5 .ifsy-subrc<> 0.message id sy-msgid type sy-msgty number sy-msgno.else.loop at int_edidc.write :/ 'IDOC GENERATED',int_edidc-docnum.endloop.commit work.endif.

Continued...

ALE-IDOC Scenario using Custom IDOC

...Previous

Settings on the receiver side. 

The ALE configuration is same as we did it on the sender side. Please refer to earlier pages. 

The receiver specific differences are mentioned below. 

T-Code – SALE 

200 is our sender

800 is our receiver 

Steps  

Defining Logical System (Same as sender)

Assigning Client to Logical System (Same as sender)

Defining Target System for RFC Calls (Tcode – SM59) (Same as sender)

Defining Port(Same as sender) 

Defining Partner Profiles – Here we are accepting the data from Sender system. Hence we need to configure it as Inbound. 

Page 14: Custom idoc

 

 

Click on the    sign above to go to next screen. 

Page 15: Custom idoc

 

Here the message type is to be created again as it was created on the sender side.

The following steps are repeated, as done on the sender side, on the receiver end 

Tcode WE30

Tcode WE31

Tcode WE82

Tcode WE81

Here on the receiver end, we need to specify a process code at the time of defining the partner profile.

Process code is something that has the logic defined about what to be done after receiving the IDOC. 

In our case, on receipt of the IDOC, we are updating the Z Table. i.e Inserting the data from the IDOC into the Z Table. 

Page 16: Custom idoc

 

Creating a Process Code

Tcode – WE42  

 

Page 17: Custom idoc

 

The logic associated is coded in the Function Module which is specified in the Identification Field above. 

Also the processing type is selected as Processing by Function Module as above. 

The function Module is specified in the following

screen. 

To have your function Module in the above drop down list, the entry is to be made using the following transaction 

Page 18: Custom idoc

TCode – BD51 

 

Once the entry is done here, the function module appears in the drop down list in the previous stage.

Continued...

ALE-IDOC Scenario using Custom IDOC

...Previous

Also it is important to make the following entry

Tcode WE57 

 

Function Module will look something as below: 

Page 19: Custom idoc

 

 

Source Codefunctionz_idoc_input_sach .*"----------------------------------------------------------------------*"*"Local interface:*" IMPORTING*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC*" VALUE(NO_APPLICATION_LOG) LIKE SY-DATAR OPTIONAL

Page 20: Custom idoc

*" VALUE(MASSSAVEINFOS) LIKE MASSSAVINF STRUCTURE MASSSAVINF*" OPTIONAL*" EXPORTING*" VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT*" VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-APPL_VAR*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK*" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS*" TABLES*" IDOC_CONTRL STRUCTURE EDIDC*" IDOC_DATA STRUCTURE EDIDD*" IDOC_STATUS STRUCTURE BDIDOCSTAT*" RETURN_VARIABLES STRUCTURE BDWFRETVAR*" SERIALIZATION_INFO STRUCTURE BDI_SER*" EXCEPTIONS*" WRONG_FUNCTION_CALLED*"----------------------------------------------------------------------includembdconwf.data :it_emp_data like zsach1 occurs 0 with header line.data :gen_data like zsach1 .workflow_result = c_wf_result_ok.data : counter type int4.select count( * ) from zsach1 into counter.counter = counter + 1.loop at idoc_contrl.ifidoc_contrl-mestyp ne 'ZSACH'.raisewrong_function_called.endif.cleargen_data.refreshit_emp_data.loop at idoc_data where docnumeqidoc_contrl-docnum.ifidoc_data-segnam = 'ZSACH'.gen_data = idoc_data-sdata.it_emp_data-mandt = counter.it_emp_data-lname = gen_data-lname.it_emp_data-fname = gen_data-fname.counter = counter + 1.appendit_emp_data.else.message 'ERROR' type 'I'.endif.endloop.endloop.insert zsach1 from table it_emp_data.*****call function 'EDI_DOCUMENT_OPEN_FOR_EDIT'exportingdocument_number = idoc_data-docnumimportingidoc_control = idoc_contrltablesidoc_data = idoc_dataexceptionsdocument_foreign_lock = 1document_not_exist = 2document_not_open = 3status_is_unable_for_changing = 4

Page 21: Custom idoc

others = 5.call function 'EDI_CHANGE_DATA_SEGMENTS'tablesidoc_changed_data_range = idoc_dataexceptionsidoc_not_open = 1data_record_not_exist = 2others = 3.data t_itab_edids40 like edi_ds40 occurs 0 with header line.clear t_itab_edids40.t_itab_edids40-docnum = idoc_data-docnum.t_itab_edids40-status = '51'.t_itab_edids40-repid = sy-repid.t_itab_edids40-tabnam = 'EDI_DS'.t_itab_edids40-mandt = sy-mandt.t_itab_edids40-stamqu = 'SAP'.t_itab_edids40-stamid = 'B1'.t_itab_edids40-stamno = '999'.t_itab_edids40-stapa1 = 'Sold to changed to '.*t_itab_edids40-stapa2 = t_new_kunnr.t_itab_edids40-logdat = sy-datum.t_itab_edids40-logtim = sy-uzeit.append t_itab_edids40.call function 'EDI_DOCUMENT_CLOSE_EDIT'exportingdocument_number =idoc_data-docnumdo_commit = 'X'do_update = 'X'write_all_status = 'X'tablesstatus_records = t_itab_edids40exceptionsidoc_not_open = 1db_error = 2others = 3.endfunction.

Continued...

 

ALE-IDOC Scenario using Custom IDOC

...Previous  

Running the Application 

Sender system

Execute the program we created earlier 

Page 22: Custom idoc

 

 

Checking the IDOC 

T Code WE02 

 

Checking the data on the Receiver end 

Tcode: WE02 

Page 23: Custom idoc

The IDOC has arrived here 

Checking the Data  

Double click on the IDOC  

Checking the Database 

Page 24: Custom idoc

 

This way, the data has come to the receiver end successfully.