on 12-01-2009 11:28 AM
Hi Gurus
I'm using BAPI_ACC_DOCUMENT_POST to post a FI document in background according the process in TCODE FB01. Right now the FI document can be posted whereas the information relavent to profitability analysis (CO-PA) was lost. I do not know how should i fill the parameters so that the profitability analysis data can be populated simutanencely.
i've passed the ledger information to BAPI via BADI ACC_DOUCMENT.
here is my code:
CONSTANTS:
c_bus_act TYPE glvor VALUE 'RFBU'.
FIELD-SYMBOLS:
<fi_upload> TYPE LINE OF ty_excel_template,
<return> TYPE bapiret2.
DATA:
st_docheader TYPE bapiache09,
lt_accountgl TYPE TABLE OF bapiacgl09,
wa_accountgl TYPE bapiacgl09,
lt_currencyamount TYPE TABLE OF bapiaccr09,
wa_currencyamount TYPE bapiaccr09,
lt_extension TYPE TABLE OF bapiacextc,
wa_extension TYPE bapiacextc,
lt_extension2 TYPE TABLE OF bapiparex,
wa_extension2 TYPE bapiparex,
lt_return TYPE TABLE OF bapiret2,
lv_obj_key TYPE awkey,
lv_ktonr TYPE ktonr
.
Edited by: Stephen Xue on Dec 1, 2009 12:28 PM
it has been solved. the table parameter: criteria needs to be filled too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
.
* 1. Fill in header information
st_docheader-bus_act = c_bus_act.
st_docheader-username = sy-uname.
st_docheader-comp_code = p_bukrs.
st_docheader-doc_date = p_budat.
st_docheader-pstng_date = p_budat.
st_docheader-doc_type = p_blart.
* 2. The ledger group information needs to be filled in an extension structure and
* to be processed via BADI afterwards.
wa_extension-field1 = p_ldgrp.
APPEND wa_extension TO lt_extension.
wa_extension2-structure = p_ldgrp.
APPEND wa_extension2 TO lt_extension2.
LOOP AT tab_fi_upload ASSIGNING <fi_upload>.
* 3. Fill in the account GL informaiton
CLEAR wa_accountgl.
lv_ktonr = <fi_upload>-ktonr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_ktonr
IMPORTING
output = lv_ktonr.
wa_accountgl-itemno_acc = sy-tabix.
wa_accountgl-gl_account = lv_ktonr.
wa_accountgl-item_text = <fi_upload>-kobez.
wa_accountgl-doc_type = p_blart.
wa_accountgl-comp_code = p_bukrs.
wa_accountgl-customer = <fi_upload>-kunnr.
wa_accountgl-costcenter = <fi_upload>-kostl.
wa_accountgl-alloc_nmbr = <fi_upload>-zuonr.
APPEND wa_accountgl TO lt_accountgl.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
* 4. Fill in the currency amount information.
* if the posting key is 40, the value will be positive;
* if the posting key is 50, the value will be negative.
CLEAR wa_currencyamount.
wa_currencyamount-itemno_acc = sy-tabix.
wa_currencyamount-currency_iso = p_waers.
CASE <fi_upload>-bschl.
WHEN '40'.
wa_currencyamount-amt_doccur = <fi_upload>-wrbtr.
WHEN '50'.
wa_currencyamount-amt_doccur = ( -1 ) * <fi_upload>-wrbtr.
WHEN OTHERS.
ENDCASE.
APPEND wa_currencyamount TO lt_currencyamount.
ENDLOOP.
* 5. Call BAPI to posting document
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = st_docheader
* CUSTOMERCPD =
* CONTRACTHEADER =
IMPORTING
* OBJ_TYPE =
obj_key = lv_obj_key
* OBJ_SYS =
TABLES
accountgl = lt_accountgl[]
* ACCOUNTRECEIVABLE =
* ACCOUNTPAYABLE =
* ACCOUNTTAX =
currencyamount = lt_currencyamount[]
* CRITERIA =
* VALUEFIELD =
extension1 = lt_extension[]
return = lt_return[]
* PAYMENTCARD =
* CONTRACTITEM =
extension2 = lt_extension2[]
* REALESTATE =
* ACCOUNTWT =
.
* Since the posting data and the log data will be populated once, the
* commit work will no tbe triggered here.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
* IMPORTING
* RETURN =
.
ENDIF.
User | Count |
---|---|
88 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.