<?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: Sample Code for BAPI_ACC_DOCUMENT_POST in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890585#M679297</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;Here is a sample program which posts FI document along with CO-PA characteristics.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT ZRBC060 .
*
DATA: doc_header LIKE BAPIACHE09,
      criteria   LIKE BAPIACKEC9 OCCURS 0 WITH HEADER LINE,
      doc_item   LIKE BAPIACGL09 OCCURS 0 WITH HEADER LINE,
      doc_values LIKE BAPIACCR09 OCCURS 0 WITH HEADER LINE,
      return     LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
      extension1 like BAPIACEXTC occurs 0 with header line,
      obj_type   LIKE bapiache08-obj_type,
      obj_key    LIKE bapiache02-obj_key,
      obj_sys    LIKE bapiache02-obj_sys,
      docnum     LIKE bkpf-belnr.
*
* Fill Document Header
doc_header-bus_act = 'RFBU'.
*doc_header-obj_type = 'BKPFF'.
*doc_header-obj_key = 'AAAABBBB'.
*doc_header-obj_sys = 'NLD220'.
doc_header-username = sy-uname.
doc_header-header_txt = 'TEST BOC BAPI POSTING'.
doc_header-comp_code = 'IN10'.
doc_header-doc_date = '20060127'.
doc_header-pstng_date = sy-datlo.
doc_header-doc_type = 'SA'.
* Fill Line 1 of Document Item
doc_item-itemno_acc = '1'.
doc_item-gl_account = '0000500001'.
doc_item-pstng_date = sy-datum.
doc_item-item_text = 'TEST POSTING DEBIT ITEM'.
doc_item-costcenter = ''.
doc_item-quantity = '1'.
doc_item-base_uom = 'ST'.
*doc_item-stat_con = 'X'.
*doc_item-orderid = 'M5253'.
*_____________
*doc_item-comp_code = 'IN01'.
*_______________
APPEND doc_item.
CLEAR doc_item.
* Fill Line 2 of Document Item
doc_item-itemno_acc = '2'.
doc_item-gl_account = '0000210072'.
doc_item-pstng_date = sy-datlo.
doc_item-item_text = 'TEST POSTING CREDIT ITEM'.
*doc_item-stat_con = 'X'.
*doc_item-costcenter = '0000201681'.
*_______________
*doc_item-comp_code = 'IN01'.
*_______________
APPEND doc_item.
CLEAR doc_item.
* Fill Line 1 of Document Value.
doc_values-itemno_acc = '1'.
doc_values-currency_iso = 'INR'.
doc_values-amt_doccur = '0.02-'.
APPEND doc_values.
CLEAR doc_values.
* Fill Line 2 of Document Value
doc_values-itemno_acc = '2'.
doc_values-currency_iso = 'INR'.
doc_values-amt_doccur = '0.02'.
APPEND doc_values.
CLEAR doc_values.
* Add tax code in extension1 table.
extension1-field1 = 'BAPI CALL'.
APPEND EXTENSION1.
*
* Fill CRITERIA for CO-PA
*
refresh criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'ARTNR'.
criteria-CHARACTER	= '000000000001312251'.
Append criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'WERKS'.
criteria-CHARACTER	= 'IN91'.
Append criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'KNDNR'.
criteria-CHARACTER	= '0000000016'.
Append criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'FKART'.
criteria-CHARACTER	= 'ZIN2'.
Append criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'KAUFN'.
criteria-CHARACTER	= '0000000633'.
Append criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'KDPOS'.
criteria-CHARACTER	= '000010'.
Append criteria.
*criteria-ITEMNO_ACC = '1'.
*criteria-FIELDNAME	= 'VKGRP'.
*criteria-CHARACTER	= '009'.
**Append criteria.
*
* All tables filled - now call BAPI.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
  EXPORTING
    documentheader       = doc_header
  IMPORTING
    OBJ_TYPE             = doc_header-obj_type
    OBJ_KEY              = doc_header-obj_key
    OBJ_SYS              = doc_header-obj_sys
  TABLES
    criteria             = criteria
    accountgl            = doc_item
    currencyamount       = doc_values
    return               = return
    EXTENSION1           = EXTENSION1.
*
LOOP AT return WHERE type = 'E'.
  EXIT.
