<?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_DOCUMENT_POST in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538851#M2005969</link>
    <description>&lt;P&gt;Hi Nivetha,&lt;/P&gt;&lt;P&gt;Yes, this is very much possible.&lt;/P&gt;&lt;P&gt;Please refer to the below code snippets:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Header structure:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    ls_header-bus_act = 'RFBU'.
    ls_header-username = sy-uname.
    ls_header-comp_code = gfs_record-bukrs.
    ls_header-doc_date = pn-endda.
    ls_header-pstng_date = pn-endda.
    ls_header-doc_type = gfs_record-blart.
    ls_header-fis_period = pn-pabrp.
    ls_header-fisc_year = pn-pabrj.
    ls_header-header_txt = 'Bonus Entries'.
    ls_header-ref_doc_no = gfs_record-xblnr.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Item Tables to be filled, you can loop the internal table and append all the entries in BAPI Account GL &amp;amp; currency amount Table, here item will be incremented like counter starting from 1,2,3....and so on.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    LOOP AT git_record INTO gfs_record WHERE blart = 'BO'.
      CLEAR: ls_accountgl, ls_currencyamount.
      SHIFT gfs_record-newko LEFT DELETING LEADING '0'.
      lv_itemno = lv_itemno + 1.
      ls_accountgl-itemno_acc = lv_itemno.
      ls_accountgl-gl_account = gfs_record-newko.
      ls_accountgl-item_text = gfs_record-sgtxt.
      ls_accountgl-comp_code = gfs_record-bukrs.
      ls_accountgl-doc_type = gfs_record-blart.
      ls_accountgl-pstng_date = pn-endda.
      ls_accountgl-value_date = pn-endda.
      ls_accountgl-fis_period = pn-pabrp.
      ls_accountgl-fisc_year = pn-pabrj.
      IF gfs_record-newbs EQ '40'.
        ls_accountgl-de_cre_ind = 'S'.
        ls_accountgl-costcenter = gfs_record-kostl.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ls_accountgl-costcenter
          IMPORTING
            output = ls_accountgl-costcenter.
      ELSEIF gfs_record-newbs EQ '50'.
        ls_accountgl-de_cre_ind = 'H'.
      ENDIF.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = ls_accountgl-gl_account
        IMPORTING
          output = ls_accountgl-gl_account.

      APPEND ls_accountgl TO lt_accountgl.

      ls_currencyamount-itemno_acc = lv_itemno.
      ls_currencyamount-curr_type = '00'.
      IF gfs_record-newbs EQ '40'.
        ls_currencyamount-amt_doccur = gfs_record-wrbtr / 10.
      ELSEIF gfs_record-newbs EQ '50'.
        ls_currencyamount-amt_doccur = ( gfs_record-wrbtr * -1 ) / 10.
      ENDIF.
      ls_currencyamount-currency = gfs_record-waers.
      APPEND ls_currencyamount TO lt_currencyamount.
    ENDLOOP.

    """" Post Bonus
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader = ls_header
      IMPORTING
        obj_type       = lv_obj_type
        obj_key        = lv_obj_key
        obj_sys        = lv_obj_sys
      TABLES
        accountgl      = lt_accountgl
        currencyamount = lt_currencyamount
        return         = lt_return.

    READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
    IF sy-subrc NE 0.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
        ls_msg-doc_type = gfs_record-blart. "'BO'.
        ls_msg-type = 'S'.
        CONCATENATE 'Document No.' lv_obj_key+0(10) 'posted successfully' INTO ls_msg-msg SEPARATED BY space.
        APPEND ls_msg TO lit_msg.
        CLEAR ls_msg..

        """"""" Update Custom Tables """"""""""""""""""""""""""""""""""""""""""""
        ls_prov_post-bukrs = gfs_record-bukrs. "'1000'.
        ls_prov_post-pabrp = pn-pabrp.
        ls_prov_post-pabrj = pn-pabrj.
        ls_prov_post-blart = gfs_record-blart. "'BO'.
        ls_prov_post-zbelnr = lv_obj_key+0(10).
        ls_prov_post-gjahr = pn-pabrj.
        MODIFY zhr_fi_prov_post FROM ls_prov_post.

        """""" Update IT tables
        lt_emp_post = gt_emp_prov.
        DELETE lt_emp_post WHERE blart NE gfs_record-blart. "'BO'.
        LOOP AT lt_emp_post ASSIGNING &amp;lt;lfs_emp_post&amp;gt;.
          &amp;lt;lfs_emp_post&amp;gt;-gjahr = pn-pabrj.
          &amp;lt;lfs_emp_post&amp;gt;-zbelnr = lv_obj_key+0(10).
        ENDLOOP.
        MODIFY zhr_emp_prov_pst FROM TABLE lt_emp_post.

    ELSE.
      ls_msg-doc_type = gfs_record-blart. "'BO'.
      ls_msg-type = 'E'.
      ls_msg-msg = 'Unable create posting document' &amp;amp;&amp;amp; ls_prov_post-zbelnr.
      APPEND ls_msg TO lit_msg.
      CLEAR ls_msg.
    ENDIF.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Oct 2021 04:39:41 GMT</pubDate>
    <dc:creator>vipinsaraika</dc:creator>
    <dc:date>2021-10-18T04:39:41Z</dc:date>
    <item>
      <title>BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538850#M2005968</link>
      <description>&lt;P&gt;I have a requirement like , I need to post multiple documents at once .&lt;/P&gt;
  &lt;P&gt;Is that possible ?&lt;/P&gt;
  &lt;P&gt;If possible , then what should be item number be for each document , and how can I retrieve the object key for each document?&lt;/P&gt;
  &lt;P&gt;Have anyone come across this requirement ?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 04:13:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538850#M2005968</guid>
      <dc:creator>nivetha_d2021</dc:creator>
      <dc:date>2021-10-18T04:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538851#M2005969</link>
      <description>&lt;P&gt;Hi Nivetha,&lt;/P&gt;&lt;P&gt;Yes, this is very much possible.&lt;/P&gt;&lt;P&gt;Please refer to the below code snippets:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Header structure:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    ls_header-bus_act = 'RFBU'.
    ls_header-username = sy-uname.
    ls_header-comp_code = gfs_record-bukrs.
    ls_header-doc_date = pn-endda.
    ls_header-pstng_date = pn-endda.
    ls_header-doc_type = gfs_record-blart.
    ls_header-fis_period = pn-pabrp.
    ls_header-fisc_year = pn-pabrj.
    ls_header-header_txt = 'Bonus Entries'.
    ls_header-ref_doc_no = gfs_record-xblnr.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Item Tables to be filled, you can loop the internal table and append all the entries in BAPI Account GL &amp;amp; currency amount Table, here item will be incremented like counter starting from 1,2,3....and so on.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    LOOP AT git_record INTO gfs_record WHERE blart = 'BO'.
      CLEAR: ls_accountgl, ls_currencyamount.
      SHIFT gfs_record-newko LEFT DELETING LEADING '0'.
      lv_itemno = lv_itemno + 1.
      ls_accountgl-itemno_acc = lv_itemno.
      ls_accountgl-gl_account = gfs_record-newko.
      ls_accountgl-item_text = gfs_record-sgtxt.
      ls_accountgl-comp_code = gfs_record-bukrs.
      ls_accountgl-doc_type = gfs_record-blart.
      ls_accountgl-pstng_date = pn-endda.
      ls_accountgl-value_date = pn-endda.
      ls_accountgl-fis_period = pn-pabrp.
      ls_accountgl-fisc_year = pn-pabrj.
      IF gfs_record-newbs EQ '40'.
        ls_accountgl-de_cre_ind = 'S'.
        ls_accountgl-costcenter = gfs_record-kostl.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ls_accountgl-costcenter
          IMPORTING
            output = ls_accountgl-costcenter.
      ELSEIF gfs_record-newbs EQ '50'.
        ls_accountgl-de_cre_ind = 'H'.
      ENDIF.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = ls_accountgl-gl_account
        IMPORTING
          output = ls_accountgl-gl_account.

      APPEND ls_accountgl TO lt_accountgl.

      ls_currencyamount-itemno_acc = lv_itemno.
      ls_currencyamount-curr_type = '00'.
      IF gfs_record-newbs EQ '40'.
        ls_currencyamount-amt_doccur = gfs_record-wrbtr / 10.
      ELSEIF gfs_record-newbs EQ '50'.
        ls_currencyamount-amt_doccur = ( gfs_record-wrbtr * -1 ) / 10.
      ENDIF.
      ls_currencyamount-currency = gfs_record-waers.
      APPEND ls_currencyamount TO lt_currencyamount.
    ENDLOOP.

    """" Post Bonus
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader = ls_header
      IMPORTING
        obj_type       = lv_obj_type
        obj_key        = lv_obj_key
        obj_sys        = lv_obj_sys
      TABLES
        accountgl      = lt_accountgl
        currencyamount = lt_currencyamount
        return         = lt_return.

    READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
    IF sy-subrc NE 0.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
        ls_msg-doc_type = gfs_record-blart. "'BO'.
        ls_msg-type = 'S'.
        CONCATENATE 'Document No.' lv_obj_key+0(10) 'posted successfully' INTO ls_msg-msg SEPARATED BY space.
        APPEND ls_msg TO lit_msg.
        CLEAR ls_msg..

        """"""" Update Custom Tables """"""""""""""""""""""""""""""""""""""""""""
        ls_prov_post-bukrs = gfs_record-bukrs. "'1000'.
        ls_prov_post-pabrp = pn-pabrp.
        ls_prov_post-pabrj = pn-pabrj.
        ls_prov_post-blart = gfs_record-blart. "'BO'.
        ls_prov_post-zbelnr = lv_obj_key+0(10).
        ls_prov_post-gjahr = pn-pabrj.
        MODIFY zhr_fi_prov_post FROM ls_prov_post.

        """""" Update IT tables
        lt_emp_post = gt_emp_prov.
        DELETE lt_emp_post WHERE blart NE gfs_record-blart. "'BO'.
        LOOP AT lt_emp_post ASSIGNING &amp;lt;lfs_emp_post&amp;gt;.
          &amp;lt;lfs_emp_post&amp;gt;-gjahr = pn-pabrj.
          &amp;lt;lfs_emp_post&amp;gt;-zbelnr = lv_obj_key+0(10).
        ENDLOOP.
        MODIFY zhr_emp_prov_pst FROM TABLE lt_emp_post.

    ELSE.
      ls_msg-doc_type = gfs_record-blart. "'BO'.
      ls_msg-type = 'E'.
      ls_msg-msg = 'Unable create posting document' &amp;amp;&amp;amp; ls_prov_post-zbelnr.
      APPEND ls_msg TO lit_msg.
      CLEAR ls_msg.
    ENDIF.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Oct 2021 04:39:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538851#M2005969</guid>
      <dc:creator>vipinsaraika</dc:creator>
      <dc:date>2021-10-18T04:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538852#M2005970</link>
      <description>&lt;P&gt;Hello Vipin,&lt;/P&gt;&lt;P&gt;Thank you for the answer&lt;/P&gt;&lt;P&gt;for single document number , my inputs are &lt;/P&gt;&lt;P&gt;1 record in ACCOUNTGL with item number 1&lt;/P&gt;&lt;P&gt;1 record in ACCOUNTPAYABLE with item number 2&lt;/P&gt;&lt;P&gt;2 records in CURRENCYAMOUNT with item number 1 and 2&lt;/P&gt;&lt;P&gt;If this is the case , then how should I provide item number for the next document ?&lt;/P&gt;&lt;P&gt;And , will the object key be same for all the posted records ?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 04:57:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538852#M2005970</guid>
      <dc:creator>nivetha_d2021</dc:creator>
      <dc:date>2021-10-18T04:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538853#M2005971</link>
      <description>&lt;P&gt;Hi Nivetha,&lt;/P&gt;&lt;P&gt;Every time you call BAPI_ACC_DOUCMENT_POST a document will be posted, in your case the item number for the next docuemnt should be again 1,2,... and so on. Whwneveer you have posted one document you need to clear the item counter back to 0.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 05:38:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538853#M2005971</guid>
      <dc:creator>vipinsaraika</dc:creator>
      <dc:date>2021-10-18T05:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538854#M2005972</link>
      <description>&lt;P&gt;Thank you for the confirmation, Vipin&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 07:22:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post/m-p/12538854#M2005972</guid>
      <dc:creator>nivetha_d2021</dc:creator>
      <dc:date>2021-10-18T07:22:58Z</dc:date>
    </item>
  </channel>
</rss>

