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

BAPI_ACC_DOCUMENT_POST does not update BKPF/BSEG tables

0 Likes
2,200

Hello,

I used bapi_acc_document_post to post a accounting document The following routine says that the document is successfully posted, however, does not update the acccounting tables. I read several messages on the SDN and unable to get the correct answer.

Your help is appreciated.

Regards

William

REPORT ze_bapi_acc_document_post .

SELECTION-SCREEN BEGIN OF BLOCK bl01 .

SELECTION-SCREEN ULINE.

PARAMETERS:

ref_key LIKE bapiache01-obj_key DEFAULT 'TEST000001BAPICALL',

dest LIKE bdi_logsys-logsys DEFAULT ' '.

SELECTION-SCREEN END OF BLOCK bl01 .

DATA:

gd_documentheader LIKE bapiache09,

gd_customercpd LIKE bapiacpa09,

gd_fica_hd LIKE bapiaccahd,

it_accountreceivable LIKE TABLE OF bapiacar09 WITH HEADER LINE,

it_accountgl LIKE TABLE OF bapiacgl09 WITH HEADER LINE,

it_accounttax LIKE TABLE OF bapiactx09 WITH HEADER LINE,

it_criteria LIKE TABLE OF bapiackec9 WITH HEADER LINE,

it_valuefield LIKE TABLE OF bapiackev9 WITH HEADER LINE,

it_currencyamount LIKE TABLE OF bapiaccr09 WITH HEADER LINE,

it_return LIKE TABLE OF bapiret2 WITH HEADER LINE,

it_receivers LIKE TABLE OF bdi_logsys WITH HEADER LINE,

it_fica_it LIKE TABLE OF bapiaccait WITH HEADER LINE,

it_accountpayable LIKE TABLE OF bapiacap09 WITH HEADER LINE,

it_paymentcard LIKE TABLE OF bapiacpc09 WITH HEADER LINE,

it_ext LIKE TABLE OF bapiacextc WITH HEADER LINE.

PERFORM fill_internal_tables.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'

DESTINATION dest

EXPORTING

documentheader = gd_documentheader

customercpd = gd_customercpd

contractheader = gd_fica_hd

TABLES

accountgl = it_accountgl

accountreceivable = it_accountreceivable

accountpayable = it_accountpayable

accounttax = it_accounttax

currencyamount = it_currencyamount

return = it_return.

WRITE: / 'Result of check all:'. "#EC NOTEXT

PERFORM show_messages.

DATA: l_type LIKE gd_documentheader-obj_type,

l_key LIKE gd_documentheader-obj_key,

l_sys LIKE gd_documentheader-obj_sys.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = gd_documentheader

customercpd = gd_customercpd

contractheader = gd_fica_hd

IMPORTING

obj_type = l_type

obj_key = l_key

obj_sys = l_sys

TABLES

accountgl = it_accountgl

accountpayable = it_accountpayable

accounttax = it_accounttax

currencyamount = it_currencyamount

return = it_return

EXCEPTIONS

OTHERS = 1.

WRITE: / 'Result of post:'. "#EC NOTEXT

PERFORM show_messages.

REFRESH IT_RETURN.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'.

  • IMPORTING

  • RETURN = IT_RETURN.

  • COMMIT WORK. .

.

BREAK-POINT.

----


  • Form fill_internal_tables

----


FORM fill_internal_tables.

PERFORM fill_header.

PERFORM fill_accountgl.

PERFORM fill_accountap.

PERFORM fill_accounttax.

PERFORM fill_currencyamount.

ENDFORM. " fill_internal_tables

----


  • Form Show_messages

----


FORM show_messages.

IF it_return[] IS INITIAL.

WRITE: / 'no messages'.

ELSE.

SKIP 1.

LOOP AT it_return.

WRITE: / it_return-type,

(2) it_return-id,

it_return-number,

(80) it_return-message,

it_return-message_v1,

(20) it_return-parameter,

(3) it_return-row,

it_return-field.

ENDLOOP.

ENDIF.

ULINE.

ENDFORM. " Show_messages

----


  • FORM fill_accountgl *

----


FORM fill_accountgl.

  • Actual invoice line

CLEAR it_accountgl.

it_accountgl-itemno_acc = 2.

it_accountgl-gl_account = '0000009223'.

