Application Development 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: 

BAPI_ACC_DOCUMENT_POST Withholding tax information for FI Interface

sudhakara_reddy4
Participant
0 Kudos

HI

I am using BAPI (BAPI_ACC_DOCUMENT_POST ) to post accounting document. I am passing the withholding tax details on accountwt component. But still the TDS value are not getting calculated. I am working ECC 6.0 version.

Can anyone please give a sample how this has tob e done. Help is highly appreciated.

14 REPLIES 14

Former Member
0 Kudos

Hi,

In Enhancement ACBAPI01-> EXIT_SAPLACC4_001 ->ZXACCU15.

Try with Following code

LOOP AT EXTENSION.

MOVE EXTENSION-FIELD1+0(6) TO T_ACCWT-WT_KEY.

MOVE EXTENSION-FIELD1+6(2) TO T_ACCWT-WITHT.

MOVE EXTENSION-FIELD1+8(2) TO T_ACCWT-WT_WITHCD.

MOVE EXTENSION-FIELD2 TO T_ACCWT-WT_QSSHB.

MOVE EXTENSION-FIELD3 TO T_ACCWT-WT_QBUIHB.

APPEND T_ACCWT.

ENDLOOP.

DATA L_WTKEY LIKE ACCIT_WT-WT_KEY.

L_WTKEY = '000001'.

LOOP AT T_ACCIT WHERE KOART = 'K'.

MOVE L_WTKEY TO T_ACCIT-WT_KEY.

MODIFY T_ACCIT.

L_WTKEY = L_WTKEY + 1.

ENDLOOP.

Read the function module documentation EXIT_SAPLACC4_001

Now check with BAPI.

Regards,

Ravi.

0 Kudos

Hi,

The above exit will be usefull for following Bapi only

BAPI_ACC_BILLING_CHECK AcctngBilling

BAPI_ACC_BILLING_POST AcctngBilling

BAPI_ACC_EMPLOYEE_EXP_CHECK AcctngEmplyeeExpnses

BAPI_ACC_EMPLOYEE_EXP_POST AcctngEmplyeeExpnses

BAPI_ACC_EMPLOYEE_PAY_CHECK AcctngEmplyeePaybles

BAPI_ACC_EMPLOYEE_PAY_POST AcctngEmplyeePaybles

BAPI_ACC_EMPLOYEE_REC_CHECK AcctngEmplyeeRcvbles

BAPI_ACC_EMPLOYEE_REC_POST AcctngEmplyeeRcvbles

BAPI_ACC_GOODS_MOVEMENT_CHECK AcctngGoodsMovement

BAPI_ACC_GOODS_MOVEMENT_POST AcctngGoodsMovement

BAPI_ACC_INVOICE_RECEIPT_CHECK AcctngInvoiceReceipt

BAPI_ACC_INVOICE_RECEIPT_POST AcctngInvoiceReceipt

you can use BAPI_ACC_INVOICE_RECEIPT_POST AcctngInvoiceReceipt to post Vndor invoices

Regards

Ravi

0 Kudos

Hi,

thank you for your reply. If i post the documents using FB01 for vendor all withholding tax information is caluclated automatically. but when i used bapi it is not calucationg automatically. Please check the below code and suggest me how to do.

 
SELECT * FROM lfbw
          INTO TABLE t_lfbw
          WHERE lifnr EQ i_item-vendor_no.
        IF sy-subrc = 0.
          LOOP AT t_lfbw INTO t_lfbw.
            i_accountwt-itemno_acc = l_itemnoacc.
            i_accountwt-wt_type = t_lfbw-witht.
            i_accountwt-wt_code = t_lfbw-wt_withcd.
            i_accountwt-bas_amt_tc = i_item-amt_doccur.
            APPEND i_accountwt TO i_accountwt.
          ENDLOOP.
        ENDIF.

0 Kudos

Hi,

I also faced simillar suituation while posting vendor invoices. when i post manually through transcation with-holding tax calculated automatically but not in BAPI. In forum Some one suggested for enhancement.

let us wait for others reply for BAPI_ACC_ DOCUMENT_POST.

Also search for any OSS note

Regards,

Ravi.

Edited by: rshankar on Dec 23, 2009 3:17 PM

Edited by: rshankar on Dec 23, 2009 3:23 PM

former_member387317
Active Contributor
0 Kudos

Hi Sudhakara Reddy,

You need to use

FM BAPI_TRANSACTION_COMMIT after calling BAPI_ACC_DOCUMENT_POST

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7

