cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger Basic Idoc from scratch

MadhavSharma
Explorer
0 Kudos

I have a requirement to create an Idoc from scratch without using any standard things. Let's say I have a custom table named EmpTable in my sender system. I want to transfer the table(just the fields or with the table entries also). So how do I achieve this?

I can create the segments, idoc type, message type and also the process code and function module to write my custom code. But my question is that how do I trigger my idoc. How do I send the Idoc from my sender system to the receiver system. Let's assume that the logical system is also created.

Is there any tcode to execute the idoc or do we have to create it using MPP?

View Entire Topic
caner_genis
Explorer
0 Kudos

Hello MadhavSharma,

You can use "Events" under "Table Maintenance Generator".

I'd advise you to create a maintenance view via SE11 using your custom table before following these blogs: 

https://community.sap.com/t5/application-development-blog-posts/update-and-create-events-in-table-ma...

https://community.sap.com/t5/application-development-blog-posts/table-maintenance-generator-events-c...

To send IDoc you can use the event "02 - After saving the data in the database".

The collected data is assigned to the relevant class object and the relevant method is called to send the IDoc.

 

 

*----------------------------------------------------------------------*
***INCLUDE LZAG_MII_004VF01.
*----------------------------------------------------------------------*

* After save.
FORM 02_send_idoc.
  DATA: lr_tot TYPE REF TO data.

  DATA: lt_data TYPE zmii_tt_matvers.

* Collect data.
  LOOP AT total REFERENCE INTO lr_tot.

    ASSIGN ('LR_TOT->ACTION') TO FIELD-SYMBOL(<action>).
    CHECK <action> NE space.      "If the row is added or updated or deleted

    ASSIGN ('LR_TOT->*') TO FIELD-SYMBOL(<total>).

    APPEND INITIAL LINE TO lt_data REFERENCE INTO DATA(lr_data).
    lr_data->* = <total>.

  ENDLOOP.

* Sending IDoc.
  DATA(lo_prdvs) = NEW zcl_mii_prodvers( lt_data[] ).

  lo_prdvs->zif_send_idoc~send_idoc( ).
  lo_prdvs->zif_send_idoc~show_messages( ).

ENDFORM.

 

 

There is a field called "action" in the "total" internal table. It can be as "I" for the added row, as "U" for the updated row and as "D" for the deleted row. Since this "action" field is defined in the IDoc segment with the same name, this indicator value is transferred to the receiver system. If you want, you can also send the whole data by removing the "Check" statement at the line 15.

Good luck.

Caner.