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

Set calculate Tax(BKPF-XMWST) check box in BAPI

Former Member
0 Kudos
11,066

Dear All,

Can you please suggest how can I set Calculate Tax(BKPF-XMWST) check box in BAPI_ACC_DOCUMENT_POST.

Thanks,

Surya

6 REPLIES 6
Read only

Former Member
0 Kudos
4,396

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

Read only

0 Kudos
4,396

Many thanks Pallavi

f

BADI implementation created but when I run the FM this method is not running since it's depends on Filter values.

Please let me know which value I have to specify.

Note:

I specified BKPF in filter value

Thanks,

Surya

Read only

0 Kudos
4,396

Hi surya,

Specify BKPFF as filter value.

Hope this will be helpful.

Regards

Pallavi

Read only

0 Kudos
4,396

Hi Pallavi,

  It's working now, few more details please.

I filled these three tables

ACCOUNTGL      -- this record item_acc number as 1

ACCOUNTPAYABLE  -- this record item_acc number as 2

ACCOUNTTAX -- this record item_acc number as 3

I think this numbering is not correct. can you please provide the inputs on this while adding the data to these tables.

Thanks,

Surya

Read only

0 Kudos
4,396

BAPI_ACC_DOCUMENT_POST | SCN

Go through this link.It will be helpful.

Regards

Pallavi

Read only

RaymondGiuseppi
Active Contributor
0 Kudos
4,396

Could you also consider solution provided in 1873588 - Filling tax information for BAPIs

(and its correction 2070697 - Filling tax information for BAPIs , if required)

Regards,

Raymond