<?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 Re: Custom IDOC in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/custom-idoc/m-p/3688339#M888153</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; 1.For the writing of code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; STEP 1 - Open document to edit with the function 'EDI_DOCUMENT_OPEN_FOR_EDIT' . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STEP2 - Change data segments with the function 'EDI_CHANGE_DATA_SEGMENTS' . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STEP 3 - Change control record with the function 'EDI_CHANGE_CONTROL_RECORD' . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STEP 4 - Close Idoc with the function &lt;/P&gt;&lt;P&gt;'EDI_DOCUMENT_CLOSE_EDIT' . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;If helpful reward with points(Don't forget).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Apr 2008 07:47:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-11T07:47:53Z</dc:date>
    <item>
      <title>Custom IDOC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/custom-idoc/m-p/3688338#M888152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while creating custom IDOC we need to create a FM i.e., (Posting program) which is used to fetch the data from IDOC and post the data into DB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;there we need to call 3 FM's &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'EDI_DOCUMENT_OPEN_FOR_EDIT'&lt;/P&gt;&lt;P&gt;'EDI_CHANGE_DATA_SEGMENTS'&lt;/P&gt;&lt;P&gt;'EDI_DOCUMENT_CLOSE_EDIT'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plz explain why these FM are required and wht each does????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pts will b rewarded for correct answers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Faisal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 07:35:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/custom-idoc/m-p/3688338#M888152</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T07:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Custom IDOC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/custom-idoc/m-p/3688339#M888153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; 1.For the writing of code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; STEP 1 - Open document to edit with the function 'EDI_DOCUMENT_OPEN_FOR_EDIT' . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STEP2 - Change data segments with the function 'EDI_CHANGE_DATA_SEGMENTS' . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STEP 3 - Change control record with the function 'EDI_CHANGE_CONTROL_RECORD' . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STEP 4 - Close Idoc with the function &lt;/P&gt;&lt;P&gt;'EDI_DOCUMENT_CLOSE_EDIT' . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;If helpful reward with points(Don't forget).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 07:47:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/custom-idoc/m-p/3688339#M888153</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T07:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Custom IDOC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/custom-idoc/m-p/3688340#M888154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDI_DOCUMENT_OPEN_FOR_EDIT (unlocks the idoc for editing) &lt;/P&gt;&lt;P&gt;EDI_CHANGE_DATA_SEGMENT (writes any changes to the idoc segment)&lt;/P&gt;&lt;P&gt;EDI_DOCUMENT_CLOSE_EDIT (closes the idoc to editing)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Updating IDoc data in segments 
STEP 1 - Open document to edit 

CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_EDIT' 

       EXPORTING 

            document_number               = t_docnum 
            IMPORTING 
            idoc_control                  = itab_edidc 
            TABLES 
            idoc_data                     = itab_edidd 

       EXCEPTIONS 

            document_foreign_lock         = 1 
            document_not_exist            = 2 
            document_not_open             = 3 
            status_is_unable_for_changing = 4 
            OTHERS                        = 5. 

STEP 2 - Loop at itab_edidd and change data

LOOP AT itab_edidd WHERE segnam = 'E1EDKA1'. 

  e1edka1 = itab_edidd-sdata. 

  IF e1edka1-parvw = 'LF'. 

    e1edka1-partn = t_eikto. 

    itab_edidd-sdata = e1edka1. 

    MODIFY itab_edidd.

    EXIT.

  ENDIF.

ENDLOOP. 

STEP 3 - Change data segments

CALL FUNCTION 'EDI_CHANGE_DATA_SEGMENTS' 

           TABLES 

                idoc_changed_data_range = itab_edidd 

           EXCEPTIONS 

                idoc_not_open           = 1 

                data_record_not_exist   = 2 

                OTHERS                  = 3.

STEP 3a - Change control record

CALL FUNCTION 'EDI_CHANGE_CONTROL_RECORD' 

       EXPORTING 

            idoc_changed_control         = itab_edidc 

       EXCEPTIONS 

            idoc_not_open                = 1 

            direction_change_not_allowed = 2 

            OTHERS                       = 3. 

STEP 4 - Close Idoc

* Update IDoc status

CLEAR t_itab_edids40. 

  t_itab_edids40-docnum      = t_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' 

       EXPORTING 

            document_number  = t_docnum 

            do_commit        = 'X' 

            do_update        = 'X' 

            write_all_status = 'X' 

       TABLES 

            status_records   = t_itab_edids40 

       EXCEPTIONS 

            idoc_not_open    = 1 

            db_error         = 2 

            OTHERS           = 3.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if useful....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;AK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 07:50:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/custom-idoc/m-p/3688340#M888154</guid>
      <dc:creator>ak_upadhyay</dc:creator>
      <dc:date>2008-04-11T07:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: Custom IDOC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/custom-idoc/m-p/3688341#M888155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read the IDOC data using the FM IDOC_READ_COMPLETELY, and find the errors &lt;/P&gt;&lt;P&gt;then now modify the IDoc using &lt;/P&gt;&lt;P&gt;EDI_DOCUMENT_OPEN_FOR_EDIT "open idoc&lt;/P&gt;&lt;P&gt;EDI_CHANGE_DATA_SEGMENTS "change the data&lt;/P&gt;&lt;P&gt;EDI_DOCUMENT_CLOSE_EDIT "close the IDOC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now change the status of the IDoc &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The example codes can be found in website &lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapgenie.com/sapedi/idoc_abap.htm" target="test_blank"&gt;http://www.sapgenie.com/sapedi/idoc_abap.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Kiran Sure&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 07:54:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/custom-idoc/m-p/3688341#M888155</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T07:54:34Z</dc:date>
    </item>
  </channel>
</rss>