it_accountgl-item_text = 'Line Iten'. "#EC NOTEXT

it_accountgl-profit_ctr = 'DNDDUMMY'.

it_accountgl-comp_code = '0180'.

it_accountgl-tax_code = 'IG'.

it_accountgl-FUNDS_CTR = '1985BA'.

it_accountgl-COSTCENTER = '1985BA'.

it_accountgl-FUND = 'C113'.

it_accountgl-TAXJURCODE = 'CAON'.

APPEND it_accountgl.

ENDFORM. "fill_accountgl

----


  • FORM fill_header *

----


FORM fill_header.

  • CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'

  • IMPORTING

  • own_logical_system = gd_documentheader-obj_sys.

  • OBJ_TYPE has to be replaced by customers object key (Y* or Z*)

  • gd_documentheader-obj_type = 'BKPFF'.

  • gd_documentheader-obj_key = ref_key.

  • gd_documentheader-BUS_ACT = 'RMRP'.

gd_documentheader-username = sy-uname.

gd_documentheader-header_txt = 'BAPI Test'. "#EC NOTEXT

  • gd_documentheader-obj_key_r =

  • GD_DOCUMENTHEADER-reason_rev =

gd_documentheader-comp_code = '0180'.

  • GD_DOCUMENTHEADER-AC_DOC_NO =

gd_documentheader-fisc_year = '2008'.

gd_documentheader-doc_date = sy-datum.

gd_documentheader-pstng_date = '20070901'.

GD_DOCUMENTHEADER-TRANS_DATE = SY-DATUM.

  • GD_DOCUMENTHEADER-VALUE_DATE =

  • GD_DOCUMENTHEADER-FIS_PERIOD =

gd_documentheader-doc_type = 'RE'.

gd_documentheader-ref_doc_no = '6000009268'.

GD_DOCUMENTHEADER-COMPO_ACC = 'FI'.

gd_documentheader-bus_act = 'RFBU'.

ENDFORM. "fill_header

----


  • FORM fill_ap *

----


FORM fill_accountap.

  • vendor line

CLEAR it_accountpayable.

it_accountpayable-itemno_acc = 1.

it_accountpayable-comp_code = '0180'.

it_accountpayable-pmnttrms = '0006'.

it_accountpayable-TAX_CODE = 'IG'.

it_accountpayable-vendor_no = '0001200051'.

it_accountpayable-item_text = 'Vendor Line'. "#EC NOTEXT

APPEND it_accountpayable.

ENDFORM. "fill_accountap

----


  • FORM fill_tax *

----


FORM fill_accounttax.

  • tax line

CLEAR it_accounttax.

it_accounttax-itemno_acc = 3.

it_accounttax-gl_account = '0000081710'.

it_accounttax-tax_code = 'IG'.

it_accounttax-acct_key = 'VST'.

it_accounttax-TAXJURCODE = 'CA00'.

APPEND it_accounttax.

ENDFORM. "fill_accounttax

----


  • FORM fill_currencyamount *

----


FORM fill_currencyamount.

CLEAR it_currencyamount.

it_currencyamount-itemno_acc = 1.

it_currencyamount-curr_type = '00'.

it_currencyamount-currency = 'CAD'.

it_currencyamount-amt_base = '106.00'.

APPEND it_currencyamount.

CLEAR it_currencyamount.

it_currencyamount-itemno_acc = 2.

it_currencyamount-curr_type = '00'.

it_currencyamount-currency = 'CAD'.

it_currencyamount-amt_base = '100.00'.

APPEND it_currencyamount.

CLEAR it_currencyamount.

it_currencyamount-itemno_acc = 3.

it_currencyamount-curr_type = '00'.

it_currencyamount-currency = 'CAD'.

it_currencyamount-amt_base = '6.00'.

APPEND it_currencyamount.

ENDFORM. "fill_currencyamount

Hello,

I used bapi_acc_document_post to post a accounting document The following routine says that the document is successfully posted, however, does not update the acccounting tables. I read several messages on the SDN and unable to get the correct answer.

Your help is appreciated.

Regards

William

REPORT ze_bapi_acc_document_post .

SELECTION-SCREEN BEGIN OF BLOCK bl01 .

SELECTION-SCREEN ULINE.

PARAMETERS:

