<?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: BAPI_ACC_GL_POSTING_POST    Document Already exist in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063192#M1354299</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thanks a lot for your response but I always meet the same problem. I refresh the tables and I do before a commit. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT l_seltab INTO wa_seltab.
* Call BAPI to post the document
        CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
          EXPORTING
            documentheader       = i_docheader
          IMPORTING
            obj_type             = i_docheader-obj_type
            obj_key              = i_docheader-obj_key
            obj_sys              = i_docheader-obj_sys
          TABLES
            accountgl            = i_accountgl
            currencyamount       = i_curramunt
            return               = i_return
*   EXTENSION1           = .
          CLEAR i_return.
        REFRESH i_return.

        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = 'X'
          IMPORTING
            return = i_return.
commit WORK AND WAIT.

        CLEAR i_return.
        REFRESH i_return.

        i_reversal-obj_type        = 'BKPFF'.
        i_reversal-obj_key         = i_docheader-obj_key.
        i_reversal-obj_key_r       = i_docheader-obj_key.
        i_reversal-reason_rev      = '06'.
        i_reversal-pstng_date      = p_budt3.
        i_reversal-fis_period      = p_budt3+4(2).
        i_reversal-comp_code       = s_bukrs-low.

        APPEND i_reversal.
* Reversal posting
        CALL FUNCTION 'BAPI_ACC_GL_POSTING_REV_POST'
          EXPORTING
            reversal = i_reversal
          IMPORTING
            obj_type = i_reversal-obj_type
            obj_key  = i_reversal-obj_key
            obj_sys  = i_reversal-obj_sys
          TABLES
            return   = i_return.
        CLEAR i_return.
        REFRESH i_return.

        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = 'X'
          IMPORTING
            return = i_return.

        commit WORK AND WAIT.

refresh: i_docheader, i_accountgl, i_curramunt, i_reversal.
      ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I don't see where is the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mohamed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Aug 2009 08:26:48 GMT</pubDate>
    <dc:creator>mrahhaoui</dc:creator>
    <dc:date>2009-08-25T08:26:48Z</dc:date>
    <item>
      <title>BAPI_ACC_GL_POSTING_POST    Document Already exist</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063187#M1354294</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;I have an ALV grid which contains some amount that I have to post. When I post a first time with function  	   BAPI_ACC_GL_POSTING_POST, the posting and the reversal do correctly. After that I do a refresh of the ALV. But when I try a second time to post another document, I receive the internal message "Document XXXXXX already exist". I think my problem comes from the OBJ_KEY because It takes the old reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My posting is in a loop and I think maybe that I would have to increment my OBJ_KEY. Is it possible to do that? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anybody would have an idea?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mohamed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: rahhaoui mohamed on Aug 24, 2009 7:59 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2009 17:58:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063187#M1354294</guid>
      <dc:creator>mrahhaoui</dc:creator>
      <dc:date>2009-08-24T17:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_GL_POSTING_POST    Document Already exist</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063188#M1354295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try clearing the Object key and re assign in the loop. Or if the doc already exists you might have to use a doc change bapi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should not increment just like that... there would be a number range assigned to Object key.. which will give you the next number to use.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2009 18:05:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063188#M1354295</guid>
      <dc:creator>former_member156446</dc:creator>
      <dc:date>2009-08-24T18:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_GL_POSTING_POST    Document Already exist</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063189#M1354296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thks for your quick answer but how to clearing the OBJect key and re assign it. What BAPI are you talking?&lt;/P&gt;&lt;P&gt;DO you have an example maybe? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2009 18:08:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063189#M1354296</guid>
      <dc:creator>mrahhaoui</dc:creator>
      <dc:date>2009-08-24T18:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_GL_POSTING_POST    Document Already exist</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063190#M1354297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;I receive the internal message "Document XXXXXX already exist". I think my problem comes from the OBJ_KEY because It takes the old reference.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;already exists means the document already posted so with that OBject key you cannot force the system to create again....&lt;/P&gt;&lt;P&gt;loop at itab...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call bapi  and send obj_key..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear obj_key.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __jive_macro_name="message" id="852829"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2009 18:35:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063190#M1354297</guid>
      <dc:creator>former_member156446</dc:creator>
      <dc:date>2009-08-24T18:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_GL_POSTING_POST    Document Already exist</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063191#M1354298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  Thats an exporting parameter for the BAPI that you are using i think you should clear that variable before you call the BAPI second time in the loop.&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;Himanshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2009 18:38:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063191#M1354298</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-24T18:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_GL_POSTING_POST    Document Already exist</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063192#M1354299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thanks a lot for your response but I always meet the same problem. I refresh the tables and I do before a commit. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT l_seltab INTO wa_seltab.
