Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

The typical problem with BAPI_ACC_DOCUMENT_POST

Former Member
0 Likes
1,447

Hi all!

Just my first post in the forum.

I'm using the BAPI_ACC_DOCUMENT_POST to generate an accountable document. As I've seen with a lot of people, the bapi is succesfully executed, but no doc. is created.

Can anyone have a look on my code and try to guide me through the right way to have my doc?

--- doc_head TYPE BAPIACHE09 ---

doc_head-obj_type = 'BKPFF'.

CONCATENATE SY-SYSID 'CLNT' SY-MANDT INTO

DOC_HEAD-OBJ_SYS.

doc_head-obj_key = '$'.

doc_head-COMP_CODE = P_BUKRS.

doc_head-DOC_TYPE = 'SA'.

doc_head-PSTNG_DATE = P_BUDAT.

doc_head-FISC_YEAR = sy-datum(4). "Periodo liquidación

doc_head-FIS_PERIOD = sy-datum+4(2).

doc_head-USERNAME = SY-UNAME.

doc_head-DOC_DATE = sy-datum.

doc_head-BUS_ACT = 'RFBU'.

--- w_bseg TYPE TABLE OF BAPIACGL09 ---

--- t_cur_am TYPE TABLE OF BAPIACCR09 ---

w_bseg-ITEMNO_ACC = '0001'.

w_bseg-GL_ACCOUNT = '0006230000'.

w_bseg-ALLOC_NMBR = P_REF.

w_bseg-stat_con = 'S'.

w_bseg-COSTCENTER = P_COST_CENTER.

w_bseg-TAX_CODE = 'S0'.

APPEND w_bseg.

CLEAR w_bseg-COSTCENTER.

t_cur_am-ITEMNO_ACC = '0001'.

t_cur_am-CURRENCY = 'EUR'.

t_cur_am-AMT_DOCCUR = '100'.

APPEND t_cur_am.

w_bseg-ITEMNO_ACC = '0002'.

w_bseg-ITEM_TEXT = TEXT-001.

w_bseg-GL_ACCOUNT = '0004000900'.

w_bseg-ALLOC_NMBR = P_TEXT.

w_bseg-stat_con = 'H'.

APPEND w_bseg.

  • Llenar importes

t_cur_am-ITEMNO_ACC = '0002'.

t_cur_am-CURRENCY = 'EUR'.

t_cur_am-AMT_DOCCUR = '100'.

APPEND t_cur_am.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

DOCUMENTHEADER = doc_head

  • CUSTOMERCPD =

  • CONTRACTHEADER =

IMPORTING

OBJ_TYPE = obj_type

OBJ_KEY = obj_key

OBJ_SYS = obj_sys

TABLES

ACCOUNTGL = w_bseg

  • ACCOUNTRECEIVABLE =

  • ACCOUNTPAYABLE =

  • ACCOUNTTAX =

CURRENCYAMOUNT = t_cur_am

  • CRITERIA =

  • VALUEFIELD =

  • EXTENSION1 =

RETURN = t_ret

  • PAYMENTCARD =

  • CONTRACTITEM =

  • EXTENSION2 =

  • REALESTATE =

.

b_wait = 'X'.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = b_wait

IMPORTING

RETURN = b_ret.

-

-


I get my "Document XXXXXXXXXX was Successfully created" but no BKPF record is created on the database. Any ideas?

Thank you very much!

Message was edited by: Angel Garcia

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,272

Hi,

Welcome to SDN!

I have encountered this problem before.

You should not pass anything for obj_type, obj_sys, and obj_key. Then SAP will assume that it has to generate a new document number.

Hope this helps,

Bhanu

6 REPLIES 6
Read only

Former Member
0 Likes
1,273

Hi,

Welcome to SDN!

I have encountered this problem before.

You should not pass anything for obj_type, obj_sys, and obj_key. Then SAP will assume that it has to generate a new document number.

Hope this helps,

Bhanu

Read only

0 Likes
1,272

Thanks for your reply, Bhanumurthy, but I've tried that solution, and the BAPI is telling me to fill those fields. Have I missed any additional field?

Regards!

Angel.

Read only

0 Likes
1,272

Hi Angel,

1. U code must be absolutely right.

2. The problem is with this general bapi.

3. I also faced the same problem,

but there is no solution for this

on SDN.

4. After posting the bapi, (also using commit)

the message says, Docuement xXX created,

but actually there is no document

in tables.

5. Even the Number Range is incremented,

but no document.

6. Its really a mystery for me.

regards,

amit m.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,272

Hi,

Check this link.It is explaining the BAPI with sample code.Kindly reward points by clicking the star on the left of reply,if it helps.

http://funciones.sapabap.cc/DocuFuncion.asp?Id=515

Read only

0 Likes
1,272

Hello Jayanthi Jayaraman,

I am also facing BAP_ACC_DOCUMENT_POST problem ,sometimes document posted message ,but there is no document.I am unable to access your link.please can you provide me the solution.my mail id is sridhar_88@yahoo.com or srinsap@gmail.com

http://funciones.sapabap.cc/DocuFuncion.asp?Id=515

Regards

Sridhar

Read only

0 Likes
1,272

I know this is an old thread, but I wanted to provide a link (for those searching for an answer in the future) to a good way to get the document number after calling BAPI_ACC_DOCUMENT_POST.

Please see my reply in the following SDN forum topic:

Cheers,

James Gaddis