<?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 BAPI_ACC_DOCUMENT_POST cannot post/create new accounting documents in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205783#M1982290</link>
    <description>&lt;P&gt;&lt;A href="https://answers.sap.com/storage/temp/1792748-bapi-acc-document-post.png"&gt;bapi-acc-document-post.png&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;Hi all,&lt;/P&gt;
  &lt;P&gt;I am having problem using BAPI_ACC_DOCUMENT_POST to post/create new accounting documents. Can anyone identify what could be the problem here? Thanks&lt;/P&gt;
  &lt;P&gt;This is the header part.&lt;/P&gt;
  &lt;P&gt; gw_documentheader-fisc_year = gw_post_rec-gjahr.&lt;BR /&gt; gw_documentheader-header_txt = 'CAYEAUTO'.&lt;/P&gt;
  &lt;P&gt; gw_documentheader-pstng_date = gw_post_rec-budat.&lt;BR /&gt; gw_documentheader-doc_date = gw_documentheader-pstng_date.&lt;/P&gt;
  &lt;P&gt; gw_documentheader-ref_doc_no = gw_post_rec-xblnr&lt;/P&gt;
  &lt;P&gt;IF gw_post_rec-bschl = '21' OR&lt;BR /&gt; gw_post_rec-bschl = '31'.&lt;BR /&gt;&lt;BR /&gt; gw_documentheader-doc_type = 'KI'.&lt;BR /&gt;&lt;BR /&gt; ELSEIF gw_post_rec-bschl = '25' OR&lt;BR /&gt; gw_post_rec-bschl = '50'.&lt;BR /&gt;&lt;BR /&gt; gw_documentheader-doc_type = 'ZP'.&lt;BR /&gt;&lt;BR /&gt; ENDIF.&lt;BR /&gt; gw_documentheader-fis_period = '12'. "gw_post_rec-monat.&lt;BR /&gt; gw_documentheader-comp_code = gw_post_rec-bukrs.&lt;BR /&gt;&lt;BR /&gt; gw_documentheader-index = g_doc_count.&lt;/P&gt;
  &lt;P&gt; gw_documentheader_p-doc_status = '4'.&lt;BR /&gt; gw_documentheader_p-obj_type = 'ZBKPF'. "'BKPFF'.&lt;BR /&gt;*&lt;BR /&gt;*&lt;BR /&gt; l_belnr = gw_documentheader-ac_doc_no + 1.&lt;BR /&gt; CONCATENATE l_belnr&lt;BR /&gt; gw_documentheader-comp_code&lt;BR /&gt; gw_documentheader-fisc_year&lt;BR /&gt;&lt;BR /&gt; INTO gw_documentheader-obj_key.&lt;BR /&gt;* gw_documentheader-obj_key = 'l'.&lt;BR /&gt;** gw_documentheader-obj_key = gw_documentheader-ref_doc_no. "'$'. "gw_documentheader_p-ac_doc_no.&lt;BR /&gt; gw_documentheader-obj_sys = l_logsys.&lt;/P&gt;
  &lt;P&gt; APPEND gw_documentheader TO gt_documentheader.&lt;/P&gt;
  &lt;P&gt;This is my account payable.&lt;/P&gt;
  &lt;P&gt;gw_accountpayable-itemno_acc = g_doc_count.&lt;BR /&gt; IF gw_post_rec-bschl = '21'.&lt;BR /&gt; gw_accountpayable-vendor_no = gw_post_rec-lifnr.&lt;BR /&gt; ELSEIF gw_post_rec-bschl = '31'.&lt;BR /&gt; gw_accountpayable-vendor_no = '1001941'.&lt;BR /&gt; ENDIF.&lt;/P&gt;
  &lt;P&gt; gw_accountpayable-comp_code = gw_post_rec-bukrs.&lt;BR /&gt; gw_accountpayable-gl_account = gw_post_rec-hkont.&lt;/P&gt;
  &lt;P&gt; gw_accountpayable-bus_area = gw_post_rec-gsber.&lt;/P&gt;
  &lt;P&gt; gw_accountpayable-item_text = 'CAYEAUTO'. &lt;/P&gt;
  &lt;P&gt; gw_accountpayable-bline_date = gw_documentheader-doc_date.&lt;BR /&gt; gw_accountpayable-pmnt_block = gw_post_rec-zlspr.&lt;BR /&gt; gw_accountpayable-pymt_cur = 'SGD'. "gw_post_rec-pycur.&lt;BR /&gt; gw_accountpayable-dsct_days1 = gw_post_rec-zbd1t.&lt;BR /&gt; gw_accountpayable-dsct_pct1 = gw_post_rec-zbd1p.&lt;BR /&gt; gw_accountpayable-dsct_days2 = gw_post_rec-zbd2t.&lt;/P&gt;
  &lt;P&gt; gw_accountpayable-pymt_amt = gw_post_rec-wrbtr. &lt;/P&gt;
  &lt;P&gt; gw_accountpayable-index = g_doc_count.&lt;/P&gt;
  &lt;P&gt; APPEND gw_accountpayable TO gt_accountpayable.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Apr 2020 06:03:38 GMT</pubDate>
    <dc:creator>siongchao_ng</dc:creator>
    <dc:date>2020-04-02T06:03:38Z</dc:date>
    <item>
      <title>BAPI_ACC_DOCUMENT_POST cannot post/create new accounting documents</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205783#M1982290</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/storage/temp/1792748-bapi-acc-document-post.png"&gt;bapi-acc-document-post.png&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;Hi all,&lt;/P&gt;
  &lt;P&gt;I am having problem using BAPI_ACC_DOCUMENT_POST to post/create new accounting documents. Can anyone identify what could be the problem here? Thanks&lt;/P&gt;
  &lt;P&gt;This is the header part.&lt;/P&gt;
  &lt;P&gt; gw_documentheader-fisc_year = gw_post_rec-gjahr.&lt;BR /&gt; gw_documentheader-header_txt = 'CAYEAUTO'.&lt;/P&gt;
  &lt;P&gt; gw_documentheader-pstng_date = gw_post_rec-budat.&lt;BR /&gt; gw_documentheader-doc_date = gw_documentheader-pstng_date.&lt;/P&gt;
  &lt;P&gt; gw_documentheader-ref_doc_no = gw_post_rec-xblnr&lt;/P&gt;
  &lt;P&gt;IF gw_post_rec-bschl = '21' OR&lt;BR /&gt; gw_post_rec-bschl = '31'.&lt;BR /&gt;&lt;BR /&gt; gw_documentheader-doc_type = 'KI'.&lt;BR /&gt;&lt;BR /&gt; ELSEIF gw_post_rec-bschl = '25' OR&lt;BR /&gt; gw_post_rec-bschl = '50'.&lt;BR /&gt;&lt;BR /&gt; gw_documentheader-doc_type = 'ZP'.&lt;BR /&gt;&lt;BR /&gt; ENDIF.&lt;BR /&gt; gw_documentheader-fis_period = '12'. "gw_post_rec-monat.&lt;BR /&gt; gw_documentheader-comp_code = gw_post_rec-bukrs.&lt;BR /&gt;&lt;BR /&gt; gw_documentheader-index = g_doc_count.&lt;/P&gt;
  &lt;P&gt; gw_documentheader_p-doc_status = '4'.&lt;BR /&gt; gw_documentheader_p-obj_type = 'ZBKPF'. "'BKPFF'.&lt;BR /&gt;*&lt;BR /&gt;*&lt;BR /&gt; l_belnr = gw_documentheader-ac_doc_no + 1.&lt;BR /&gt; CONCATENATE l_belnr&lt;BR /&gt; gw_documentheader-comp_code&lt;BR /&gt; gw_documentheader-fisc_year&lt;BR /&gt;&lt;BR /&gt; INTO gw_documentheader-obj_key.&lt;BR /&gt;* gw_documentheader-obj_key = 'l'.&lt;BR /&gt;** gw_documentheader-obj_key = gw_documentheader-ref_doc_no. "'$'. "gw_documentheader_p-ac_doc_no.&lt;BR /&gt; gw_documentheader-obj_sys = l_logsys.&lt;/P&gt;
  &lt;P&gt; APPEND gw_documentheader TO gt_documentheader.&lt;/P&gt;
  &lt;P&gt;This is my account payable.&lt;/P&gt;
  &lt;P&gt;gw_accountpayable-itemno_acc = g_doc_count.&lt;BR /&gt; IF gw_post_rec-bschl = '21'.&lt;BR /&gt; gw_accountpayable-vendor_no = gw_post_rec-lifnr.&lt;BR /&gt; ELSEIF gw_post_rec-bschl = '31'.&lt;BR /&gt; gw_accountpayable-vendor_no = '1001941'.&lt;BR /&gt; ENDIF.&lt;/P&gt;
  &lt;P&gt; gw_accountpayable-comp_code = gw_post_rec-bukrs.&lt;BR /&gt; gw_accountpayable-gl_account = gw_post_rec-hkont.&lt;/P&gt;
  &lt;P&gt; gw_accountpayable-bus_area = gw_post_rec-gsber.&lt;/P&gt;
  &lt;P&gt; gw_accountpayable-item_text = 'CAYEAUTO'. &lt;/P&gt;
  &lt;P&gt; gw_accountpayable-bline_date = gw_documentheader-doc_date.&lt;BR /&gt; gw_accountpayable-pmnt_block = gw_post_rec-zlspr.&lt;BR /&gt; gw_accountpayable-pymt_cur = 'SGD'. "gw_post_rec-pycur.&lt;BR /&gt; gw_accountpayable-dsct_days1 = gw_post_rec-zbd1t.&lt;BR /&gt; gw_accountpayable-dsct_pct1 = gw_post_rec-zbd1p.&lt;BR /&gt; gw_accountpayable-dsct_days2 = gw_post_rec-zbd2t.&lt;/P&gt;
  &lt;P&gt; gw_accountpayable-pymt_amt = gw_post_rec-wrbtr. &lt;/P&gt;
  &lt;P&gt; gw_accountpayable-index = g_doc_count.&lt;/P&gt;
  &lt;P&gt; APPEND gw_accountpayable TO gt_accountpayable.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 06:03:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205783#M1982290</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2020-04-02T06:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_DOCUMENT_POST cannot post/create new accounting documents</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205784#M1982291</link>
      <description>&lt;P&gt;what is your issue.&lt;/P&gt;&lt;P&gt;All lines are created in one single document?&lt;/P&gt;&lt;P&gt;If so please attach your code full, using code option&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 07:06:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205784#M1982291</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2020-04-02T07:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_DOCUMENT_POST cannot post/create new accounting documents</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205785#M1982292</link>
      <description>&lt;P&gt;What is the error in the RETURN Parameter? &lt;/P&gt;&lt;P&gt;From the Screenshot it seems Document is created. If that is the case, please check whether you have called Commit statement after the BAPI call. &lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 07:12:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205785#M1982292</guid>
      <dc:creator>former_member629447</dc:creator>
      <dc:date>2020-04-02T07:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_DOCUMENT_POST cannot post/create new accounting documents</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205786#M1982293</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;DATA: l_loop_index TYPE i.
  DATA: l_status_count TYPE i,
        l_result_count TYPE i,
        l_error_flag   TYPE c,
        l_status       TYPE icon_d,
        l_belnr        TYPE belnr_d.

  DATA: l_obj_key TYPE bapiache09-obj_key.
  DATA: l_logsys  TYPE bapiache09-obj_sys.

  DATA: l_nr_range_nr TYPE inri-nrrangenr,
        l_object      TYPE inri-object.

  REFRESH: gt_check_result,
           gt_post_result.

  CLEAR:   l_loop_index,
           g_belnr1,
           g_bukrs,
           g_budat.

  CALL FUNCTION 'FIBL_GET_LOGSYS'
    IMPORTING
      ex_logsys = l_logsys.