ilesh Nandaniya

0 Kudos

Hi All,

We are also facing the same problem. If you got the solution can you please let us know.

Please find the below details what we have implemented. Recently our company implemented the Extended with holding tax.

We are using the BAPI_ACC_DOCUMENT_POST to post documents in sevaral custom programs.

I have serached and found a OSS note 487722 and implemented the BTE and respective function module after implementing.

The with holding tax type is getting populated but not the tax code and the respective amounts.

Appriciate your help...

Thanks

0 Kudos

hi

you need to calculate withhold tax items and fill the that table manually.


REFRESH t_lfbw.
          SELECT * FROM lfbw
            INTO TABLE t_lfbw
            WHERE lifnr EQ i_item-vendor_no.
          IF sy-subrc = 0.
            LOOP AT t_lfbw INTO t_lfbw.

              i_accountwt-itemno_acc = l_itemnoacc.
              i_accountwt-wt_type = t_lfbw-witht.
              i_accountwt-wt_code = t_lfbw-wt_withcd.
              i_accountwt-bas_amt_tc = i_item-amt_doccur.

              i_accountwt-bas_amt_lc = i_item-amt_doccur.
              SELECT SINGLE *
                FROM t059z
                INTO wa_t059z
                WHERE land1 = 'IN'
                  AND witht = i_accountwt-wt_type

                  AND wt_withcd = i_accountwt-wt_code.
              i_accountwt-man_amt_tc
               = ( i_item-amt_doccur * wa_t059z-qsatz ) / 100.
              IF  i_accountwt-man_amt_tc < 0.
                i_accountwt-man_amt_tc = i_accountwt-man_amt_tc * -1.

              ENDIF.
              i_accountwt-man_amt_lc = i_accountwt-man_amt_tc.
              i_accountwt-bas_amt_ind = c_x.
              i_accountwt-man_amt_ind = c_x.
              APPEND i_accountwt TO i_accountwt.

            ENDLOOP.
            SELECT SINGLE zfbpid
              FROM zfcoincoremap
              INTO  i_accountpayable-businessplace
              WHERE prctr = i_item-profit_ctr.
            i_accountpayable-sectioncode = i_accountpayable-businessplace.

          ENDIF.

Thanks & regards

Sudhakara Reddy

Edited by: sudhakara reddy on Mar 4, 2010 12:15 PM

0 Kudos

Hi,

Could you please guide me on how you have implemented this BTE?

regards,

JP

0 Kudos

Hi, i'm facing similar issues.

I already applied note 1130678.

Just have a question.

Is necesary to update   currencyamount table with values from accountwt?

and what in sectioncode? I don't see what to fill in this field.

Thanks

0 Kudos

Hi I am no longer remember what i have done at time, soory.

sudhakara_reddy4
Participant
0 Kudos

Solved myself.

0 Kudos

Hi,

I also have the same requirement. Can you please guide me step by step on you have resolved this.

regards,

JP

0 Kudos

Hi Sudhakar,

Please let us know how you resolved withholding tax update using BAPI ?

Thanks,

Varma

0 Kudos

Hi I had a similar problem, I let them how I solved it

data: obj_type like bapiache09-obj_type,
      obj_key like bapiache09-obj_key,
      obj_sys like bapiache09-obj_sys,
      documentheader like bapiache09,
      accountgl like bapiacgl09 occurs 0 with header line,
      ACCOUNTTAX like BAPIACTX09 occurs 0 with header line,
      ACCOUNTWT like BAPIACWT09 occurs 0 with header line,
      accountpayable like BAPIACAP09 occurs 0 with header line,
    
      accountreceivable like bapiacar09 occurs 0 with header line,
      currencyamount like bapiaccr09 occurs 0 with header line,
      return like bapiret2 occurs 0 with header line,
      extension1 like bapiextc occurs 0 with header line,
      t_edidd like edidd occurs 0 with header line,
      bapi_retn_info like bapiret2 occurs 0 with header line.

data: error_flag, errTotal.
data: anulado TYPE i, linea TYPE i, TAXCODE TYPE BSEG-MWSKZ,
      PRET TYPE T059Z-QSATZ VALUE 0, KBETR TYPE KONP-KBETR VALUE 0,
      KBETR13 TYPE KONP-KBETR VALUE 0, RESULTADO TYPE BSEG-WRBTR, MONTO13 TYPE BSEG-WRBTR,
      MONTO1 TYPE BSEG-WRBTR, MONTO TYPE BSEG-WRBTR.