ref_key LIKE bapiache01-obj_key DEFAULT 'TEST000001BAPICALL',

dest LIKE bdi_logsys-logsys DEFAULT ' '.

SELECTION-SCREEN END OF BLOCK bl01 .

DATA:

gd_documentheader LIKE bapiache09,

gd_customercpd LIKE bapiacpa09,

gd_fica_hd LIKE bapiaccahd,

it_accountreceivable LIKE TABLE OF bapiacar09 WITH HEADER LINE,

it_accountgl LIKE TABLE OF bapiacgl09 WITH HEADER LINE,

it_accounttax LIKE TABLE OF bapiactx09 WITH HEADER LINE,

it_criteria LIKE TABLE OF bapiackec9 WITH HEADER LINE,

it_valuefield LIKE TABLE OF bapiackev9 WITH HEADER LINE,

it_currencyamount LIKE TABLE OF bapiaccr09 WITH HEADER LINE,

it_return LIKE TABLE OF bapiret2 WITH HEADER LINE,

it_receivers LIKE TABLE OF bdi_logsys WITH HEADER LINE,

it_fica_it LIKE TABLE OF bapiaccait WITH HEADER LINE,

it_accountpayable LIKE TABLE OF bapiacap09 WITH HEADER LINE,

it_paymentcard LIKE TABLE OF bapiacpc09 WITH HEADER LINE,

it_ext LIKE TABLE OF bapiacextc WITH HEADER LINE.

PERFORM fill_internal_tables.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'

DESTINATION dest

EXPORTING

documentheader = gd_documentheader

customercpd = gd_customercpd

contractheader = gd_fica_hd

TABLES

accountgl = it_accountgl

accountreceivable = it_accountreceivable

accountpayable = it_accountpayable

accounttax = it_accounttax

currencyamount = it_currencyamount

return = it_return.

WRITE: / 'Result of check all:'. "#EC NOTEXT

PERFORM show_messages.

DATA: l_type LIKE gd_documentheader-obj_type,

l_key LIKE gd_documentheader-obj_key,

l_sys LIKE gd_documentheader-obj_sys.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = gd_documentheader

customercpd = gd_customercpd

contractheader = gd_fica_hd

IMPORTING

obj_type = l_type

obj_key = l_key

obj_sys = l_sys

TABLES

accountgl = it_accountgl

accountpayable = it_accountpayable

accounttax = it_accounttax

currencyamount = it_currencyamount

return = it_return

EXCEPTIONS

OTHERS = 1.

WRITE: / 'Result of post:'. "#EC NOTEXT

PERFORM show_messages.

REFRESH IT_RETURN.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'.

  • IMPORTING

  • RETURN = IT_RETURN.

  • COMMIT WORK. .

.

BREAK-POINT.

----


  • Form fill_internal_tables

----


FORM fill_internal_tables.

PERFORM fill_header.

PERFORM fill_accountgl.

PERFORM fill_accountap.

PERFORM fill_accounttax.

PERFORM fill_currencyamount.

ENDFORM. " fill_internal_tables

----


  • Form Show_messages

----


FORM show_messages.

IF it_return[] IS INITIAL.

WRITE: / 'no messages'.

ELSE.

SKIP 1.

LOOP AT it_return.

WRITE: / it_return-type,

(2) it_return-id,

it_return-number,

(80) it_return-message,

it_return-message_v1,

(20) it_return-parameter,

(3) it_return-row,

it_return-field.

ENDLOOP.

ENDIF.

ULINE.

ENDFORM. " Show_messages

----


  • FORM fill_accountgl *

----


FORM fill_accountgl.

  • Actual invoice line

CLEAR it_accountgl.

it_accountgl-itemno_acc = 2.

it_accountgl-gl_account = '0000009223'.

it_accountgl-item_text = 'Line Iten'. "#EC NOTEXT

it_accountgl-profit_ctr = 'DNDDUMMY'.

it_accountgl-comp_code = '0180'.

it_accountgl-tax_code = 'IG'.

it_accountgl-FUNDS_CTR = '1985BA'.

it_accountgl-COSTCENTER = '1985BA'.

it_accountgl-FUND = 'C113'.

it_accountgl-TAXJURCODE = 'CAON'.

APPEND it_accountgl.

ENDFORM. "fill_accountgl

