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

Function Module for Tax Calculation calculating wrong Tax Values

desharkshukla
Explorer
0 Likes
2,499

Hi All ,

          I have developed a Smartform for displaying Purchasae Order in which there is a Function Module for Calculating Tax values . Thw Function Module is - CALCULATE_TAX_ITEM . In this F.M , i give an Internal Table as Input which is of TYPE taxcom . For some P.O's , the FM calculates correct tax values of that PO but for some P.O's , it calculates wrong values . Kindly suggest , what should i do in this case .

Thanks -

Deshark Shukla

4 REPLIES 4
Read only

deependra_shekhawat3
Contributor
0 Likes
1,436

Hi Deshark,

that is not internal table....you are passing structure of type taxcom...

and i want to see the code, which values you are passing to structure ...

Thanks,

Deeps

Read only

0 Likes
1,436

Hii Deeps ,

                I am mentioning the code below as asked by you . Here V_TAXCOM is an IT of type TAXCOM and IT_KOMV is an IT of the type KOMV .

                The problem which i am facing is - I am passing V_TAXCOM in the F.M as W.A , so each time when the loop executes it calculates the values of the taxes by using Condition Value(KAWRT) field . If suppose there are 5 line items for 5 different materials and KAWRT field contains diff. values for all line items , then the calculated values in the KWERT column should contain diff. values . But itz not happening . It appends the value of 1st line item for KWERT to the remaining Line Items .

               Please help and suggest me how to resolve this problem ??

Code :-

loop at it_po.
       move :    it_po-bukrs to v_taxcom-bukrs,
                 it_po-budat to v_taxcom-budat,
                 it_po-budat to v_taxcom-bldat,
                 it_po-waers to v_taxcom-waers,
                 it_po-waers to v_taxcom-hwaer,
                 it_po-kposn to v_taxcom-kposn,
                 it_po-mwskz to v_taxcom-mwskz,
                 it_po-wrbtr to v_taxcom-wrbtr,
                 it_po-lifnr to v_taxcom-lifnr,
                 it_po-ekorg to v_taxcom-ekorg,
                 it_po-matnr to v_taxcom-matnr,
                 it_po-werks to v_taxcom-werks,
                 it_po-matkl to v_taxcom-matkl,
                 it_po-meins to v_taxcom-meins,
                 it_po-mglme to v_taxcom-mglme,
                 it_po-mtart to v_taxcom-mtart,
                 it_po-land1 to v_taxcom-land1,
                 'H'         to v_taxcom-shkzg,
                 'X'         to v_taxcom-xmwst.
       select single mwskz txjcd matnr netpr menge
       into (v_mwskz,v_txjcd,v_matnr,v_netpr,v_menge)
       from ekpo
       where ebeln = wa_ekpo-ebeln and loekz = ''.
*       ebelp = v_ebelp AND
       if sy-subrc eq 0.
         v_base = v_netpr * v_menge.
         call function 'CALCULATE_TAX_ITEM'
           exporting
*      ANZAHLUNG                 = ' '
*      DIALOG                    = ' '
*      DISPLAY_ONLY              = ' '
*      INKLUSIVE                 = ' '
*      I_ANWTYP                  = ' '
*      I_DMBTR                   = '0'
*      I_MWSTS                   = '0'
             i_taxcom                  = v_taxcom
*      PRUEFEN                   = ' '
*      RESET                     = ' '
*    IMPORTING
*      E_NAVFW                   =
*      E_TAXCOM                  =
*      E_XSTVR                   =
*      NAV_ANTEIL                =
         tables
         t_xkomv                   it_komv
       exceptions
         mwskz_not_defined         = 1
         mwskz_not_found           = 2
         mwskz_not_valid           = 3
         steuerbetrag_falsch       = 4
         country_not_found         = 5
         others                    = 6
                   .
       endif.
     endloop.


Read only

0 Likes
1,436

Hi Shukla,

Here is the code I have used.

FUNCTION zmm_calculate_tax.

*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IS_EKKO) TYPE  EKKO
*"     REFERENCE(IS_EKPO) TYPE  EKPO
*"  EXPORTING
*"     REFERENCE(TKOMV) TYPE  KOMV_TAB
*"----------------------------------------------------------------------

*Local Data declaration
  DATA :  lwa_tax_com   TYPE j_1b_taxcom ,
          lwa_taxcom    TYPE taxcom ,
          lwa_t001      TYPE t001,
          lwa_lfa1      TYPE lfa1,
          ewa_taxcom    TYPE taxcom ,
          lwa_komv      TYPE komv ,
          l_gv_amount   TYPE netwr ,
          l_unitprice   TYPE netwr,
          l_ipiamount   TYPE netwr,
          l_total_ipi   TYPE netwr,
          l_total       TYPE netwr  ,
          l_taxamount   TYPE netwr,
          lit_komv      TYPE TABLE OF komv.

  SELECT SINGLE * FROM t001
                  INTO lwa_t001
                  WHERE bukrs EQ is_ekko-bukrs.

  SELECT SINGLE * FROM lfa1 INTO lwa_lfa1
                           WHERE lifnr = is_ekko-lifnr.

