‎2010 Jun 04 6:57 PM
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.
‎2010 Jun 09 7:12 AM
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.
‎2010 Jun 04 10:08 PM
Leave the value blank, i.e., don't populate it in the header structure that is passed to the BAPI call.
‎2010 Jun 07 7:22 PM
‎2010 Jun 08 9:26 AM
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.
‎2010 Jun 08 7:00 PM
What exactly it is supposed to mean?
Its not releated to my question anyway.
‎2010 Jun 08 10:01 AM
‎2010 Jun 08 6:59 PM
‎2010 Jun 09 7:12 AM
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.
‎2010 Jun 10 9:29 PM
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.