*  WHILE l_loop_index &amp;lt; g_doc_count.
  ADD 1 TO l_loop_index.
  CLEAR l_error_flag.

*--&amp;gt; If Errors exist in the previous checking, ignore the record
  READ TABLE gt_status INTO gw_status
    WITH KEY index = l_loop_index
              type = 'E'.

*--&amp;gt; Errors found in the document. Add the Error status message and
*    ignore the record
  IF sy-subrc = 0.

    LOOP AT gt_status INTO gw_status
      WHERE index = l_loop_index.
      gw_status-type   = 'E'.
      gw_status-status  = icon_led_red.

      APPEND gw_status TO gt_check_result.
      APPEND gw_status TO gt_final_result.
      l_error_flag = gc_x.
    ENDLOOP.

    IF l_error_flag = gc_x.
      IF g_check IS INITIAL.
        g_check = 8.
      ENDIF.
*        CONTINUE.
    ENDIF.
  ENDIF.

  REFRESH: gt_documentheader_p,
           gt_accountgl_p,
           gt_accountreceivable_p,
           gt_accountpayable_p,
           gt_currencyamount_p,
           gt_criteria_p,
           gt_accounttax_p,
           gt_bapiret2_p,
           gt_accountreceivable_b,
           gt_currencyamount_b,
           gt_accountgl_b,
           gt_accounttax_b,
           gt_bapiret2_b.

