Skip to Content
author's profile photo
Former Member

How to calculate withholding tax in FB60 uploading using bapi?

Hi Experts,

Im very new to the world of SAP and ABAP Programming. Just joined a job and have a very tough task given on the very first day.

There is a Uploading done for transaction FB60 using BAPI .

Bapi used is BAPI_ACC_DOCUMENT_POST and BAPI_TRANSACTION_COMMIT .

Its working perfectly fine but now they have asked me to make changes in it so that the withholding tax is also calculated and deducted.

Im providing the current program please guide me how and what changes i hv to make?

Sinse im very new to ABAP itself and the task given to me is very tough so please i would would warm welcome all support and help i get.

Regards,

Harish Khandelwal

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Nov 06, 2013 at 10:35 AM

    Hi Harish,

    Try like this

    Step 1. :

    Pass the withholding tax information to the BAPI,

    The withholding tax information can be retreived from table T059Z. Get the withholding tax code from table lfbw.


    LOOP AT IT_DATA INTO WA_DATA.

    SELECT * FROM lfbw

    INTO TABLE it_lfbw

    WHERE lifnr EQ wa_data-lifnr.

    LOOP AT it_lfbw INTO wa_lfbw.

    SELECT SINGLE * FROM t059z WHERE land1 = text-004

    AND witht = wa_lfbw-wt_witht

    and withcd= wa_lfbw-wt_withcd.

    ____________________________________________________________________

    Option 1 - Use the table parameter EXTENSION1 to pass the details.

    wt_item_th = wt_item_th + 1.

    wa_extension-field1 = 'WHT'. "Identifier

    wa_extension-field2+0(6) = wt_item_th . "ACCWT-WT_KEY

    wa_extension-field2+6(2) = t059z-witht. "ACCWT-WITHT

    wa_extension-field2+8(2) = t059z-wt_withcd. "ACCWT-WT_WITHCD

    wa_extension-field3 = wa_data-witht. "Withholding tax base amount from input file.

    APPEND wa_extension TO it_extension.

    ENDLOOP.

    ____________________________________________________________________

    Option 2 : Another option is, you could try direcly filling the wt_key, witht, wt_withcd in the

    ACCOUNTWT table in the BAPI. If this works there is no need to implement step 3.

    wt_item_th = wt_item_th + 1.

    wa_ACCOUNTWT-ITEMNO_ACC = wt_item_th . "ACCWT-WT_KEY

    wa_ACCOUNTWT-WT_TYPE = t059z-witht. "ACCWT-WITHT

    wa_ACCOUNTWT-WT_CODE = t059z-wt_withcd. "ACCWT-WT_WITHCD

    wa_ACCOUNTWT-BAS_AMT_LC = wa_data-witht. "Withholding tax base amount from input file.

    append wa_ACCOUNTWT to IT_ACCOUNTWT.

    ______________________________________________________________________________

    Step 2


    This WHT information is passed in the BAPI.

    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

    EXPORTING

    DOCUMENTHEADER = DOCHEADER

    IMPORTING

    OBJ_TYPE = OBJ_TYPE

    OBJ_KEY = OBJ_KEY

    OBJ_SYS = OBJ_SYS

    TABLES

    ACCOUNTGL = ACCOUNTGL

    ACCOUNTPAYABLE = ACCOUNTPAY

    ACCOUNTTAX = ACCOUNTTAX

    CURRENCYAMOUNT = CURRAMOUNT

    ACCOUNTWT = IT_ACCOUNTWT " For Withholding Tax (Option 2)

    EXTENSION1 = IT_EXTENSION " Withholding tax details (option 1)

    RETURN = RETURN1.

    Step 3 (Only for option 1)

    Inside the user exit, populate table t_accwt. Use the Business transaction event BTE to implement this.

    LOOP AT extension WHERE field1 EQ 'WHT'.

    MOVE extension-field2+0(6) TO t_accwt-wt_key.

    MOVE extension-field2+6(2) TO t_accwt-witht.

    MOVE extension-field2+8(2) TO t_accwt-wt_withcd.

    MOVE extension-field3 TO t_accwt-wt_qsshb.

    * MOVE extension-field3 TO t_accwt-wt_qbuihb.

    APPEND t_accwt.

    ENDLOOP.

    Check this document toimplement this BTE.

    http://wiki.scn.sap.com/wiki/display/ABAP/Business+Transaction+Event+-+RWBAPI01+-+For+Accounting+Document+Interface

    You could also see these related threads.

    http://scn.sap.com/thread/1565269

    https://scn.sap.com/message/4607117

    https://scn.sap.com/thread/1900727

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Susmitha Susan Thomas

      Hi Susmitha mam,

      Sorry for the late reply i was working on some other task. Now im back on this withholding tax issue.

      By far i have tried by Accountwt structure no success and information is not getting updated also in document.

      then i tried with extension1 and used btw by this method withholding information was getting passed and reflected in document but the tax was getting calculated 0.

      So you suggested me to check the tax code and its tax rate and as you said it was zero so tax was getting calculated zero.

      so i changed the tax code for the vendor. Any tax code which didnt had QSATZ = 0.

      still the tax is being recorded zero.

      so some one suggested me to use Function module FI_WITHHOLDING_TAX_CALCULATION to calculate tax in my program and than pass the calculated amount manually using Accountwt structure.thus using Accountwt again but Now tax is being calculated using this FM (inside my program)but its not being reflected in document(FB03)

      Susmitha mam pls guide me futher now what should i do.???

  • author's profile photo
    Former Member
    Nov 29, 2013 at 12:05 PM

    Hi Susmitha mam,

    Sorry for the late reply i was working on some other task. Now im back on this withholding tax issue.

    By far i have tried by Accountwt structure no success and information is not getting updated also in document.

    then i tried with extension1 and used btw by this method withholding information was getting passed and reflected in document but the tax was getting calculated 0.

    So you suggested me to check the tax code and its tax rate and as you said it was zero so tax was getting calculated zero.

    so i changed the tax code for the vendor. Any tax code which didnt had QSATZ = 0.

    still the tax is being recorded zero.

    so some one suggested me to use Function module FI_WITHHOLDING_TAX_CALCULATION to calculate tax in my program and than pass the calculated amount manually using Accountwt structure.thus using Accountwt again but Now tax is being calculated using this FM (inside my program)but its not being reflected in document(FB03)

    Susmitha mam pls guide me futher now what should i do.???

    Add comment
    10|10000 characters needed characters exceeded