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'

Former Member
0 Likes
538

Hi gurus,

I am working on an interface where I need to post an accounting document using

f-43 and for this I have identified this bapi 'BAPI_ACC_DOCUMENT_POST', and I have written the following code. everything is working properly but the only problem is, the posting keys I am using are 31 and 40 but when I run my program and look into the document created, it shows me the posting keys as 40 and 50 instead of 31 and 40, can you please tell me how to get rid of this thing .

v_semfile = p_ifname.

refresh it_input_file.

call function 'WS_UPLOAD'

EXPORTING

filename = v_semfile

filetype = 'DAT'

TABLES

data_tab = it_input

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

others = 10.

move:

'RFBU' to documentheader-bus_act,

it_input-doc_date2 to documentheader-doc_date,

it_input-pos_date2 to documentheader-pstng_date,

it_inputdoc_type to documentheader-doc_type,

it_inputbukrs to documentheader-comp_code,

it_input-pos_per to documentheader-fis_period,

it_input-fis_year to documentheader-fisc_year,

it_input-reference to documentheader-ref_doc_no,

it_input-h_text to documentheader-header_txt,

syst-uname to documentheader-username.

if it_input_file-pos_key eq 31.

move:

v_count to glaccount-ITEMNO_ACC,

it_input-glaccount to glaccount-gl_account,

it_input-kostl to glaccount-COSTCENTER,

it_input-prctr to glaccount-PROFIT_CTR,

it_input-bus_area to glaccount-bus_area,

it_input-item_text to glaccount-ITEM_TEXT,

it_input-assignment to glaccount-ALLOC_NMBR.

append glaccount.

move:

v_count to currencyamount-ITEMNO_ACC,

it_input-currency to currencyamount-CURRENCY,

it_input-amount to currencyamount-AMT_DOCCUR .

append currencyamount.

clear: glaccount, currencyamount.

else.

move: v_count to glaccount-ITEMNO_ACC,

it_input-glaccount to glaccount-gl_account,

it_input-kostl to glaccount-COSTCENTER,

it_input-prctr to glaccount-PROFIT_CTR,

it_input-bus_area to glaccount-bus_area,

it_input-item_text to glaccount-ITEM_TEXT,

it_input-assignment to glaccount-ALLOC_NMBR.

append glaccount.

move:

v_count to currencyamount-ITEMNO_ACC,

it_input-currency to currencyamount-CURRENCY.

currencyamount-AMT_DOCCUR = it_input-amount * -1.

append currencyamount.

clear: glaccount, currencyamount.

endif.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

DOCUMENTHEADER = documentheader

IMPORTING

OBJ_TYPE = obj_type

OBJ_KEY = obj_key

OBJ_SYS = obj_sys

TABLES

ACCOUNTGL = glaccount

ACCOUNTPAYABLE = ap

CURRENCYAMOUNT = currencyamount

RETURN = return.

read table return with key type = 'S'.

if syst-subrc eq 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

IMPORTING

RETURN = return2.

*****************************************************

I will really appreciate your help <b><REMOVED BY MODERATOR></b>,

Thanks

Rajeev

Message was edited by:

Alvaro Tejada Galindo

2 REPLIES 2
Read only

Former Member
0 Likes
387

I didn't get any reply

Read only

0 Likes
387

Hi,

When u you use the bapi 'BAPI_ACC_DOCUMENT_POST',

it does 2 things : 1.it credits one account and (say cost of goods sale)

2.debits the other account((say dealer /customer account).

now the posting key for debit is 40 and posting key for credit is 50 and that is what you aare getting in the code.

also you need to multiply the currency with '-1' when you credit a account.

Thanks,

Challa.