** Document Header
  LOOP AT gt_documentheader INTO gw_documentheader.
    "WHERE index = l_loop_index.

    gw_documentheader_p = gw_documentheader.
    gw_documentheader_p-bus_act = 'RFBU'.
    gw_documentheader_p-username = sy-uname.

    IF gw_documentheader_p-doc_type EQ 'RV'
    OR gw_documentheader_p-doc_type EQ 'RC'
    OR gw_documentheader_p-doc_type EQ 'RR'.


      gw_documentheader_p-obj_type = 'ZBKPF'.
      gw_documentheader_p-obj_key =  gw_documentheader_p-ac_doc_no.
      gw_documentheader_p-obj_sys = l_logsys.

    ELSEIF gw_documentheader_p-doc_type EQ 'RE'
    OR     gw_documentheader_p-doc_type EQ 'KI'
    OR     gw_documentheader_p-doc_type EQ 'ZP'.

      gw_documentheader_p-ac_doc_no = space.
*      gw_documentheader_p-doc_status = '4'.
      gw_documentheader_p-obj_type = 'ZBKPF'. "'BKPFF'.
*
*
      l_belnr = gw_documentheader_p-ac_doc_no + 1.
      CONCATENATE l_belnr
                  gw_documentheader_p-comp_code
                  gw_documentheader_p-fisc_year

                  INTO gw_documentheader_p-obj_key.
