Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
JonathanEemans
Active Contributor
27,393

Introduction


Standard SAP functionality allows parking accounting documents before finally posting these documents. Parking can be used to enter and store (in)complete documents in the SAP system, without carrying out extensive entry checks. These parked documents can be completed, checked and then posted at a later date.

When registering accounting documents via interface and not directly online in your SAP environment, the same business application programming interface (BAPI) is used as for posting accounting documents. This is BAPI_ACC_DOCUMENT_POST.

Some fields have to be filled with specific values to park accounting document via BAPI_ACC_DOCUMENT_POST. OSS note 2092366 explains how to park an accounting document using BAPI_ACC_DOCUMENT_POST.

 

Example program to park accounting document via BAPI_ACC_DOCUMENT_POST


I share with you a test program which parks an accounting document with vendor line using BAPI_ACC_DOCUMENT_POST. The fields to be changed to post in your SAP environment are marked with 'To be changed !'
!'*&---------------------------------------------------------------------*

*& Report ZTEST

*&---------------------------------------------------------------------*

*& Test program to park document using BAPI_ACC_DOCUMENT_POST

*&---------------------------------------------------------------------*

REPORT ZTEST.



* Work Areas

DATA: gs_documentheader TYPE bapiache09 ##NEEDED,

gs_accountpayable TYPE bapiacap09 ##NEEDED,

gs_currencyamount TYPE bapiaccr09 ##NEEDED,

gv_obj_key TYPE awkey ##NEEDED,

gs_err_tab TYPE bapi_msg ##NEEDED,

gs_return_format TYPE bapiret2 ##NEEDED.



* Tables

DATA: gt_documentheader TYPE STANDARD TABLE OF bapiache09 ##NEEDED,

gt_accountpayable TYPE STANDARD TABLE OF bapiacap09 ##NEEDED,

gt_currencyamount TYPE STANDARD TABLE OF bapiaccr09 ##NEEDED,

gt_return TYPE STANDARD TABLE OF bapiret2 ##NEEDED.



* Fill header structure

gs_documentheader-bus_act = 'RFBV'. "Business Transaction set as per SAP Note 2092366

gs_documentheader-username = sy-uname. "User name

gs_documentheader-header_txt = 'TEST'. "Document Header Text

gs_documentheader-comp_code = 'BEN0'. "Company Code - To be changed!

gs_documentheader-doc_date = sy-datum. "Document Date in Document

gs_documentheader-trans_date = sy-datum. "Translation Date

gs_documentheader-pstng_date = sy-datum. "Posting Date in the Document

gs_documentheader-doc_type = 'KR'. "Document Type - To be changed!

gs_documentheader-ref_doc_no = 'TEST'. "Reference

gs_documentheader-doc_status = '2'. "Document status set as per SAP Note 2092366



APPEND gs_documentheader TO gt_documentheader.



* Fill vendor structure

gs_accountpayable-itemno_acc = '0001'. "Accounting Document Line Item Number

gs_accountpayable-vendor_no = '0000895746'. "Account Number of Vendor or Creditor - To be changed!

gs_accountpayable-partner_bk = '0001'. "Partner Bank Type - To be changed!

gs_accountpayable-pmnttrms = '00AA'. "Terms of Payment Key - To be changed!

gs_accountpayable-pmnt_block = ''. "Payment block key

gs_accountpayable-pymt_meth = ''. "Payment method

gs_accountpayable-comp_code = 'BEN0'. "Company Code - To be changed!



APPEND gs_accountpayable TO gt_accountpayable.



* Fill amount structure



gs_currencyamount-itemno_acc = '0001'. "Accounting Document Line Item Number

gs_currencyamount-curr_type = '00'. "Currency Type and Valuation View

gs_currencyamount-currency = 'EUR'. "Currency Key

gs_currencyamount-amt_doccur = '1000.00'. "Amount



APPEND gs_currencyamount TO gt_currencyamount.



* Call BAPI to park the document



CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = gs_documentheader

IMPORTING

obj_key = gv_obj_key

TABLES

accountpayable = gt_accountpayable

currencyamount = gt_currencyamount

return = gt_return.



CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'. "Set flag for wait for so that commit happens successfully

 

Conclusion


BAPI_ACC_DOCUMENT_POST can be used to park accounting documents in SAP.

 

Useful reference


OSS note 2092366: https://launchpad.support.sap.com/#/notes/2092366
15 Comments
ewilder
Discoverer
0 Kudos
Hi Jonathan! Excellent article, very helpful!

I run the BAPI and everything works great. I get the document number. But I have a problem: i cannot edit the document that was just created with transaction FV60. I can only edit it with FBV2. I debug the BAPI, and I found that there is a condition that checks for the transaction (it means, that you cannot change in extension2 the value of "TCODE" or in BTE RWBAPI01).

