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 to modify an accounting document

Former Member
0 Likes
4,812

hi,

somebody knows how to use the FM BAPI_ACC_DOCUMENT_POST to modify an accounting document?

I use:



lw_cab-username   = sy-uname.
lw_cab-doc_type   = 'KR'.
lw_cab-comp_code  = '0001'.
lw_cab-bus_act = 'RFBU'.
lw_cab-obj_type = 'BKPFF'.
lw_cab-obj_key = '190000032000012007'.
lw_cab-obj_sys = 'HRDCLNT100'.


* I only want to modify this field.
lw_cab-ref_doc_no = 'NEW'.


CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
    EXPORTING
      documentheader = lw_cab
    IMPORTING
      obj_key        = l_obj
    TABLES
      currencyamount = li_currencyamount
      return         = li_return.

but it doesn't work.

I also need to reverse an accounting document with BAPI_ACC_DOCUMENT_REV_POST.

Somebody knows an example that works?

Thanks,

Ángel.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,381

Hi,

see note 487722.

The posting key is automatically assigned by the BAPI, u can't transfer it.

The BAPI decides which posting key ahs to be used in order on the kind of item and operation key.

So you can try to drive the posting key assigning a certain operation key in the item.

Try to check the fm FI_GET_POSTING_KEY.

I believe you can decide which operation key to be used only in the G/L items (BAPIACGL09-ACCT_KEY), for the customer the BAPI uses the keys 01 and 11.

U can see how the BAPI decides which posting keys has to be used in the form fill_acct_key in the include LACC9F20.

Check the therads.

<b>Reward points</b>

Regarsd

hi,

somebody knows how to use the FM BAPI_ACC_DOCUMENT_POST to modify an accounting document?

I use:



lw_cab-username   = sy-uname.
lw_cab-doc_type   = 'KR'.
lw_cab-comp_code  = '0001'.
lw_cab-bus_act = 'RFBU'.
lw_cab-obj_type = 'BKPFF'.
lw_cab-obj_key = '190000032000012007'.
lw_cab-obj_sys = 'HRDCLNT100'.


* I only want to modify this field.
lw_cab-ref_doc_no = 'NEW'.


CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
    EXPORTING
      documentheader = lw_cab
    IMPORTING
      obj_key        = l_obj
    TABLES
      currencyamount = li_currencyamount
      return         = li_return.

but it doesn't work.

I also need to reverse an accounting document with BAPI_ACC_DOCUMENT_REV_POST.

Somebody knows an example that works?

Thanks,

Ángel.

3 REPLIES 3
Read only

Former Member
0 Likes
2,382

Hi,

see note 487722.

The posting key is automatically assigned by the BAPI, u can't transfer it.

The BAPI decides which posting key ahs to be used in order on the kind of item and operation key.

So you can try to drive the posting key assigning a certain operation key in the item.

Try to check the fm FI_GET_POSTING_KEY.

I believe you can decide which operation key to be used only in the G/L items (BAPIACGL09-ACCT_KEY), for the customer the BAPI uses the keys 01 and 11.

U can see how the BAPI decides which posting keys has to be used in the form fill_acct_key in the include LACC9F20.

Check the therads.

<b>Reward points</b>

Regarsd

Read only

Former Member
0 Likes
2,381

I'm sorry to trouble you,angel..

I met the same problem as follows:

would you please share your code with me?

I'll meet the deadline in a few days..

Thank you..

my e-mail:[email protected]

Read only

Former Member
0 Likes
2,381

check this FM for modifing a field: CHANGE_DOCUMENT

data: rev like BAPIACREV,

bus like bAPIACHE09-BUS_ACT,

ret like table of bapiret2 with header line.

data: flg(1) type c.

rev-obj_type = 'BKPFF'.

rev-obj_key = 'docnocompcodeyear'.

REV-OBJ_KEY_R = 'docnocompcodeyear'.

rev-PSTNG_DATE = '20070611'.

rev-FIS_PERIOD = '06'.

rev-COMP_CODE = 'comp_code'.

REV-REASON_REV = '02'.

REV-obj_sys = sy-mandt.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_REV_POST'

EXPORTING

REVERSAL = rev

BUS_ACT = 'RFBU'

  • IMPORTING

  • OBJ_TYPE =

  • OBJ_KEY =

  • OBJ_SYS =

TABLES

RETURN = ret.

.