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: 

P.O. item taxes

Former Member
0 Kudos
329

hi,

Can any one tell how to retrive the data for tax, e.d., cess.

it tried with several function module like

ME_PRICING_ALL

CALCULATE_TAX_ITEM

etc.

or

some sample code please.

regards,

Prabhu

Points assured.

1 ACCEPTED SOLUTION

Pawan_Kesari
Active Contributor
0 Kudos
189

Calculate Tax of Purchase order Line Item


REPORT zreport10 .

TABLES : ekko , ekpo , t001 , komk , komp .

DATA mwsbp TYPE komp-mwsbp .

PARAMETERS : p_ebeln TYPE ekpo-ebeln ,
             p_ebelp TYPE ekpo-ebelp .


START-OF-SELECTION .

  PERFORM calculate_tax USING p_ebeln p_ebelp CHANGING mwsbp .

  WRITE mwsbp .


*---------------------------------------------------------------------*
*       FORM calculate_tax                                            *
*---------------------------------------------------------------------*
FORM calculate_tax USING    p_ebeln TYPE ekpo-ebeln
                            p_ebelp TYPE ekpo-ebelp
                   CHANGING p_mwsbp TYPE komp-mwsbp .

  CONSTANTS: bstyp-info VALUE 'I',
             bstyp-ordr VALUE 'W',
             bstyp-banf VALUE 'B',
             bstyp-best VALUE 'F',
             bstyp-anfr VALUE 'A',
             bstyp-kont VALUE 'K',
             bstyp-lfpl VALUE 'L',
             bstyp-lerf VALUE 'Q'.

  DATA : taxcom TYPE taxcom ,
         t_konv TYPE TABLE OF komv WITH HEADER LINE .


  DATA: BEGIN OF tkomv OCCURS 50.
          INCLUDE STRUCTURE komv.
  DATA: END OF tkomv.

  DATA: BEGIN OF tkomvd OCCURS 50. "Belegkonditionen
          INCLUDE STRUCTURE komvd.
  DATA: END OF tkomvd.

  DATA : BEGIN OF tkomvh OCCURS 50.
          INCLUDE STRUCTURE komv.
  DATA : vtext LIKE t685t-vtext.
  DATA : END OF tkomvh.

  SELECT SINGLE *
    INTO ekko
    FROM ekko
   WHERE ebeln = p_ebeln .

  SELECT SINGLE *
     INTO ekpo
     FROM ekpo
    WHERE ebeln = p_ebeln
      AND ebelp = p_ebelp .

  SELECT SINGLE *
    INTO t001
    FROM t001
   WHERE bukrs = ekko-bukrs .

  taxcom-bukrs = ekpo-bukrs.
  taxcom-budat = ekko-bedat.
  taxcom-waers = ekko-waers.
  taxcom-kposn = ekpo-ebelp.
  taxcom-mwskz = ekpo-mwskz.
  taxcom-txjcd = ekpo-txjcd.
  taxcom-shkzg = 'H'.
  taxcom-xmwst = 'X'.
  IF ekko-bstyp EQ bstyp-best.
    taxcom-wrbtr = ekpo-netwr.
  ELSE.
    taxcom-wrbtr = ekpo-zwert.
  ENDIF.

  taxcom-lifnr = ekko-lifnr.
  taxcom-land1 = ekko-lands.
  taxcom-ekorg = ekko-ekorg.
  taxcom-hwaer = t001-waers.
  taxcom-llief = ekko-llief.
  taxcom-bldat = ekko-bedat.
  taxcom-matnr = ekpo-ematn.
  taxcom-werks = ekpo-werks.
  taxcom-bwtar = ekpo-bwtar.
  taxcom-matkl = ekpo-matkl.
  taxcom-meins = ekpo-meins.

  IF ekko-bstyp EQ bstyp-best.
    taxcom-mglme = ekpo-menge.
  ELSE.
    IF ekko-bstyp EQ bstyp-kont AND ekpo-abmng GT 0.
      taxcom-mglme = ekpo-abmng.
    ELSE.
      taxcom-mglme = ekpo-ktmng.
    ENDIF.
  ENDIF.
  IF taxcom-mglme EQ 0.
    taxcom-mglme = 1000.
  ENDIF.
  taxcom-mtart = ekpo-mtart.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION 'J_1BSA_COMPONENT_ACTIVE'
       EXPORTING
            bukrs                = ekko-bukrs
            component            = 'BR'
       EXCEPTIONS
            component_not_active = 1
            OTHERS               = 2.

  IF sy-subrc IS INITIAL.

    komk-mandt = ekko-mandt.
    komk-kalsm = ekko-kalsm.
    IF ekko-kalsm = ''.
      komk-kalsm = 'RM0000'.
    ENDIF.
    komk-kappl = 'M'.
    komk-waerk = ekko-waers.
    komk-knumv = ekko-knumv.
    komk-lifnr = ekko-lifnr.
    komp-kposn = ekpo-ebelp.
    komp-matnr = ekpo-matnr.
    komp-werks = ekpo-werks.
    komp-matkl = ekpo-matkl.
    komp-infnr = ekpo-infnr.
    komp-evrtn = ekpo-konnr.
    komp-evrtp = ekpo-ktpnr.


    CALL FUNCTION 'RV_PRICE_PRINT_ITEM'
         EXPORTING
              comm_head_i = komk
              comm_item_i = komp
              language    = 'E'
         TABLES
              tkomv       = tkomv
              tkomvd      = tkomvd.


    CALL FUNCTION 'J_1B_NF_PO_DISCOUNTS'
         EXPORTING
              i_kalsm = ekko-kalsm
              i_ekpo  = ekpo
         IMPORTING
              e_ekpo  = ekpo
         TABLES
              i_konv  = t_konv.

    IF NOT ekko-llief IS INITIAL.
      taxcom-lifnr = ekko-llief.
    ENDIF.

  ENDIF.

  CALL FUNCTION 'FIND_TAX_SPREADSHEET'
       EXPORTING
            buchungskreis = t001-bukrs
       EXCEPTIONS
            not_found     = 1
            OTHERS        = 2.

  CALL FUNCTION 'CALCULATE_TAX_ITEM'
       EXPORTING
            i_taxcom            = taxcom
       IMPORTING
            e_taxcom            = taxcom
       EXCEPTIONS
            mwskz_not_defined   = 1
            mwskz_not_found     = 2
            mwskz_not_valid     = 3
            steuerbetrag_falsch = 4
            country_not_found   = 5
            OTHERS              = 6.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  p_mwsbp = taxcom-wmwst  .

