Hi Surya,
To set calculate tax, you need to implement a BADI 'ACC_DOCUMENT' method 'IF_EX_ACC_DOCUMENT~CHANGE'.
You need to pass on the extension2 parameters of the FM ,and then within the FM ,above mentioned BADI is triggered before posting the document, so that calculate tax can be enabled.Below code for BADI can be helpful
method IF_EX_ACC_DOCUMENT~CHANGE.
DATA: wa_extension TYPE bapiparex,
ext_value(960) TYPE c,
wa_accit TYPE accit,
l_ref TYPE REF TO data.
FIELD-SYMBOLS: <l_struc> TYPE ANY,
<l_field> TYPE ANY.
constants : lco_posnr1 TYPE posnr_acc VALUE '0000000001'.
SORT c_extension2 BY structure.
*in this peace of code will activate the field for calculating tax automatically
LOOP AT c_extension2 INTO wa_extension where structure = 'BAPIACHE09'.
IF wa_extension-valuepart1 = 'XMWST'.
LOOP AT c_accit INTO wa_accit WHERE POSNR = lco_posnr1 ."KUNNR IS NOT INITIAL.
wa_accit-xmwst = 'X'.
MODIFY c_accit FROM wa_accit INDEX sy-tabix TRANSPORTING xmwst.
ENDLOOP.
ENDIF.
ENDLOOP.
endmethod.
*-->Filling BAPI extension for calculate tax in the program
lwa_extnsn-structure = 'BAPIACHE09' "lco_extnstr.
lwa_extnsn-valuepart1 = 'XMWST'. "lco_extnfld.
APPEND lwa_extnsn TO lit_extnsn.
*-->Check accounting Document to be posted is correct
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = lwa_dochdr
* CUSTOMERCPD =
* CONTRACTHEADER =
TABLES
accountgl = lit_accgl
accountreceivable = lit_accrcvble
* ACCOUNTPAYABLE =
accounttax = lit_acctax
currencyamount = lit_curamt
* CRITERIA =
* VALUEFIELD =
* EXTENSION1 =
return = lit_return
* PAYMENTCARD =
* CONTRACTITEM =
extension2 = lit_extnsn.
Note : Filling field names in extension2 and thereby identifing them in BADI is very specific to requirement.As per the existing previous BADI implementions in my system I followed this procedure.
Regards
Pallavi