LOOP AT itDsol."This a Internal Table that contains the accounting transactions
  error_flag = ' '.
----------------------------------------------
This valided
----------------------------------------------
  "We validate THE CENTER OF PROFIT AND FUNCTIONAL AREA exist
  IF itDsol-Total > 0.
    SELECT * INTO CORRESPONDING FIELDS OF TABLE itBseg
    FROM bseg
    WHERE KUNNR EQ itDsol-CUSTOMER AND
          SGTXT EQ itDsol-SGTXT.

    IF sy-subrc = 0. "ENCONTRO DATOS
        SELECT * INTO CORRESPONDING FIELDS OF TABLE itBKPF
        FROM BKPF
        WHERE BUKRS = itBseg-bukrs AND GJAHR = itBseg-gjahr
          AND BELNR = itBseg-belnr.

        anulado = STRLEN( itBkpf-STBLG ).

        IF anulado = 0.
          error_flag = 'X'.
          errTotal = 'X'.
        ENDIF.
    ENDIF.

    IF STRLEN( itDsol-PROFIT_CTR ) = 0.
      error_flag = 'X'.
      errTotal = 'X'.
    ELSEIF  STRLEN( itDsol-FUNC_AREA ) = 0.
      error_flag = 'X'.
      errTotal = 'X'.
    ENDIF.
  ENDIF.
----------------------------------------------
Start
----------------------------------------------

  IF error_flag <> 'X' AND itDsol-Total > 0. "Encontro datos

    CASE itDsol-TAXGROUP.
      WHEN 'ZFAC'.
        TAXCODE  = 'V7'.
      WHEN 'ZCCF'.
        TAXCODE  = 'V6'.
      WHEN OTHERS.
        TAXCODE  = 'V0'.
    ENDCASE.

----------------------------------------------
VERIFICAMOS SI ES GRAN CONTRIBUYENTE
----------------------------------------------

    SELECT * INTO CORRESPONDING FIELDS OF TABLE itKnbw
    FROM KNBW
    WHERE KUNNR EQ itDsol-CUSTOMER AND WITHT EQ 'AR'
      AND WT_WITHCD EQ 'AR'
      AND WT_AGTDF <= itDsol-BLDAT AND WT_AGTDT >= itDsol-BLDAT.

    IF sy-subrc = 0. "FIND DATA
    "----------buscamos el %
      SELECT * INTO CORRESPONDING FIELDS OF TABLE itRet
      FROM T059Z
      WHERE LAND1 EQ 'SV' AND WITHT EQ 'AR'
        AND WT_WITHCD EQ 'AR'.

      IF sy-subrc = 0. "ENCONTRO DATOS
        LOOP AT itRet.
          PRET = itRet-QSATZ.
        ENDLOOP.
      ELSE.
        PRET = 0.
      ENDIF.
    ELSE.
      PRET = 0.
    ENDIF.

----------------------------------------------
LOOK FOR % OF IVA
----------------------------------------------
    SELECT KONP~KNUMH KONP~KBETR
    APPENDING CORRESPONDING FIELDS OF TABLE itKONP
    FROM A003 INNER JOIN KONP ON A003~KNUMH EQ KONP~KNUMH
    WHERE A003~ALAND EQ 'SV' AND A003~MWSKZ IN ('V6','V7').

    IF sy-subrc = 0 AND TAXCODE <> 'V0'. "ENCONTRO DATOS
      LOOP AT itKONP.
        KBETR = itKONP-KBETR / 10.
        KBETR13 = itKONP-KBETR / 10.
      ENDLOOP.
    ENDIF.

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

******* SE INICIA LA TRANSACCION PARA CREAR EL MOVIMIENTO CONTABLE **********

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

    CLEAR: documentheader.

    documentheader-username = sy-uname.
    documentheader-header_txt = itDsol-SGTXT.
    documentheader-comp_code =  itDsol-BUKRS.
    documentheader-doc_date = itDsol-BLDAT.
    documentheader-pstng_date = itDsol-BLDAT.
    documentheader-doc_type = 'IR'.

    CLEAR: accountreceivable.
    REFRESH: accountreceivable.

    CLEAR: currencyamount.
    REFRESH: currencyamount.

    CLEAR: accountgl.
    REFRESH: accountgl.

    CLEAR: ACCOUNTWT.
    REFRESH:  ACCOUNTWT.

    CLEAR: ACCOUNTTAX.
    REFRESH: ACCOUNTTAX.

    CLEAR: accountpayable.
    REFRESH: accountpayable.

    MONTO = 0.
    MONTO13 = 0.
    RESULTADO = 0.