*      gw_documentheader_p-obj_key = 'l'.
**      gw_documentheader_p-obj_key = gw_documentheader-ref_doc_no.  "'$'. "gw_documentheader_p-ac_doc_no.
      gw_documentheader_p-obj_sys = l_logsys.

    ENDIF.
    APPEND gw_documentheader_p TO gt_documentheader_p.

  ENDLOOP.

** GL
  LOOP AT gt_accountgl INTO gw_accountgl." WHERE index = l_loop_index.
    gw_accountgl_p = gw_accountgl.
    APPEND gw_accountgl_p TO gt_accountgl_p.
  ENDLOOP.

** AR
  LOOP AT gt_accountreceivable INTO gw_accountreceivable.
    " WHERE index = l_loop_index.
    gw_accountreceivable_p = gw_accountreceivable.
    APPEND gw_accountreceivable_p TO gt_accountreceivable_p.
  ENDLOOP.

** AP
  LOOP AT gt_accountpayable INTO gw_accountpayable.
    "WHERE index = l_loop_index.
    gw_accountpayable_p = gw_accountpayable.
    APPEND gw_accountpayable_p TO gt_accountpayable_p.
  ENDLOOP.

** Currency - Posting Amount
  LOOP AT gt_currencyamount INTO gw_currencyamount.
    "WHERE index = l_loop_index.
    gw_currencyamount_p = gw_currencyamount.
    APPEND gw_currencyamount_p TO gt_currencyamount_p.
  ENDLOOP.

** Criteria - Profit Segment
  LOOP AT gt_criteria INTO gw_criteria." WHERE index = l_loop_index.
    gw_criteria_p = gw_criteria.
    APPEND gw_criteria_p TO gt_criteria_p.
  ENDLOOP.