* Call BAPI to post the document
        CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
          EXPORTING
            documentheader       = i_docheader
          IMPORTING
            obj_type             = i_docheader-obj_type
            obj_key              = i_docheader-obj_key
            obj_sys              = i_docheader-obj_sys
          TABLES
            accountgl            = i_accountgl
            currencyamount       = i_curramunt
            return               = i_return
*   EXTENSION1           = .
          CLEAR i_return.
        REFRESH i_return.

        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = 'X'
          IMPORTING
            return = i_return.
commit WORK AND WAIT.

        CLEAR i_return.
        REFRESH i_return.

        i_reversal-obj_type        = 'BKPFF'.
        i_reversal-obj_key         = i_docheader-obj_key.
        i_reversal-obj_key_r       = i_docheader-obj_key.
        i_reversal-reason_rev      = '06'.
        i_reversal-pstng_date      = p_budt3.
        i_reversal-fis_period      = p_budt3+4(2).
        i_reversal-comp_code       = s_bukrs-low.

        APPEND i_reversal.
* Reversal posting
        CALL FUNCTION 'BAPI_ACC_GL_POSTING_REV_POST'
          EXPORTING
            reversal = i_reversal
          IMPORTING
            obj_type = i_reversal-obj_type
            obj_key  = i_reversal-obj_key
            obj_sys  = i_reversal-obj_sys
          TABLES
            return   = i_return.
        CLEAR i_return.
        REFRESH i_return.

        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = 'X'
          IMPORTING
            return = i_return.

        commit WORK AND WAIT.

refresh: i_docheader, i_accountgl, i_curramunt, i_reversal.
      ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I don't see where is the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mohamed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2009 08:26:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063192#M1354299</guid>
      <dc:creator>mrahhaoui</dc:creator>
      <dc:date>2009-08-25T08:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_GL_POSTING_POST    Document Already exist</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063193#M1354300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* Reversal posting
        CALL FUNCTION 'BAPI_ACC_GL_POSTING_REV_POST'
          EXPORTING
            reversal = i_reversal
          IMPORTING
            obj_type = i_reversal-obj_type   &amp;lt;&amp;lt;&amp;lt;&amp;lt; This is an importinging parameter
            obj_key  = i_reversal-obj_key    &amp;lt;&amp;lt;&amp;lt;&amp;lt; This is an importinging parameter
            obj_sys  = i_reversal-obj_sys   &amp;lt;&amp;lt;&amp;lt;&amp;lt; This is an importinging parameter
          TABLES
            return   = i_return.
        CLEAR i_return.
        REFRESH i_return.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do not use the same values as returnurned above you can declare new variables like obj_type,obj_key and obj_sys here and then every time you call the FM for postings clear these variables these variables would ahve values returned by the FM and we dont need to pass any values to them we can also comment the importing lines and that should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;HImanshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2009 08:35:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063193#M1354300</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-25T08:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_GL_POSTING_POST    Document Already exist</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063194#M1354301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi HImanshu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did what you told me but always the same issue:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* Reversal posting
        CALL FUNCTION 'BAPI_ACC_GL_POSTING_REV_POST'
          EXPORTING
            reversal = i_reversal
          IMPORTING
            obj_type = lw_obj_type
            obj_key  = lw_obj_key
            obj_sys  = lw_obj_sys
          TABLES
            return   = i_return.

        IF i_return-type = 'E'.                          "If error Document not posted
          EXIT.
        ENDIF.

        CLEAR i_return.
        REFRESH i_return.

        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = 'X'
          IMPORTING
            return = i_return.

        IF i_return-type = 'E'.                   "If error Document not posted
          MESSAGE s040(zst1).
          EXIT.
        ENDIF.
        COMMIT WORK AND WAIT.
        CLEAR: lw_obj_key, lw_obj_type, lw_obj_sys.
        REFRESH: i_docheader, i_accountgl, i_curramunt, i_reversal.
      ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2009 15:00:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063194#M1354301</guid>
      <dc:creator>mrahhaoui</dc:creator>
      <dc:date>2009-08-25T15:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_GL_POSTING_POST    Document Already exist</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063195#M1354302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What should I have to pass in  i_reversal-obj_key  and    i_reversal-obj_key_r   fields?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2009 16:05:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063195#M1354302</guid>
      <dc:creator>mrahhaoui</dc:creator>
      <dc:date>2009-08-25T16:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_GL_POSTING_POST    Document Already exist</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063196#M1354303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I resolved the problem. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thx.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 09:29:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-gl-posting-post-document-already-exist/m-p/6063196#M1354303</guid>
      <dc:creator>mrahhaoui</dc:creator>
      <dc:date>2009-08-26T09:29:52Z</dc:date>
    </item>
  </channel>
</rss>