ENDFORM.                    " calculate_tax

5 REPLIES 5

amit_khare
Active Contributor
0 Kudos
189

FM CALCULATE_TAX_ITEM gives u the tax amounts for an item in PO, u need to pass the PO details as export parameters..

Regards,

Amit

Reward all helpful replies.

0 Kudos
189

hi amit,

thanx,

I tried. let me try once again,

possible provide some code.

regards,

Prabhu

Former Member
0 Kudos
189

Hi

These fun modules will not help you to find out the Item level taxes of the PO

First find out the Access sequences related tables of PO Item based on which these taxes are defined.

these are stored in some A* tables (like A003, A012, A353 etc) so you have to find the correct table for theses taxes based on Access sequences of PO

so from that A* table take the KNUMH field and pass to KONP table KNUMH along with the condition type of TAxes to get the Rate(KBETR) and KWERT amounts of that Taxes.

<b>Reward points for useful Answers</b>

Regards

Anji

Pawan_Kesari
Active Contributor
0 Kudos
190

Calculate Tax of Purchase order Line Item


REPORT zreport10 .

TABLES : ekko , ekpo , t001 , komk , komp .

DATA mwsbp TYPE komp-mwsbp .

PARAMETERS : p_ebeln TYPE ekpo-ebeln ,
             p_ebelp TYPE ekpo-ebelp .


START-OF-SELECTION .

  PERFORM calculate_tax USING p_ebeln p_ebelp CHANGING mwsbp .

  WRITE mwsbp .