Do you have an idea how we can edit the document with FV60 after running the BAPI?

Thanks in advance,

Esteban
JonathanEemans
Active Contributor
Hi,

It's never possible to change a parked document via transaction FV60. In order to change a parked document, you should use transaction FBV2 or another transaction allowing to change parked documents.

 

Best regards,

Jonathan
mohit_dev
Contributor
0 Kudos

I found the answer; if we dont fill the HEADER-DOC_STATUS, the BAPI will post the document, instead of posting.


Hi Jonathan,

Thanks for the post.

My question is, what if someone wants to direcly post the document?

What parameters should be filled?

Best Regards,
Mohit Sharma

0 Kudos
Hi Jonathan! Excellent article, congrats!

Please, do you know if this way the Workflow is triggered?

I went through the following situation:

If I create a parked document by the FV60, the Workflow is triggered.
But if I create via BAPI (following its source code) the Workflow is not triggered.

 

I appreciate all your help or comments.

Thank you,

Fellipe
JonathanEemans
Active Contributor
0 Kudos
Hi Fellipe,

I don't have experience with triggering workflow from document parking via BAPI. But in my opinion the object type FIPP can be used to trigger workflow.

When I search for 'Accounting Interface FIPP' in SAP Support I get results, so it should be possible.

Best regards,
Jonathan
aditya_palekar
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hello Jonathan,

 

Is it possible to post an Accounting Document which is parked using BAPI_ACC_DOCUMENT_POST. If yes then it would be helpful to know which specific parameters to transfer.

Thanks,

Aditya
0 Kudos
Hi Jonathan,

Do you have any idea on a BAPI ,which can edit and post /save a Parked document as Completed.

 

 

BR,

Tanuj K Patnaik

 

 
Jaman
Participant
0 Kudos
Hi Aditya,

Did you find solution for this?

Thanks,

Ahamed
PeterJonker
Active Contributor
0 Kudos
Hi Jonathan,

Nice blog. It works as a charm, except for one specific situation.

I encounter a problem when posting a vendor invoice which contains cross company items.  Whenever I park them with the BAPI, the VAT of the cross company items is added to the first item and then when you post the document it fails because of the balance not being correct. The BAPI_ACC_DOCUMENT_CHECK does not show any errors.

Do you know what should be filled different (if any) when the vendor invoice contains cross company items ? Or is this an error in the BAPI (what I think it is).

Regards,

 

Peter Jonker
JonathanEemans
Active Contributor
0 Kudos
Hi Peter,


Thanks for your feedback.

If you get the error that balance of the document is not zero, this is generally due to data or configuration issue.

Were you able to park the the document with the same data manually (so not via BAPI)?

Best regards,
Jonathan
JonathanEemans
Active Contributor
0 Kudos

Hi Tanuj,

SAP note 2092366 provides the information on the field DOC_STATUS to the structure DOCUMENTHEADER of the BAPI:

  • Parked document: 2
  • Fully saved document: 3
  • Posted document: 4 or space
  • Parked document for which only the transaction currency amounts are transferred during posting: A
  • Completely saved document for which only the transaction currency amounts are transferred during posting: B

 

Additionally, pablo.casamayor provided a sample code for saving a MM incoming invoice as completed. Link: https://answers.sap.com/questions/3957721/bapi-to-save-as-completed-an-incoming-invoice.html

Best regards,
Jonathan

JonathanEemans
Active Contributor
0 Kudos
Hi,

SAP note 2092366 provides the information on the field DOC_STATUS to the structure DOCUMENTHEADER of the BAPI:

  • Parked document: 2

  • Fully saved document: 3

  • Posted document: 4 or space

  • Parked document for which only the transaction currency amounts are transferred during posting: A

  • Completely saved document for which only the transaction currency amounts are transferred during posting: B


Best regards,
Jonathan
PeterJonker
Active Contributor
0 Kudos
Hi Jonathan,

Thanks for your quick reply.

A little background.  We have an old program, a file interface, that uses BDC to park the vendor invoice. I have now developed this in AIF (Application Interface Framework) and call a BAPI to park the document.  It works great except for the previous described situation with cross company items. The old program which use BDC parks the document correct (w/o adding the VAT of the cross company items to the first item).

I also have created a ticket with SAP because I believe this is a shortcoming of the BAPI, but I am not sure.  That's the reason why I asked you this question.

Peter

 
JonathanEemans
Active Contributor
0 Kudos
Hi,

Check out function module PRELIMINARY_POSTING_POST.

 

Best regards,
Jonathan
Jaman
Participant
0 Kudos
Hi Jonathan,

Thanks for your reply.

Is there any API/Odata Service available for the same.

It would be helpful Since we work in BTP ABAP Environment.

Thanks,

Ahamed
Labels in this area