Application Development 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: 

BAPI to change Accounting Document Header

Former Member
0 Kudos

Hi Folks,

I have a requirement to go into an existing document (Billing Doc.) and change the Reference field (XBLNR). The business requirement is specifically to modify the BKPF-XBLNR field to contain a new reference. Is there a BAPI that can be used to modify accounting header details? All the accounting BAPI's I can find seem to be for posting a new record.

Points will be rewarded for helpful answers

Cheers,

Steve

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

Hi,

Try with

1. BAPI_ACC_GL_POSTING_POST

2. BAPI_ACC_DOCUMENT_POST

5 REPLIES 5

former_member194669
Active Contributor
0 Kudos

Hi,

Try with

1. BAPI_ACC_GL_POSTING_POST

2. BAPI_ACC_DOCUMENT_POST

0 Kudos

Hi,

Check this example code


TABLES: bapiache08, bapiacgl08,bapiaccr08, bapiret2.

DATA: t_bapiache08 LIKE TABLE OF bapiache08 WITH HEADER LINE,
t_bapiacgl08 LIKE TABLE OF bapiacgl08 WITH HEADER LINE,
t_bapiaccr08 LIKE TABLE OF bapiaccr08 WITH HEADER LINE,
t_bapiret2 LIKE TABLE OF bapiret2 WITH HEADER LINE,
ct_bapiret2 LIKE TABLE OF bapiret2 WITH HEADER LINE.

t_bapiache08-obj_type = 'BKPFF'. "BKPFF
t_bapiache08-obj_key = '010000000000062005'.
t_bapiache08-obj_sys = 'T90CLNT800'. "T09CLNT800
t_bapiache08-username = 'SSI4'.

t_bapiache08-header_txt = 'DOCUMENT POSTING'.
t_bapiache08-comp_code = '1000'.
t_bapiache08-fisc_year = '2005'.
t_bapiache08-doc_date = '20050805'.
t_bapiache08-pstng_date = '20050805'.
t_bapiache08-fis_period = '07'.
t_bapiache08-doc_type = 'SA'.
t_bapiache08-compo_acc = 'FI'. "GL

APPEND t_bapiache08.

t_bapiacgl08-itemno_acc = '031'.
t_bapiacgl08-gl_account = '160000'.
t_bapiacgl08-comp_code = '1000'.
t_bapiacgl08-pstng_date = '20050805'.
t_bapiacgl08-doc_type = 'SA'.
t_bapiacgl08-fisc_year = '2005'.
t_bapiacgl08-fis_period = '07'.
t_bapiacgl08-stat_con = 'X'.
t_bapiacgl08-vendor_no = '1920'. "ACCOUNTING NO.FOR VENDOR/CREDITOR.
t_bapiacgl08-item_text = 'LINE ITEM TEXT BY VIN'.

APPEND t_bapiacgl08.


t_bapiaccr08-itemno_acc = '031'.
t_bapiaccr08-currency_iso = 'EUR'.
t_bapiaccr08-amt_doccur = '2000'.
APPEND t_bapiaccr08.



CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
documentheader = t_bapiache08
* IMPORTING
* OBJ_TYPE =
* OBJ_KEY =
* OBJ_SYS =
TABLES
accountgl = t_bapiacgl08
currencyamount = t_bapiaccr08
return = t_bapiret2
* EXTENSION1 =
.


LOOP AT t_bapiret2.
WRITE 😕 t_bapiret2-type, t_bapiret2-id, t_bapiret2-number,
t_bapiret2-message,t_bapiret2-parameter,
t_bapiret2-row, t_bapiret2-field, t_bapiret2-system.
ENDLOOP.


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = ' '
IMPORTING
return = ct_bapiret2.


LOOP AT ct_bapiret2.
WRITE 😕 ct_bapiret2-type, ct_bapiret2-id, ct_bapiret2-number,
ct_bapiret2-message,ct_bapiret2-log_no, ct_bapiret2-parameter,
ct_bapiret2-row, ct_bapiret2-field, ct_bapiret2-system.
ENDLOOP.


0 Kudos

Hi a®s,

In using these BAPI's, do I need to re-create each line item from the original document in order for the change document to post?

In that case, is there a 'Get' bapi that can return these values ready for 're' posting?

Cheers,

Steve

Former Member
0 Kudos

It turned out there is a function module (FI_DOCUMENT_CHANGE) that updates the required fields for me.

Thanks for your help

0 Kudos

Hi Stephen,

I saw your requirement which was you posted, I have also similar requirement but i need to change Reference field value ( BKPF-XBLNR) in Transaction code - FB02. So if you used function module

(FI_DOCUMENT_CHANGE)  and got exact requirement can you help me how did you done and how you passed parameter there.


Thanks,