*

*    CLEAR: EXTENCION1.
*    REFRESH: EXTENCION1.

    IF PRET > 0 AND itDsol-TOTAL >= 100.
*      KBETR = KBETR13 - PRET.
       Monto1 = ( ( itDsol-TOTAL * PRET ) / 100 ).
*       PERFORM REDONDEAR USING MONTO Monto1.
       Monto13 = ( ( itDsol-TOTAL * KBETR ) / 100 ).
*       PERFORM REDONDEAR USING MONTO Monto13.
       Resultado = itDsol-TOTAL + ( Monto13 - Monto1 ).
    ELSE.
      Resultado = itDsol-TOTAL + ( ( itDsol-TOTAL * KBETR ) / 100 ).
      Monto13 = ( ( itDsol-TOTAL * KBETR ) / 100 ).
*      PERFORM REDONDEAR USING MONTO Resultado.
    ENDIF.

      Linea = 1.
*    IF itDsol-Electricidad > 0.
      accountreceivable-itemno_acc = Linea.
      accountreceivable-comp_code = itDsol-BUKRS.
      accountreceivable-customer = itDsol-CUSTOMER.
      accountreceivable-PMNTTRMS = itDsol-ZTERM. "condicion de pago
*      accountreceivable-TAX_CODE = TAXCODE.
      accountreceivable-item_text = itDsol-SGTXT. "vElectxt.
      append accountreceivable.

*      MONTO = itDsol-TOTAL + ( ( itDsol-TOTAL * KBETR ) / 100 ).
*      PERFORM REDONDEAR USING MONTO  RESULTADO.
      currencyamount-itemno_acc = Linea.
      currencyamount-currency = 'USD'.
      currencyamount-amt_doccur = Resultado. "itDsol-TOTAL + ( ( itDsol-TOTAL * KBETR ) / 100 ).  "( itDsol-Electricidad + ( ( itDsol-Electricidad * KBETR ) / 100 ) ) + ( itDsol-Agua + ( ( itDsol-Agua * KBETR ) / 100 ) ). "itDsol-WRBTR.
      append currencyamount.

      Linea = Linea + 1.
*    ENDIF.

    if PRET > 0 AND itDsol-TOTAL >= 100.
        "Datos del proveedor
*        SELECT * FROM lfbw
*        INTO TABLE itlfbw
*        WHERE lifnr EQ itDsol-CUSTOMER.
        accountpayable-itemno_acc = Linea.
        accountpayable-comp_code = itDsol-BUKRS.
*        accountreceivable-customer = itDsol-CUSTOMER.
        accountpayable-gl_account = '0000126020'.
        accountpayable-W_TAX_CODE = 'AR'.
        accountpayable-item_text = 'Retención de Gran Contribuyente'.
        append accountpayable.

        ACCOUNTWT-ITEMNO_ACC = Linea.
        ACCOUNTWT-WT_TYPE = 'AR'.
        ACCOUNTWT-WT_CODE = 'AR'.
        APPEND ACCOUNTWT.

*        MONTO = ( ( itDsol-TOTAL * PRET ) / 100 ).
*        PERFORM REDONDEAR USING MONTO RESULTADO.
        currencyamount-itemno_acc = Linea.
        currencyamount-currency = 'USD'.
        currencyamount-amt_doccur = Monto1. "( ( itDsol-TOTAL * PRET ) / 100 ). "itDsol-WRBTR.
        currencyamount-AMT_BASE = itDsol-TOTAL.
        append currencyamount.

        Linea = Linea + 1.
    endif.

    IF TAXCODE <> 'V0'.
      ACCOUNTTAX-ITEMNO_ACC = Linea.
      ACCOUNTTAX-TAX_CODE = TAXCODE.
      ACCOUNTTAX-gl_account = '0000216040'.
      APPEND ACCOUNTTAX.