*---------------------------------------------------------------------*
*       FORM calculate_tax                                            *
*---------------------------------------------------------------------*
FORM calculate_tax USING    p_ebeln TYPE ekpo-ebeln
                            p_ebelp TYPE ekpo-ebelp
                   CHANGING p_mwsbp TYPE komp-mwsbp .

  CONSTANTS: bstyp-info VALUE 'I',
             bstyp-ordr VALUE 'W',
             bstyp-banf VALUE 'B',
             bstyp-best VALUE 'F',
             bstyp-anfr VALUE 'A',
             bstyp-kont VALUE 'K',
             bstyp-lfpl VALUE 'L',
             bstyp-lerf VALUE 'Q'.

  DATA : taxcom TYPE taxcom ,
         t_konv TYPE TABLE OF komv WITH HEADER LINE .


  DATA: BEGIN OF tkomv OCCURS 50.
          INCLUDE STRUCTURE komv.
  DATA: END OF tkomv.

  DATA: BEGIN OF tkomvd OCCURS 50. "Belegkonditionen
          INCLUDE STRUCTURE komvd.
  DATA: END OF tkomvd.

  DATA : BEGIN OF tkomvh OCCURS 50.
          INCLUDE STRUCTURE komv.
  DATA : vtext LIKE t685t-vtext.
  DATA : END OF tkomvh.

  SELECT SINGLE *
    INTO ekko
    FROM ekko
   WHERE ebeln = p_ebeln .

  SELECT SINGLE *
     INTO ekpo
     FROM ekpo
    WHERE ebeln = p_ebeln
      AND ebelp = p_ebelp .

  SELECT SINGLE *
    INTO t001
    FROM t001
   WHERE bukrs = ekko-bukrs .

  taxcom-bukrs = ekpo-bukrs.
  taxcom-budat = ekko-bedat.
  taxcom-waers = ekko-waers.
  taxcom-kposn = ekpo-ebelp.
  taxcom-mwskz = ekpo-mwskz.
  taxcom-txjcd = ekpo-txjcd.
  taxcom-shkzg = 'H'.
  taxcom-xmwst = 'X'.
  IF ekko-bstyp EQ bstyp-best.
    taxcom-wrbtr = ekpo-netwr.
  ELSE.
    taxcom-wrbtr = ekpo-zwert.
  ENDIF.

  taxcom-lifnr = ekko-lifnr.
  taxcom-land1 = ekko-lands.
  taxcom-ekorg = ekko-ekorg.
  taxcom-hwaer = t001-waers.
  taxcom-llief = ekko-llief.
  taxcom-bldat = ekko-bedat.
  taxcom-matnr = ekpo-ematn.
  taxcom-werks = ekpo-werks.
  taxcom-bwtar = ekpo-bwtar.
  taxcom-matkl = ekpo-matkl.
  taxcom-meins = ekpo-meins.

  IF ekko-bstyp EQ bstyp-best.
    taxcom-mglme = ekpo-menge.
  ELSE.
    IF ekko-bstyp EQ bstyp-kont AND ekpo-abmng GT 0.
      taxcom-mglme = ekpo-abmng.
    ELSE.
      taxcom-mglme = ekpo-ktmng.
    ENDIF.
  ENDIF.
  IF taxcom-mglme EQ 0.
    taxcom-mglme = 1000.
  ENDIF.
  taxcom-mtart = ekpo-mtart.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION 'J_1BSA_COMPONENT_ACTIVE'
       EXPORTING
            bukrs                = ekko-bukrs
            component            = 'BR'
       EXCEPTIONS
            component_not_active = 1
            OTHERS               = 2.

  IF sy-subrc IS INITIAL.

    komk-mandt = ekko-mandt.
    komk-kalsm = ekko-kalsm.
    IF ekko-kalsm = ''.
      komk-kalsm = 'RM0000'.
    ENDIF.
    komk-kappl = 'M'.
    komk-waerk = ekko-waers.
    komk-knumv = ekko-knumv.
    komk-lifnr = ekko-lifnr.
    komp-kposn = ekpo-ebelp.
    komp-matnr = ekpo-matnr.
    komp-werks = ekpo-werks.
    komp-matkl = ekpo-matkl.
    komp-infnr = ekpo-infnr.
    komp-evrtn = ekpo-konnr.
    komp-evrtp = ekpo-ktpnr.


    CALL FUNCTION 'RV_PRICE_PRINT_ITEM'
         EXPORTING
              comm_head_i = komk
              comm_item_i = komp
              language    = 'E'
         TABLES
              tkomv       = tkomv
              tkomvd      = tkomvd.


    CALL FUNCTION 'J_1B_NF_PO_DISCOUNTS'
         EXPORTING
              i_kalsm = ekko-kalsm
              i_ekpo  = ekpo
         IMPORTING
              e_ekpo  = ekpo
         TABLES
              i_konv  = t_konv.

    IF NOT ekko-llief IS INITIAL.
      taxcom-lifnr = ekko-llief.
    ENDIF.

  ENDIF.

  CALL FUNCTION 'FIND_TAX_SPREADSHEET'
       EXPORTING
            buchungskreis = t001-bukrs
       EXCEPTIONS
            not_found     = 1
            OTHERS        = 2.

  CALL FUNCTION 'CALCULATE_TAX_ITEM'
       EXPORTING
            i_taxcom            = taxcom
       IMPORTING
            e_taxcom            = taxcom
       EXCEPTIONS
            mwskz_not_defined   = 1
            mwskz_not_found     = 2
            mwskz_not_valid     = 3
            steuerbetrag_falsch = 4
            country_not_found   = 5
            OTHERS              = 6.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  p_mwsbp = taxcom-wmwst  .

ENDFORM.                    " calculate_tax

0 Kudos
189

thanx you very much pawan , excatly suits my requirement.

Anji, yours is right but we have to calculate the BED,Cess and tax based on percentage.

But my scenario is :

We have defined a TAX code which will 16 % of bed, 2% of cess, and JIP 5 is 12.5 % of the total amt + bed + cess.

Then my total tax will be the JIP5 + BED + CESS (only for this particular tax code).

Total tax is not unique in some tax code it will be only 12.5 or 4.00 and so on.

ThanX AMIT.

regards,

Prabhu