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

Invoice Posting via BAPI

Former Member
0 Likes
2,212

Hi Experts,

I am using BAPI_ACC_DOCUMENT_POST to post a vendor invoice. This works perfectly fine.

But the problem is that users are not able to reverse the invoice from FB08. They get the error: "Not possible to reverse the document in financial accounting".

It seems it is related to the import paramter DOCUMENTHEADER-OBJ_TYPE of the BAPI.

I am passing 'IDOC' in this field. Please let me know what should I pass to this BAPI to make sure the invoice gets posted and it is also possible to reverse the invoice via normal FI strnsactions.

Regards,

Prabhas.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,687

Example

data: gs_DOCUMENTHEADER like BAPIACHE09.

data: gs_accountgl like BAPIACGL09.

data: begin of gt_accountgl occurs 0.

include structure BAPIACGL09.

data: end of gt_accountgl.

data: gs_accountpayable like BAPIACAP09.

data: begin of gt_accountpayable occurs 0.

include structure BAPIACAP09.

data: end of gt_accountpayable.

DATA: gs_currencyamount like BAPIACCR09.

data: begin of gt_currencyamount occurs 0.

include structure BAPIACCR09.

data: end of gt_currencyamount.

data: begin of gt_return occurs 0.

include structure BAPIRET2.

data: end of gt_return.

DATA: gv_obj_type LIKE BAPIACHE09-OBJ_TYPE,

gv_obj_key LIKE BAPIACHE09-OBJ_KEY,

gv_obj_sys LIKE BAPIACHE09-OBJ_SYS.

gs_documentheader-bus_act = 'RFBU'.

gs_documentheader-username = sy-uname.

gs_documentheader-header_txt = 'test'.

gs_documentheader-comp_code = 'YOUR COMPANY CODE'.

gs_documentheader-doc_date = 'WRITE UR DOC.DATE'.

gs_documentheader-pstng_date = 'WRITE UR DOC. DATE'.

gs_documentheader-doc_type = 'KA'.

gs_accountpayable-itemno_acc = '2'.

gs_accountpayable-vendor_no = '0060001439'.

APPEND gs_accountpayable TO gt_accountpayable.

gs_accountgl-itemno_acc = '1'.

gs_accountgl-gl_account = '0000825100'.

gs_accountgl-costcenter = '0000010500'.

APPEND gs_accountgl TO gt_accountgl.

gs_currencyamount-itemno_acc = '1'.

gs_currencyamount-currency = 'USD'.

gs_currencyamount-amt_doccur = '350.00'. "i_tab-repval.

APPEND gs_currencyamount TO gt_currencyamount.

gs_currencyamount-itemno_acc = '2'.

gs_currencyamount-currency = 'USD'.

gs_currencyamount-amt_doccur = '-350.00'. "i_tab-repval.

APPEND gs_currencyamount TO gt_currencyamount.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = gs_documentheader

IMPORTING

obj_type = gv_obj_type

obj_key = gv_obj_key

obj_sys = gv_obj_sys

TABLES

accountgl = gt_accountgl

accountpayable = gt_accountpayable

currencyamount = gt_currencyamount

return = gt_return.

8 REPLIES 8
Read only

brad_bohn
Active Contributor
0 Likes
1,687

Leave the value blank, i.e., don't populate it in the header structure that is passed to the BAPI call.

Read only

Former Member
0 Likes
1,687

Leaving it balnk do not work as it is mandatory field

Read only

Former Member
0 Likes
1,687

u can pass header date like


IF itab-shkzg = 'H'.
      CONCATENATE itab-mblnr itab-mjahr INTO documentheader-header_txt.
      documentheader-username = sy-uname.
      documentheader-comp_code = 'GIVE UR COMPANY CODE'.
      documentheader-doc_date = itab-bldat.
      documentheader-pstng_date = itab-budat.
      documentheader-doc_type = 'SA'.
      documentheader-ref_doc_no = itab-xblnr.

Read only

0 Likes
1,687

What exactly it is supposed to mean?

Its not releated to my question anyway.

Read only

birendra_chatterjee
Active Participant
0 Likes
1,687

For vendor invoice pass the value of object type as 'RMRP'.

Read only

0 Likes
1,687

I got the error:

Incorrect entry in field OBJ_TYPE: RMRP

Read only

Former Member
0 Likes
1,688

Example

data: gs_DOCUMENTHEADER like BAPIACHE09.

data: gs_accountgl like BAPIACGL09.

data: begin of gt_accountgl occurs 0.

include structure BAPIACGL09.

data: end of gt_accountgl.

data: gs_accountpayable like BAPIACAP09.

data: begin of gt_accountpayable occurs 0.

include structure BAPIACAP09.

data: end of gt_accountpayable.

DATA: gs_currencyamount like BAPIACCR09.

data: begin of gt_currencyamount occurs 0.

include structure BAPIACCR09.

data: end of gt_currencyamount.

data: begin of gt_return occurs 0.

include structure BAPIRET2.

data: end of gt_return.

DATA: gv_obj_type LIKE BAPIACHE09-OBJ_TYPE,

gv_obj_key LIKE BAPIACHE09-OBJ_KEY,

gv_obj_sys LIKE BAPIACHE09-OBJ_SYS.

gs_documentheader-bus_act = 'RFBU'.

gs_documentheader-username = sy-uname.

gs_documentheader-header_txt = 'test'.

gs_documentheader-comp_code = 'YOUR COMPANY CODE'.

gs_documentheader-doc_date = 'WRITE UR DOC.DATE'.

gs_documentheader-pstng_date = 'WRITE UR DOC. DATE'.

gs_documentheader-doc_type = 'KA'.

gs_accountpayable-itemno_acc = '2'.

gs_accountpayable-vendor_no = '0060001439'.

APPEND gs_accountpayable TO gt_accountpayable.

gs_accountgl-itemno_acc = '1'.

gs_accountgl-gl_account = '0000825100'.

gs_accountgl-costcenter = '0000010500'.

APPEND gs_accountgl TO gt_accountgl.

gs_currencyamount-itemno_acc = '1'.

gs_currencyamount-currency = 'USD'.

gs_currencyamount-amt_doccur = '350.00'. "i_tab-repval.

APPEND gs_currencyamount TO gt_currencyamount.

gs_currencyamount-itemno_acc = '2'.

gs_currencyamount-currency = 'USD'.

gs_currencyamount-amt_doccur = '-350.00'. "i_tab-repval.

APPEND gs_currencyamount TO gt_currencyamount.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = gs_documentheader

IMPORTING

obj_type = gv_obj_type

obj_key = gv_obj_key

obj_sys = gv_obj_sys

TABLES

accountgl = gt_accountgl

accountpayable = gt_accountpayable

currencyamount = gt_currencyamount

return = gt_return.

Read only

Former Member
0 Likes
1,687

Thank you all who supported.

I was able to make it work by not passing a few fields in the header structure. Although this worked in ECC 6.0, I had to create my own transaction to reverse the invoices created by BAPI in SAP 5.0, 4.7 and 4.6c versions. My transaction is basd on reversal posting BAPI.