ENDLOOP.
*
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
  EXPORTING
    documentheader       = doc_header
  IMPORTING
    OBJ_TYPE             = doc_header-obj_type
    OBJ_KEY              = doc_header-obj_key
    OBJ_SYS              = doc_header-obj_sys
  TABLES
    criteria             = criteria
    accountgl            = doc_item
    currencyamount       = doc_values
    return               = return
    EXTENSION1           = EXTENSION1.
LOOP AT return WHERE type = 'E'.
  EXIT.
ENDLOOP.
IF sy-subrc EQ 0.
  WRITE: / 'BAPI call failed - debug and fix!'.
ELSE.
  CLEAR return.
  REFRESH return.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
*   WAIT          =
   IMPORTING
     return        = return.
  WRITE: / 'BAPI call worked!!'.
  WRITE: / doc_header-obj_key, ' posted'.
ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raju chitale&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Oct 2007 08:49:14 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-18T08:49:14Z</dc:date>
    <item>
      <title>Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890576#M679288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you give me a sample code in which we have to post an FI document with CO-PA data using BAPI_ACC_DOCUMENT_POST. Currently I'm having trouble posting a document with profit segment. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;Andre&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 01:50:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890576#M679288</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-18T01:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890577#M679289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this link -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?p=76232&amp;amp;sid=b6519d31b5097f49dc303d03b35eed43" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?p=76232&amp;amp;sid=b6519d31b5097f49dc303d03b35eed43&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=137643&amp;amp;highlight=bapiaccdocumentpost" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=137643&amp;amp;highlight=bapiaccdocumentpost&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It also tells that the documentation is not clear so which all errors you can avoid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sample code -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REFRESH : i_accountgl,&lt;/P&gt;&lt;P&gt;i_accountreceivable,&lt;/P&gt;&lt;P&gt;i_currencyamount,&lt;/P&gt;&lt;P&gt;i_return.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR : wa_documentheader,&lt;/P&gt;&lt;P&gt;wa_accountgl,&lt;/P&gt;&lt;P&gt;wa_accountreceivable,&lt;/P&gt;&lt;P&gt;wa_currencyamount,&lt;/P&gt;&lt;P&gt;wa_return,&lt;/P&gt;&lt;P&gt;g_shipdate,&lt;/P&gt;&lt;P&gt;g_matdate,&lt;/P&gt;&lt;P&gt;g_amount.&lt;/P&gt;&lt;P&gt;*changing the format of the shipment date from MM/DD/YYYY TO YYYYMMDD&lt;/P&gt;&lt;P&gt;CONCATENATE p_wa_item-shipdate+6(4)&lt;/P&gt;&lt;P&gt;p_wa_item-shipdate+0(2)&lt;/P&gt;&lt;P&gt;p_wa_item-shipdate+3(2)&lt;/P&gt;&lt;P&gt;INTO g_shipdate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*changing the format of the loan maturity date from MM/DD/YYYY TO YYYYMMDD&lt;/P&gt;&lt;P&gt;CONCATENATE p_wa_item-matdate+6(4)&lt;/P&gt;&lt;P&gt;p_wa_item-matdate+0(2)&lt;/P&gt;&lt;P&gt;p_wa_item-matdate+3(2)&lt;/P&gt;&lt;P&gt;INTO g_matdate.&lt;/P&gt;&lt;P&gt;*changing the format of the due date from MM/DD/YYYY TO YYYY.MM.DD&lt;/P&gt;&lt;P&gt;CONCATENATE p_wa_item-duedate+6(4)&lt;/P&gt;&lt;P&gt;c_dot&lt;/P&gt;&lt;P&gt;p_wa_item-duedate+0(2)&lt;/P&gt;&lt;P&gt;c_dot&lt;/P&gt;&lt;P&gt;p_wa_item-duedate+3(2)&lt;/P&gt;&lt;P&gt;INTO p_wa_item-duedate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*assignment of credit/debit indicator and document type(invoice/credit memo)&lt;/P&gt;&lt;P&gt;IF p_wa_item-amount LT 0.&lt;/P&gt;&lt;P&gt;g_credeb_ind = c_debit -&lt;/P&gt;&lt;HR originaltext="---" /&gt;&lt;P&gt;S.&lt;/P&gt;&lt;P&gt;g_doctyp = c_doctypcreditmemo DG.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;g_credeb_ind = c_credit H.&lt;/P&gt;&lt;P&gt;g_doctyp = c_doctypinvoice. DR&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_documentheader-bus_act = c_busact. RFBU&lt;/P&gt;&lt;P&gt;wa_documentheader-username = sy-uname.&lt;/P&gt;&lt;P&gt;wa_documentheader-comp_code = p_wa_item-compcode.&lt;/P&gt;&lt;P&gt;wa_documentheader-doc_date = g_shipdate.&lt;/P&gt;&lt;P&gt;wa_documentheader-pstng_date = p_posdat.&lt;/P&gt;&lt;P&gt;wa_documentheader-ref_doc_no = p_wa_item-docnum.&lt;/P&gt;&lt;P&gt;wa_documentheader-doc_type = g_doctyp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_accountgl-itemno_acc = c_glitemno. 2&lt;/P&gt;&lt;P&gt;wa_accountgl-gl_account = p_saknr.&lt;/P&gt;&lt;P&gt;wa_accountgl-comp_code = p_wa_item-compcode.&lt;/P&gt;&lt;P&gt;wa_accountgl-de_cre_ind = g_credeb_ind.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND wa_accountgl TO i_accountgl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_accountreceivable-itemno_acc = c_hditemno. 1&lt;/P&gt;&lt;P&gt;wa_accountreceivable-customer = p_kunnr.&lt;/P&gt;&lt;P&gt;wa_accountreceivable-comp_code = p_wa_item-compcode.&lt;/P&gt;&lt;P&gt;wa_accountreceivable-bline_date = g_matdate.&lt;/P&gt;&lt;P&gt;wa_accountreceivable-pmnttrms = p_zterm.&lt;/P&gt;&lt;P&gt;wa_accountreceivable-pmnt_block = c_blockpayment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND wa_accountreceivable TO i_accountreceivable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_currencyamount-itemno_acc = c_hditemno. 1&lt;/P&gt;&lt;P&gt;wa_currencyamount-curr_type = c_currtyp. 00&lt;/P&gt;&lt;P&gt;wa_currencyamount-amt_doccur = p_wa_item-amount.&lt;/P&gt;&lt;P&gt;wa_currencyamount-currency = p_wa_item-currency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND wa_currencyamount TO i_currencyamount.&lt;/P&gt;&lt;P&gt;g_amount = p_wa_item-amount.&lt;/P&gt;&lt;P&gt;IF p_wa_item-amount GT 0.&lt;/P&gt;&lt;P&gt;CONCATENATE c_minus p_wa_item-amount INTO p_wa_item-amount.&lt;/P&gt;&lt;P&gt;CONDENSE p_wa_item-amount NO-GAPS.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;REPLACE FIRST OCCURRENCE OF c_minus IN p_wa_item-amount WITH space.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;wa_currencyamount-itemno_acc = c_glitemno.&lt;/P&gt;&lt;P&gt;wa_currencyamount-curr_type = c_currtyp.&lt;/P&gt;&lt;P&gt;wa_currencyamount-amt_doccur = p_wa_item-amount.&lt;/P&gt;&lt;P&gt;wa_currencyamount-currency = p_wa_item-currency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND wa_currencyamount TO i_currencyamount.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*bapi for posting the invoice and credit memo documents&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;documentheader = wa_documentheader&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;accountgl = i_accountgl&lt;/P&gt;&lt;P&gt;accountreceivable = i_accountreceivable&lt;/P&gt;&lt;P&gt;currencyamount = i_currencyamount&lt;/P&gt;&lt;P&gt;return = i_return.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for more information:&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="101765"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="137111"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="1512737"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="78988"&gt;&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ashish&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Ashish Gundawar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 01:55:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890577#M679289</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-18T01:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890578#M679290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ashish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do have an example wherein you must post an FI document having CO-PA (Profit Segment Data). Currently I am not successful posting it. I've filled up the CRITERIA table of the BAPI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Andre&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 02:10:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890578#M679290</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-18T02:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890579#M679291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this link -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It might help. Code is at the end.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://translate.google.com/translate?hl=en&amp;amp;sl=de&amp;amp;u=http://www.apentia-forum.de/viewtopic.php%3Fp%3D41991&amp;amp;sa=X&amp;amp;oi=translate&amp;amp;resnum=8&amp;amp;ct=result&amp;amp;prev=/search%3Fq%3DBAPI_ACC_DOCUMENT_POST%2BCO-PA%26start%3D10%26hl%3Den%26sa%3DN" target="test_blank"&gt;http://translate.google.com/translate?hl=en&amp;amp;sl=de&amp;amp;u=http://www.apentia-forum.de/viewtopic.php%3Fp%3D41991&amp;amp;sa=X&amp;amp;oi=translate&amp;amp;resnum=8&amp;amp;ct=result&amp;amp;prev=/search%3Fq%3DBAPI_ACC_DOCUMENT_POST%2BCO-PA%26start%3D10%26hl%3Den%26sa%3DN&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ashish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 02:19:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890579#M679291</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-18T02:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890580#M679292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ashish ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I still cant find any sample regarding posting of FI Document with CO-PA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Andre&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 02:48:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890580#M679292</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-18T02:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890581#M679293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry Andre, could not get anything more.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ashish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 02:53:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890581#M679293</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-18T02:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890582#M679294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks anyway. I really appreciate your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Andre&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 03:13:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890582#M679294</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-18T03:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890583#M679295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please help...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 06:12:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890583#M679295</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-18T06:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890584#M679296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  For a posting to CO-PA you have to assign a tables containing data for&lt;/P&gt;&lt;P&gt;characteristics and value fields in the parameters CRITERIA and&lt;/P&gt;&lt;P&gt;VALUEFIELD of function BAPI_ACC_DOCUMENT_POST&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Waman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 08:21:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890584#M679296</guid>
      <dc:creator>waman_shirwaicar</dc:creator>
      <dc:date>2007-10-18T08:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890585#M679297</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;Here is a sample program which posts FI document along with CO-PA characteristics.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT ZRBC060 .
