<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Idoc programming question in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-programming-question/m-p/1868152#M365759</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;I am asked to write a custom executable program (not a function module) to create outbound idocs with some data from the database tables as for the selection screen data the user entered. How do I do this and how to trigger these outbound idocs? Can you please give me a sample code for this or your valuable suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Jan 2007 17:16:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-01-06T17:16:51Z</dc:date>
    <item>
      <title>Idoc programming question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-programming-question/m-p/1868152#M365759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;I am asked to write a custom executable program (not a function module) to create outbound idocs with some data from the database tables as for the selection screen data the user entered. How do I do this and how to trigger these outbound idocs? Can you please give me a sample code for this or your valuable suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Jan 2007 17:16:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-programming-question/m-p/1868152#M365759</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-06T17:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Idoc programming question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-programming-question/m-p/1868153#M365760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the sample code which triggers the IDoc (Outbound)..I also added comments&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;report z_idoc_creat_tr .

tables : ekpo,
         edidd,  " Data record (IDoc)
         tbdlst, " Text for logical system
         edmsg . "Logical message types

* Selection screen
parameters: p_ebeln like ekpo-ebeln.

data : c_seg1 like edidd-segnam value 'ZSEG1_TR',
       c_seg2 like edidd-segnam value 'ZSEG2_TR',
       itab_comm_idocs  like edidc occurs 0 with header line ,
       control_record like edidc.

*Internal Tables

data :
     itab_edidd like edidd occurs 0 with header line, "Data record(IDoc)
       itab_seg2 like zseg2_tr  occurs 0 with header line .
* zseg2_tr structure generated when you define the Segments in WE31

* Work Area

data : seg1 like zseg1_tr, " Segments Header Data
       seg2 like zseg2_tr. " Segments 

select single * from ekpo  where ebeln = p_ebeln.

*Build Control Data

control_record-mestyp = 'Z_EKPO' .  "Message Type.
control_record-idoctp = 'ZIDOC_TR' ." IDoc Type

control_record-sndprt = 'LS'. 
control_record-sndprn = 'LOGSYS0100' . " Logical system
control_record-sndpor = 'SAPLT1'. "SEnder Port

control_record-rcvprt = 'LS'.
control_record-rcvprn = 'SEND' ." Reveiver Logical system
control_record-rcvpor = 'A000000171'." Receiver Port

*Filling the Segment 1 ie.,Purchasing Document Number .

move-corresponding ekpo to seg1.

itab_edidd-segnam = 'ZSEG1_TR'." Segment Name
itab_edidd-sdata = seg1.  " Value for the Segment1. "Segment value

append itab_edidd .
clear itab_edidd.

*Filling the Segment 2 ie.,Item Number of Purchasing Document.

select * from ekpo into corresponding fields of table itab_seg2  where
         ebeln = p_ebeln .

loop at itab_seg2 .

  move-corresponding  itab_seg2 to seg2.

  itab_edidd-segnam = 'ZSEG2_TR'.
  itab_edidd-sdata = seg2.

  append itab_edidd.
  clear itab_edidd.

endloop.

* FM to trigger the Outbound Idoc
call function 'MASTER_IDOC_DISTRIBUTE'
  exporting
    master_idoc_control                  = control_record
  tables
    communication_idoc_control           = itab_comm_idocs
    master_idoc_data                     = itab_edidd
 exceptions
   error_in_idoc_control                = 1
   error_writing_idoc_status            = 2
   error_in_idoc_data                   = 3
   sending_logical_system_unknown       = 4
   others                               = 5
          .
if sy-subrc &amp;lt;&amp;gt; 0.

endif.

loop at itab_comm_idocs.

  write:/2 'Docs generated', itab_comm_idocs-docnum.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;* Reward each useful answer&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raja T&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Raja Thangamani&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Jan 2007 20:28:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-programming-question/m-p/1868153#M365760</guid>
      <dc:creator>raja_thangamani</dc:creator>
      <dc:date>2007-01-06T20:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Idoc programming question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-programming-question/m-p/1868154#M365761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;have u refered the book "ALE/EDI and IDoc Technologies for SAP" By Arvind Nagpal..If not plz go ahead..it will help to write your own outbound / inbound Programs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Abdul Hakim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Jan 2007 06:38:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-programming-question/m-p/1868154#M365761</guid>
      <dc:creator>abdul_hakim</dc:creator>
      <dc:date>2007-01-07T06:38:41Z</dc:date>
    </item>
  </channel>
</rss>