*      MONTO = ( ( ( itDsol-TOTAL * KBETR13 ) / 100 ) ).
*      PERFORM REDONDEAR USING MONTO RESULTADO.

      currencyamount-itemno_acc = Linea.
      currencyamount-currency = 'USD'.
      currencyamount-amt_doccur = Monto13 * -1. "( ( ( itDsol-TOTAL * KBETR13 ) / 100 ) ) * -1. "itDsol-WRBTR.
      currencyamount-AMT_BASE = itDsol-TOTAL * -1.
      append currencyamount.

      Linea = Linea + 1.
    ENDIF.

    IF itDsol-Electricidad > 0.

      accountgl-itemno_acc = Linea.
      accountgl-gl_account = itDsol-HKONT.
      accountgl-item_text = vElectxt.
      accountgl-TAX_CODE = TAXCODE.
      accountgl-PROFIT_CTR = itDsol-PROFIT_CTR.
      accountgl-FUNC_AREA_LONG = itDsol-FUNC_AREA.
      append accountgl.

      currencyamount-itemno_acc = Linea.
      currencyamount-currency = 'USD'.
      currencyamount-amt_doccur = itDsol-Electricidad * -1."+ ( ( itDsol-Electricidad * KBETR13 ) / 100 ) ) * -1.
*      currencyamount-AMT_BASE = itDsol-Electricidad * -1.

      append currencyamount.

      Linea = Linea + 1.
    ENDIF.

    IF itDsol-Agua > 0.
      accountgl-itemno_acc = Linea.
      accountgl-gl_account = itDsol-HKONT.
      accountgl-item_text = vAguatxt.
      accountgl-TAX_CODE = TAXCODE.
      accountgl-PROFIT_CTR = itDsol-PROFIT_CTR.
      accountgl-FUNC_AREA_LONG = itDsol-FUNC_AREA.
      append accountgl.

      currencyamount-itemno_acc = Linea.
      currencyamount-currency = 'USD'.
      currencyamount-amt_doccur =  itDsol-Agua * -1."+ ( ( itDsol-Agua  * KBETR13 ) / 100 ) ) * -1.
*      currencyamount-AMT_BASE = itDsol-Agua * -1.
      append currencyamount.
    ENDIF.

    call function 'BAPI_ACC_DOCUMENT_POST'
    exporting
    documentheader = documentheader
*     CUSTOMERCPD =
*     CONTRACTHEADER =
*     IMPORTING
*     OBJ_TYPE =
*     OBJ_KEY =
*     OBJ_SYS =
    tables
    ACCOUNTGL = accountgl
    ACCOUNTRECEIVABLE = accountreceivable
    ACCOUNTPAYABLE = accountpayable
    ACCOUNTTAX = ACCOUNTTAX
    currencyamount = currencyamount
*    CRITERIA =
*    VALUEFIELD =
*    EXTENSION1 = EXTENSION1
    return = return
*    PAYMENTCARD =
*    CONTRACTITEM =
*    EXTENSION2 =
*    REALESTATE =
*    ACCOUNTWT =
*       realestate =            " bapiacre09Real Estate Account Assignment Data
    ACCOUNTWT = ACCOUNTWT.            " bapiacwt09Withholding tax information for FI Interface
      .

    IF sy-subrc <> 0.
      itDsol-Error = return-MESSAGE.
    else.
      LOOP AT return.
        IF NOT return IS INITIAL.
          IF return-type = 'A' or return-type = 'E'.
            error_flag = 'X'.
            errTotal = 'X'.
            itDsol-Semaforo = 1.
            itDsol-Error = return-MESSAGE.
          ELSE.
            itDsol-Semaforo = 3.
            write return-message_v2(10) to itDsol-Bktxt.
          ENDIF.
        ELSE.
          itDsol-Semaforo = 3.
          write return-message_v2(10) to itDsol-Bktxt.
        ENDIF.
     ENDLOOP.
    ENDIF.
  ELSE.
    if itDsol-Total > 0.
      IF anulado = 0.
        itDsol-Error = 'Ya existe transacción para este mes'.
        itDsol-Semaforo = 1.
      ENDIF.
      IF STRLEN( itDsol-PROFIT_CTR ) = 0.
        itDsol-Error = 'No esta asignado centro de beneficio'.
        itDsol-Semaforo = 1.
      ELSEIF  STRLEN( itDsol-FUNC_AREA ) = 0.
        itDsol-Error = 'No esta asignada área funcional'.
        itDsol-Semaforo = 1.
      ENDIF.
    endif.
  ENDIF.
  if itDsol-Total > 0.
    MODIFY itDsol.
  endif.
ENDLOOP.

if errTotal = 'X'.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
*   IMPORTING
*     RETURN    =
  MESSAGE i208(00) WITH 'Se encontrarón errores no se crearon registros'.

else.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
*  
*     =
*  
*     =
  MESSAGE i208(00) WITH 'Transacción exitosa'.
endif.