*
DATA: doc_header LIKE BAPIACHE09,
      criteria   LIKE BAPIACKEC9 OCCURS 0 WITH HEADER LINE,
      doc_item   LIKE BAPIACGL09 OCCURS 0 WITH HEADER LINE,
      doc_values LIKE BAPIACCR09 OCCURS 0 WITH HEADER LINE,
      return     LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
      extension1 like BAPIACEXTC occurs 0 with header line,
      obj_type   LIKE bapiache08-obj_type,
      obj_key    LIKE bapiache02-obj_key,
      obj_sys    LIKE bapiache02-obj_sys,
      docnum     LIKE bkpf-belnr.
*
* Fill Document Header
doc_header-bus_act = 'RFBU'.
*doc_header-obj_type = 'BKPFF'.
*doc_header-obj_key = 'AAAABBBB'.
*doc_header-obj_sys = 'NLD220'.
doc_header-username = sy-uname.
doc_header-header_txt = 'TEST BOC BAPI POSTING'.
doc_header-comp_code = 'IN10'.
doc_header-doc_date = '20060127'.
doc_header-pstng_date = sy-datlo.
doc_header-doc_type = 'SA'.
* Fill Line 1 of Document Item
doc_item-itemno_acc = '1'.
doc_item-gl_account = '0000500001'.
doc_item-pstng_date = sy-datum.
doc_item-item_text = 'TEST POSTING DEBIT ITEM'.
doc_item-costcenter = ''.
doc_item-quantity = '1'.
doc_item-base_uom = 'ST'.
*doc_item-stat_con = 'X'.
*doc_item-orderid = 'M5253'.
*_____________
*doc_item-comp_code = 'IN01'.
*_______________
APPEND doc_item.
CLEAR doc_item.
* Fill Line 2 of Document Item
doc_item-itemno_acc = '2'.
doc_item-gl_account = '0000210072'.
doc_item-pstng_date = sy-datlo.
doc_item-item_text = 'TEST POSTING CREDIT ITEM'.
*doc_item-stat_con = 'X'.
*doc_item-costcenter = '0000201681'.
*_______________
*doc_item-comp_code = 'IN01'.
*_______________
APPEND doc_item.
CLEAR doc_item.
* Fill Line 1 of Document Value.
doc_values-itemno_acc = '1'.
doc_values-currency_iso = 'INR'.
doc_values-amt_doccur = '0.02-'.
APPEND doc_values.
CLEAR doc_values.
* Fill Line 2 of Document Value
doc_values-itemno_acc = '2'.
doc_values-currency_iso = 'INR'.
doc_values-amt_doccur = '0.02'.
APPEND doc_values.
CLEAR doc_values.
* Add tax code in extension1 table.
extension1-field1 = 'BAPI CALL'.
APPEND EXTENSION1.
*
* Fill CRITERIA for CO-PA
*
refresh criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'ARTNR'.
criteria-CHARACTER	= '000000000001312251'.
Append criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'WERKS'.
criteria-CHARACTER	= 'IN91'.
Append criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'KNDNR'.
criteria-CHARACTER	= '0000000016'.
Append criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'FKART'.
criteria-CHARACTER	= 'ZIN2'.
Append criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'KAUFN'.
criteria-CHARACTER	= '0000000633'.
Append criteria.
criteria-ITEMNO_ACC = '1'.
criteria-FIELDNAME	= 'KDPOS'.
criteria-CHARACTER	= '000010'.
Append criteria.
*criteria-ITEMNO_ACC = '1'.
*criteria-FIELDNAME	= 'VKGRP'.
*criteria-CHARACTER	= '009'.
**Append criteria.
*
* All tables filled - now call BAPI.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
  EXPORTING
    documentheader       = doc_header
  IMPORTING
    OBJ_TYPE             = doc_header-obj_type
    OBJ_KEY              = doc_header-obj_key
    OBJ_SYS              = doc_header-obj_sys
  TABLES
    criteria             = criteria
    accountgl            = doc_item
    currencyamount       = doc_values
    return               = return
    EXTENSION1           = EXTENSION1.