* Fill tax fields relevant for PO
  lwa_tax_com-txreg_sf = lwa_lfa1-txjcd.
  lwa_tax_com-taxbs    = lwa_lfa1-taxbs.
  lwa_tax_com-ipisp    = lwa_lfa1-ipisp.
  lwa_tax_com-brsch    = lwa_lfa1-brsch.
  lwa_tax_com-txreg_st = is_ekpo-txjcd.
  lwa_tax_com-mtuse    = is_ekpo-j_1bmatuse.
  lwa_tax_com-mtorg    = is_ekpo-j_1bmatorg.
  lwa_tax_com-ownpr    = is_ekpo-j_1bownpro.
  lwa_tax_com-steuc    = is_ekpo-j_1bnbm.
  lwa_tax_com-matkl    = is_ekpo-matkl.
  lwa_tax_com-vrkme    = is_ekpo-meins.
  lwa_tax_com-mgame    = is_ekpo-menge.

* ISS Calculation with 2-level tax jurisdiction code
* Location of service provider = Tax Jur. Code of
* vendor:
  lwa_tax_com-loc_pr   = lwa_lfa1-txjcd.
* Location of service = Tax Jur. Code of delivery address

* Refresh tax field table used in condition-based tax calculation
  CALL FUNCTION 'J_1B_REFRESH_TAX_FIELDS'.
* Refresh PO condition table used in condition-based tax calculation
  CALL FUNCTION 'J_1B_REFRESH_PO_CONDS'.
* Refresh table with nota fiscal tax lines and LPP info
  CALL FUNCTION 'J_1B_REFRESH_NF_TAX_INFO'.

*Populate fields based on country
  CALL FUNCTION 'J_1B_SAVE_TAX_FIELDS'
    EXPORTING
      i_taxcom = lwa_tax_com.

  CLEAR lwa_taxcom.

  lwa_taxcom-bukrs = is_ekpo-bukrs.
  lwa_taxcom-budat = is_ekko-bedat.
  lwa_taxcom-waers = is_ekko-waers.
  lwa_taxcom-kposn = is_ekpo-ebelp.
  lwa_taxcom-mwskz = is_ekpo-mwskz.
  lwa_taxcom-txjcd = is_ekpo-txjcd.
  lwa_taxcom-shkzg = 'H'.
  lwa_taxcom-xmwst = 'X'.

  IF is_ekko-bstyp EQ 'F'.
    lwa_taxcom-wrbtr = is_ekpo-netwr.
  ELSE.
    lwa_taxcom-wrbtr = is_ekpo-zwert.
  ENDIF.

  lwa_taxcom-lifnr = is_ekko-lifnr.
  lwa_taxcom-land1 = is_ekko-lands. "WIA
  lwa_taxcom-ekorg = is_ekko-ekorg.
  lwa_taxcom-hwaer = lwa_t001-waers.
  lwa_taxcom-llief = is_ekko-llief.
  lwa_taxcom-bldat = is_ekko-bedat.
  lwa_taxcom-matnr = is_ekpo-matnr. "HTN-Abwicklung
  lwa_taxcom-werks = is_ekpo-werks.
  lwa_taxcom-bwtar = is_ekpo-bwtar.
  lwa_taxcom-matkl = is_ekpo-matkl.
  lwa_taxcom-meins = is_ekpo-meins.

  IF is_ekko-bstyp EQ 'F'.
    lwa_taxcom-mglme = is_ekpo-menge.
  ELSE.
    IF is_ekko-bstyp EQ 'K' AND is_ekpo-abmng GT 0.
      lwa_taxcom-mglme = is_ekpo-abmng.
    ELSE.
      lwa_taxcom-mglme = is_ekpo-ktmng.
    ENDIF.
  ENDIF.

  IF lwa_taxcom-mglme EQ 0.
    lwa_taxcom-mglme = 1000.
  ENDIF.

  lwa_taxcom-mtart = is_ekpo-mtart.

*Calculation of TAX
  CALL FUNCTION 'CALCULATE_TAX_ITEM'
    EXPORTING
      anzahlung           = 'X'
      i_taxcom            = lwa_taxcom
    IMPORTING
      e_taxcom            = ewa_taxcom
    TABLES
      t_xkomv             = tkomv
    EXCEPTIONS
      mwskz_not_defined   = 1
      mwskz_not_found     = 2
      mwskz_not_valid     = 3
      steuerbetrag_falsch = 4
      country_not_found   = 5
      OTHERS              = 6.

ENDFUNCTION.
Read only

Former Member
0 Likes
1,436

This message was moderated.