** Account Tax
  LOOP AT gt_accounttax INTO gw_accounttax." WHERE index = l_loop_index.
    gw_accounttax_p = gw_accounttax.
    APPEND gw_accounttax_p TO gt_accounttax_p.
  ENDLOOP.

*** Post Document
*    CLEAR l_obj_key.
*    IF l_loop_index &amp;gt; 1.
*      CONCATENATE 'Refer'(t11) g_bukrs g_belnr1 INTO
*        gw_documentheader_p-header_txt SEPARATED BY space.
*    ENDIF.

  REFRESH gt_bapiret2_p.
  CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
    EXPORTING
      documentheader    = gw_documentheader_p
    TABLES
      accountgl         = gt_accountgl_p
      accountreceivable = gt_accountreceivable_p
      accountpayable    = gt_accountpayable_p
      accounttax        = gt_accounttax_p
      currencyamount    = gt_currencyamount_p
      return            = gt_bapiret2_p.

  IF gt_bapiret2_p IS NOT INITIAL.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader    = gw_documentheader_p
      IMPORTING
        obj_key           = l_obj_key
      TABLES
        accountgl         = gt_accountgl_p
        accountreceivable = gt_accountreceivable_p
        accountpayable    = gt_accountpayable_p
        accounttax        = gt_accounttax_p
        currencyamount    = gt_currencyamount_p
        return            = gt_bapiret2_p.

    IF l_obj_key = '$'.
*      LOOP AT gt_bapiret2_p INTO gw_bapiret2_p
*               WHERE type = 'A' OR type = 'E' OR type = 'X'.
      l_status = icon_led_red.
*        EXIT.
*      ENDLOOP.

    ELSE.
      WAIT UP TO 10 SECONDS.

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = gc_x.

*      COMMIT WORK AND WAIT.

*     unblock invoice document
*     only unblock if there is no error
      UNASSIGN &amp;lt;gs_bsik&amp;gt;.
      LOOP AT gt_bsik ASSIGNING &amp;lt;gs_bsik&amp;gt;.
        &amp;lt;gs_bsik&amp;gt;-zlspr = space.
      ENDLOOP.
      UPDATE bsik FROM TABLE gt_bsik.
      COMMIT WORK.

      gw_check_result-belnr = l_obj_key+0(10).

      CLEAR l_status_count.
      DESCRIBE TABLE gt_bapiret2_p LINES l_result_count.

      l_status = icon_led_green.

    ENDIF.



  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Apr 2020 09:08:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205786#M1982293</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2020-04-02T09:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_DOCUMENT_POST cannot post/create new accounting documents</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205787#M1982294</link>
      <description>&lt;P&gt;For every 1 line of BSIK i retrieved, I created 4 lines of documents to be posted.&lt;/P&gt;&lt;P&gt;1st pair:&lt;/P&gt;&lt;P&gt;posting key 21 and 31 for vendor.&lt;/P&gt;&lt;P&gt;2nd pair:&lt;/P&gt;&lt;P&gt;posting key 25 and 50 for GL account.&lt;/P&gt;&lt;P&gt;So you can imagine for each loop of BSIK entry,&lt;/P&gt;&lt;P&gt;My first posting: i have 1 document header line, 2 entries in my account payable table and 2 entries in my currency table.&lt;/P&gt;&lt;P&gt;My second posting: i have 1 document header line, 2 entries in my account G/L table and 2 entries in my currency table.&lt;/P&gt;&lt;P&gt;Is this concept right?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 09:12:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205787#M1982294</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2020-04-02T09:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_ACC_DOCUMENT_POST cannot post/create new accounting documents</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205788#M1982295</link>
      <description>&lt;P&gt;The following is used after CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'&lt;BR /&gt; EXPORTING&lt;/P&gt;&lt;P&gt;wait = gc_x.&lt;/P&gt;&lt;P&gt;Although the BAPI state it is successful, no accounting documents gets created. I searched in FB03 on today entry date or table BKPF for today's entry but found none.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 09:18:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-acc-document-post-cannot-post-create-new-accounting-documents/m-p/12205788#M1982295</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2020-04-02T09:18:55Z</dc:date>
    </item>
  </channel>
</rss>