*
LOOP AT return WHERE type = 'E'.
  EXIT.
ENDLOOP.
*
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
  EXPORTING
    documentheader       = doc_header
  IMPORTING
    OBJ_TYPE             = doc_header-obj_type
    OBJ_KEY              = doc_header-obj_key
    OBJ_SYS              = doc_header-obj_sys
  TABLES
    criteria             = criteria
    accountgl            = doc_item
    currencyamount       = doc_values
    return               = return
    EXTENSION1           = EXTENSION1.
LOOP AT return WHERE type = 'E'.
  EXIT.
ENDLOOP.
IF sy-subrc EQ 0.
  WRITE: / 'BAPI call failed - debug and fix!'.
ELSE.
  CLEAR return.
  REFRESH return.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
*   WAIT          =
   IMPORTING
     return        = return.
  WRITE: / 'BAPI call worked!!'.
  WRITE: / doc_header-obj_key, ' posted'.
ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raju chitale&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2007 08:49:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890585#M679297</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-18T08:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890586#M679298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Raju,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am encounterin these problems when I use the BAPI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error in document: BKPFF $ SFDCLNT100    &lt;/P&gt;&lt;P&gt;Complete PA transfer structure FI        &lt;/P&gt;&lt;P&gt;Profitability segment being derived again&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Andre&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Oct 2007 06:01:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890586#M679298</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-22T06:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Code for BAPI_ACC_DOCUMENT_POST</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890587#M679299</link>
      <description>&lt;P&gt;Same procedure updated as per 23-Feb-23&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*&lt;BR /&gt;*&amp;amp; Report ZAM_BAPI_JOURNALENTRY&lt;BR /&gt;*&amp;amp;---------------------------------------------------------------------*&lt;BR /&gt;*&amp;amp;&lt;BR /&gt;*&amp;amp;---------------------------------------------------------------------*&lt;BR /&gt;REPORT ZAM_BAPI_JOURNALENTRY.&lt;BR /&gt;DATA: doc_header LIKE BAPIACHE09,&lt;BR /&gt;*      criteria   LIKE BAPIACKEC9 OCCURS 0 WITH HEADER LINE,&lt;BR /&gt;      doc_item   LIKE BAPIACGL09 OCCURS 0 WITH HEADER LINE,&lt;BR /&gt;      doc_values LIKE BAPIACCR09 OCCURS 0 WITH HEADER LINE,&lt;BR /&gt;      return     LIKE bapiret2 OCCURS 0 WITH HEADER LINE,&lt;BR /&gt;*      extension1 like BAPIACEXTC occurs 0 with header line,&lt;BR /&gt;      obj_type   LIKE bapiache08-obj_type,&lt;BR /&gt;      obj_key    TYPE BAPIACHE09-OBJ_KEY,&lt;BR /&gt;      obj_sys    LIKE bapiache02-obj_sys,&lt;BR /&gt;      docnum     LIKE bkpf-belnr.&lt;BR /&gt;*&lt;BR /&gt;* Fill Document Header&lt;BR /&gt;doc_header-bus_act = 'RFBU'.&lt;BR /&gt;*doc_header-obj_type = 'BKPFF'.&lt;BR /&gt;*doc_header-obj_key = 'AAAABBBB'.&lt;BR /&gt;*doc_header-obj_sys = 'NLD220'.&lt;BR /&gt;doc_header-username = sy-uname.&lt;BR /&gt;doc_header-header_txt = 'AK TEST BOC BAPI POSTING 01'.&lt;BR /&gt;doc_header-comp_code = '1000'.&lt;BR /&gt;doc_header-doc_date = '20230221'.&lt;BR /&gt;doc_header-pstng_date = sy-datlo.&lt;BR /&gt;doc_header-doc_type = 'SA'.&lt;BR /&gt;* Fill Line 1 of Document Item&lt;BR /&gt;doc_item-itemno_acc = '1'.&lt;BR /&gt;doc_item-gl_account = '5410000004'.&lt;BR /&gt;doc_item-pstng_date = sy-datum.&lt;BR /&gt;doc_item-item_text = 'TEST POSTING DEBIT ITEM'.&lt;BR /&gt;doc_item-costcenter = '1000001001'.&lt;BR /&gt;*doc_item-quantity = '1'.&lt;BR /&gt;*doc_item-base_uom = 'ST'.&lt;BR /&gt;*doc_item-stat_con = 'X'.&lt;BR /&gt;*doc_item-orderid = 'M5253'.&lt;BR /&gt;*_____________&lt;BR /&gt;*doc_item-comp_code = 'IN01'.&lt;BR /&gt;*_______________&lt;BR /&gt;APPEND doc_item.&lt;BR /&gt;CLEAR doc_item.&lt;BR /&gt;* Fill Line 2 of Document Item&lt;BR /&gt;doc_item-itemno_acc = '2'.&lt;BR /&gt;doc_item-gl_account = '3010000001'.&lt;BR /&gt;doc_item-pstng_date = sy-datlo.&lt;BR /&gt;doc_item-item_text = 'TEST POSTING CREDIT ITEM'.&lt;BR /&gt;*doc_item-stat_con = 'X'.&lt;BR /&gt;*doc_item-costcenter = '0000201681'.&lt;BR /&gt;*_______________&lt;BR /&gt;*doc_item-comp_code = 'IN01'.&lt;BR /&gt;*_______________&lt;BR /&gt;APPEND doc_item.&lt;BR /&gt;CLEAR doc_item.&lt;BR /&gt;* Fill Line 1 of Document Value.&lt;BR /&gt;doc_values-itemno_acc = '1'.&lt;BR /&gt;doc_values-currency_iso = 'PKR'.&lt;BR /&gt;doc_values-amt_doccur = '10'.&lt;BR /&gt;APPEND doc_values.&lt;BR /&gt;CLEAR doc_values.&lt;BR /&gt;* Fill Line 2 of Document Value&lt;BR /&gt;doc_values-itemno_acc = '2'.&lt;BR /&gt;doc_values-currency_iso = 'PKR'.&lt;BR /&gt;doc_values-amt_doccur = '10-'.&lt;BR /&gt;APPEND doc_values.&lt;BR /&gt;CLEAR doc_values.&lt;BR /&gt;* Add tax code in extension1 table.&lt;BR /&gt;*extension1-field1 = 'BAPI CALL'.&lt;BR /&gt;*APPEND EXTENSION1.&lt;BR /&gt;**&lt;BR /&gt;** Fill CRITERIA for CO-PA&lt;BR /&gt;**&lt;BR /&gt;*refresh criteria.&lt;BR /&gt;*criteria-ITEMNO_ACC = '1'.&lt;BR /&gt;*criteria-FIELDNAME  = 'ARTNR'.&lt;BR /&gt;*criteria-CHARACTER  = '000000000001312251'.&lt;BR /&gt;*Append criteria.&lt;BR /&gt;*criteria-ITEMNO_ACC = '1'.&lt;BR /&gt;*criteria-FIELDNAME  = 'WERKS'.&lt;BR /&gt;*criteria-CHARACTER  = 'IN91'.&lt;BR /&gt;*Append criteria.&lt;BR /&gt;*criteria-ITEMNO_ACC = '1'.&lt;BR /&gt;*criteria-FIELDNAME  = 'KNDNR'.&lt;BR /&gt;*criteria-CHARACTER  = '0000000016'.&lt;BR /&gt;*Append criteria.&lt;BR /&gt;*criteria-ITEMNO_ACC = '1'.&lt;BR /&gt;*criteria-FIELDNAME  = 'FKART'.&lt;BR /&gt;*criteria-CHARACTER  = 'ZIN2'.&lt;BR /&gt;*Append criteria.&lt;BR /&gt;*criteria-ITEMNO_ACC = '1'.&lt;BR /&gt;*criteria-FIELDNAME  = 'KAUFN'.&lt;BR /&gt;*criteria-CHARACTER  = '0000000633'.&lt;BR /&gt;*Append criteria.&lt;BR /&gt;*criteria-ITEMNO_ACC = '1'.&lt;BR /&gt;*criteria-FIELDNAME  = 'KDPOS'.&lt;BR /&gt;*criteria-CHARACTER  = '000010'.&lt;BR /&gt;*Append criteria.&lt;BR /&gt;**criteria-ITEMNO_ACC = '1'.&lt;BR /&gt;**criteria-FIELDNAME  = 'VKGRP'.&lt;BR /&gt;**criteria-CHARACTER  = '009'.&lt;BR /&gt;***Append criteria.&lt;BR /&gt;*&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;* All tables filled - now call BAPI.&lt;BR /&gt;CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'&lt;BR /&gt;  EXPORTING&lt;BR /&gt;    documentheader          = doc_header&lt;BR /&gt;*   CUSTOMERCPD             =&lt;BR /&gt;*   CONTRACTHEADER          =&lt;BR /&gt;  tables&lt;BR /&gt;   ACCOUNTGL               = doc_item&lt;BR /&gt;*   ACCOUNTRECEIVABLE       =&lt;BR /&gt;*   ACCOUNTPAYABLE          =&lt;BR /&gt;*   ACCOUNTTAX              =&lt;BR /&gt;   CURRENCYAMOUNT          = doc_values&lt;BR /&gt;*   CRITERIA                =&lt;BR /&gt;*   VALUEFIELD              =&lt;BR /&gt;*   EXTENSION1              =&lt;BR /&gt;    return                  = return&lt;BR /&gt;*   PAYMENTCARD             =&lt;BR /&gt;*   CONTRACTITEM            =&lt;BR /&gt;*   EXTENSION2              =&lt;BR /&gt;*   REALESTATE              =&lt;BR /&gt;*   ACCOUNTWT               =&lt;BR /&gt;          .&lt;BR /&gt;&lt;BR /&gt;LOOP AT return WHERE type = 'E'.&lt;BR /&gt;  EXIT.&lt;BR /&gt;ENDLOOP.&lt;BR /&gt;&lt;BR /&gt;"call BAPI to post the document&lt;BR /&gt;CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'&lt;BR /&gt;  EXPORTING&lt;BR /&gt;    documentheader       = doc_header&lt;BR /&gt;  IMPORTING&lt;BR /&gt;*    OBJ_TYPE             = doc_header-obj_type&lt;BR /&gt;    OBJ_KEY              = doc_header-obj_key&lt;BR /&gt;*    OBJ_SYS              = doc_header-obj_sys&lt;BR /&gt;  TABLES&lt;BR /&gt;*    criteria             = criteria&lt;BR /&gt;    accountgl            = doc_item&lt;BR /&gt;    currencyamount       = doc_values&lt;BR /&gt;    return               = return&lt;BR /&gt;*    EXTENSION1           = EXTENSION1&lt;BR /&gt;    .&lt;BR /&gt;LOOP AT return WHERE type = 'E'.&lt;BR /&gt;  EXIT.&lt;BR /&gt;ENDLOOP.&lt;BR /&gt;IF sy-subrc EQ 0.&lt;BR /&gt;  WRITE: / 'BAPI call failed - debug and fix!'.&lt;BR /&gt;ELSE.&lt;BR /&gt;  CLEAR return.&lt;BR /&gt;  REFRESH return.&lt;BR /&gt;  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'&lt;BR /&gt;* EXPORTING&lt;BR /&gt;*   WAIT          =&lt;BR /&gt;   IMPORTING&lt;BR /&gt;     return        = return.&lt;BR /&gt;  WRITE: / 'BAPI call worked!!'.&lt;BR /&gt;  WRITE: / doc_header-obj_key, ' posted'.&lt;BR /&gt;ENDIF.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 07:53:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-bapi-acc-document-post/m-p/2890587#M679299</guid>
      <dc:creator>Khan</dc:creator>
      <dc:date>2023-02-23T07:53:03Z</dc:date>
    </item>
  </channel>
</rss>