----


  • FORM fill_header *

----


FORM fill_header.

  • CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'

  • IMPORTING

  • own_logical_system = gd_documentheader-obj_sys.

  • OBJ_TYPE has to be replaced by customers object key (Y* or Z*)

  • gd_documentheader-obj_type = 'BKPFF'.

  • gd_documentheader-obj_key = ref_key.

  • gd_documentheader-BUS_ACT = 'RMRP'.

gd_documentheader-username = sy-uname.

gd_documentheader-header_txt = 'BAPI Test'. "#EC NOTEXT

  • gd_documentheader-obj_key_r =

  • GD_DOCUMENTHEADER-reason_rev =

gd_documentheader-comp_code = '0180'.

  • GD_DOCUMENTHEADER-AC_DOC_NO =

gd_documentheader-fisc_year = '2008'.

gd_documentheader-doc_date = sy-datum.

gd_documentheader-pstng_date = '20070901'.

GD_DOCUMENTHEADER-TRANS_DATE = SY-DATUM.

  • GD_DOCUMENTHEADER-VALUE_DATE =

  • GD_DOCUMENTHEADER-FIS_PERIOD =

gd_documentheader-doc_type = 'RE'.

gd_documentheader-ref_doc_no = '6000009268'.

GD_DOCUMENTHEADER-COMPO_ACC = 'FI'.

gd_documentheader-bus_act = 'RFBU'.

ENDFORM. "fill_header

----


  • FORM fill_ap *

----


FORM fill_accountap.

  • vendor line

CLEAR it_accountpayable.

it_accountpayable-itemno_acc = 1.

it_accountpayable-comp_code = '0180'.

it_accountpayable-pmnttrms = '0006'.

it_accountpayable-TAX_CODE = 'IG'.

it_accountpayable-vendor_no = '0001200051'.

it_accountpayable-item_text = 'Vendor Line'. "#EC NOTEXT

APPEND it_accountpayable.

ENDFORM. "fill_accountap

----


  • FORM fill_tax *

----


FORM fill_accounttax.

  • tax line

CLEAR it_accounttax.

it_accounttax-itemno_acc = 3.

it_accounttax-gl_account = '0000081710'.

it_accounttax-tax_code = 'IG'.

it_accounttax-acct_key = 'VST'.

it_accounttax-TAXJURCODE = 'CA00'.

APPEND it_accounttax.

ENDFORM. "fill_accounttax

----


  • FORM fill_currencyamount *

----


FORM fill_currencyamount.

CLEAR it_currencyamount.

it_currencyamount-itemno_acc = 1.

it_currencyamount-curr_type = '00'.

it_currencyamount-currency = 'CAD'.

it_currencyamount-amt_base = '106.00'.

APPEND it_currencyamount.

CLEAR it_currencyamount.

it_currencyamount-itemno_acc = 2.

it_currencyamount-curr_type = '00'.

it_currencyamount-currency = 'CAD'.

it_currencyamount-amt_base = '100.00'.

APPEND it_currencyamount.

CLEAR it_currencyamount.

it_currencyamount-itemno_acc = 3.

it_currencyamount-curr_type = '00'.

it_currencyamount-currency = 'CAD'.

it_currencyamount-amt_base = '6.00'.

APPEND it_currencyamount.

ENDFORM. "fill_currencyamount

2 REPLIES 2
Read only

0 Likes
1,298

Any help.

thanks

Read only

raviraj7
Explorer
0 Likes
1,298

U have to implement the BADI for this.. ‘AC_DOCUMENT’

Add source code into Method: CHANGE_INITIAL & CHANGE_AFTER_CHECK,

*---<SAPLBPFC> is for Posting      with BAPI: BAPI_ACC_DOCUMENT_POST

  *---<SAPCNVE > is for Posting(Tax) with BAPI: BAPI_ACC_DOCUMENT_POST

  *---<SAPMSSY1> is for Test(Check)  with BAPI: BAPI_ACC_DOCUMENT_CHECK

  

DATA: wa_header TYPE acchd.

    IF sy-xprog NE ' SAPMSSY1 '.

      CLEAR wa_header.

      wa_header = im_document-header.

      ex_document-header-bktxt = wa_header-bktxt.

      CLEAR wa_header.

    ENDIF.