Skip to Content
avatar image
Former Member

Regarding Taxes in PO

hi all,

I have one requirement that i have to calculate taxes in Purchase Order .

Please send coding for this.

Regards

Ramireddy

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Aug 12, 2008 at 06:07 AM

    Hello try this

    *&---------------------------------------------------------------------*
    *& Report  ZNC_PTR
    *&
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*
    
    REPORT  ZNC_PTR line-size 200 no standard page heading..
    TABLES : BSEG, MKPF, BKPF,  RSEG, RBKP, VBRK, VBRP, MARA,KNA1.
    
    DATA : BEGIN OF ITAB OCCURS 0,
           NAME1        LIKE     KNA1-NAME1,
    
           TAX_CODE     LIKE     BSEG-KTOSL ,      "TAX CODE
           EBELN        LIKE     RSEG-EBELN ,      "PO NO.
           BELNR        LIKE     BKPF-BELNR ,      "MORO NO
           GJAHR        LIKE     BKPF-GJAHR ,      "ACCOUNTING YEAR
           ACC_BELNR    LIKE     BKPF-BELNR ,      "Accounting Document
           ACC_BUDAT    LIKE     BKPF-BUDAT ,      "Accounting Document DATE
           LIFNR        LIKE     LFA1-LIFNR ,      "CUSTOMER.
           COMP_COD     LIKE     BKPF-BUKRS ,      "COMPANY CODE
           DBTHEAD      LIKE     BSEG-HKONT ,      "DBT ACCOUNT HEAD
           MAKTX        LIKE     MAKT-MAKTX ,      "MATERIAL DESC
           QTY          LIKE     BSEG-MENGE ,      "QTY
           ASVAL        LIKE     BSEG-WRBTR ,      "ASSESSABLE VALUE.
           BED          LIKE     BSEG-WRBTR ,      "BED
    
           ECS          LIKE     BSEG-WRBTR ,      "ECS
    
           TAX_AMT      LIKE     BSEG-WRBTR ,      "TAXABLE AMOUNT
    
           MATNR        LIKE     RSEG-MATNR ,      "MATERIAL NUMBER
    
           EBELP LIKE BSEG-EBELP,
    
           END OF ITAB .
    
    *DATA: JTAB LIKE ITAB OCCURS 0 WITH HEADER LINE  .
    DATA : BEGIN OF IBSEG OCCURS 0,
           TAX_CODE LIKE BSEG-KTOSL ,   "TAX CODE
           QTY LIKE BSEG-MENGE  ,       "QTY
           ASVAL LIKE BSEG-WRBTR ,      "ASSESSABLE VALUE.
           BED LIKE BSEG-WRBTR ,        "BED
           ECS LIKE BSEG-WRBTR ,         "ECS
           TAX_AMT LIKE BSEG-WRBTR ,
           END OF IBSEG .
    
    DATA:BEGIN OF IT_MATNR OCCURS 0,
       MATNR LIKE MARA-MATNR,
       END OF IT_MATNR.
    
    DATA : I_RBKP LIKE RBKP OCCURS 0 WITH HEADER LINE ,
           I_RSEG LIKE RSEG OCCURS 0 WITH HEADER LINE ,
           WA_RSEG LIKE LINE OF I_RSEG,
           I_BKPF LIKE BKPF OCCURS 0 WITH HEADER LINE ,
           I_BSEG LIKE BSEG OCCURS 0 WITH HEADER LINE ,
            I_BSMK LIKE MAKT OCCURS 0 WITH HEADER LINE ,
           I_BSET LIKE BSET OCCURS 0 WITH HEADER LINE ,
    
           J_BSEG LIKE BSEG OCCURS 0 WITH HEADER LINE.
    
    TYPES : BEGIN OF IBSET,
    BELNR LIKE BSET-BELNR,
    TXGRP LIKE BSET-TXGRP,
    
           END OF IBSET .
    
    DATA IT_BSET TYPE STANDARD TABLE OF IBSET.
    DATA WA_BSET LIKE LINE OF IT_BSET.
    
    **************INPUT FIELDS***************************************
    
    SELECT-OPTIONS :   COMP_COD FOR BKPF-BUKRS,
                       GJAHR FOR BKPF-GJAHR,
                       DATE FOR RBKP-BUDAT.
    
    ****************ACCOUNT NO****************************************
    SELECT * FROM RBKP INTO I_RBKP
    
    WHERE
       BUDAT IN DATE.    "POSTING DATE
    
    
    
      CLEAR ITAB.
      ITAB-BELNR = I_RBKP-BELNR .
      ITAB-LIFNR = I_RBKP-LIFNR .
      ITAB-TAX_CODE = I_RBKP-MWSKZ1 .
    
    ******************VENDOR NAME****************************************
    
     SELECT SINGLE NAME1 FROM LFA1 INTO ITAB-NAME1 WHERE LIFNR = ITAB-LIFNR.
    
    
       CONCATENATE I_RBKP-BELNR I_RBKP-GJAHR INTO I_BKPF-AWKEY .
    
    
      SELECT  SINGLE belnr budat FROM BKPF INTO corresponding fields of
    I_BKPF WHERE AWKEY = I_BKPF-AWKEY .
    
      ITAB-ACC_BELNR = I_BKPF-BELNR .
      ITAB-ACC_BUDAT = I_BKPF-BUDAT .
    
    **************************RSEG*************************************
    
      SELECT * FROM RSEG INTO TABLE I_RSEG WHERE BELNR = I_RBKP-BELNR .
    
      LOOP AT I_RSEG.
    
    IF I_RSEG-SHKZG = 'S' .
    
    
    
        ITAB-QTY   = I_RSEG-MENGE.
        ITAB-EBELN = I_RSEG-EBELN .
        ITAB-EBELP = I_RSEG-EBELP .
        ITAB-MATNR = I_RSEG-MATNR.
        ITAB-ASVAL = I_RSEG-WRBTR.
    
    ******************TAXES******************************************
    
        SELECT SINGLE BELNR TXGRP FROM BSET INTO WA_BSET WHERE BELNR =
    I_BKPF-BELNR AND FWBAS = I_RSEG-WRBTR.
    
        SELECT * FROM BSET INTO TABLE I_BSET WHERE BELNR = WA_BSET-BELNR
    AND
     TXGRP = WA_BSET-TXGRP.
        LOOP AT I_BSET.
    
    
          IF I_BSET-KSCHL = 'ZPI1'.
    
            ITAB-BED = I_BSET-HWSTE.
            CONTINUE.
          ENDIF.
    
          IF I_BSET-KSCHL = 'ZPIJ'.
            ITAB-ECS = I_BSET-HWSTE.
            CONTINUE.
          ENDIF.
    
    
    
        ENDLOOP.
    
    
        SELECT SINGLE HKONT FROM BSEG INTO ITAB-DBTHEAD  WHERE BELNR =
    I_BKPF-BELNR AND KTOSL = 'WRX'.
    
    
        ITAB-TAX_AMT = ITAB-ECS + ITAB-BED .
    
        APPEND ITAB.
        CLEAR: ITAB-ASVAL,ITAB-BED, ITAB-ECS,
        ITAB-TAX_AMT, ITAB-DBTHEAD.
    
    
    
    ENDIF.
      ENDLOOP.
    
    
    ENDSELECT.
    
     IF SY-SUBRC = 0.
        SELECT * FROM MAKT INTO TABLE I_BSMK
        FOR ALL ENTRIES IN IT_MATNR
        WHERE MATNR = IT_MATNR-MATNR
        AND SPRAS = SY-LANGU.
      ENDIF.
    
    SORT ITAB BY EBELN EBELP.
    LOOP AT ITAB .
    
      READ TABLE I_BSMK WITH KEY MATNR = ITAB-MATNR.
      IF SY-SUBRC = 0.
        ITAB-MAKTX = I_BSMK-MAKTX.
    
    ******************OUTPUT**********************************
    
        WRITE:/1 SY-VLINE ,
    
               2 ITAB-ACC_BELNR    RIGHT-JUSTIFIED,12 SY-VLINE ,
               13 ITAB-ACC_BUDAT   RIGHT-JUSTIFIED,24  SY-VLINE ,
               25 ITAB-LIFNR       RIGHT-JUSTIFIED, 35 SY-VLINE  ,
               36 ITAB-NAME1       RIGHT-JUSTIFIED,75 SY-VLINE ,
               76 ITAB-EBELN      RIGHT-JUSTIFIED, 90 SY-VLINE ,
               91  ITAB-QTY        RIGHT-JUSTIFIED,   120  SY-VLINE ,
    
               121 ITAB-ASVAL      RIGHT-JUSTIFIED  , 140 SY-VLINE,
               141 ITAB-BED        RIGHT-JUSTIFIED , 160 SY-VLINE,
               161 ITAB-ECS        RIGHT-JUSTIFIED  , 180 SY-VLINE ,
    
               181 ITAB-TAX_CODE   RIGHT-JUSTIFIED, 200 SY-VLINE  ,
               201 ITAB-TAX_AMT    RIGHT-JUSTIFIED,  220 SY-VLINE  .
    
        ULINE  .
        IBSEG-QTY     = IBSEG-QTY + ITAB-QTY.
    
        IBSEG-ASVAL   = IBSEG-ASVAL + ITAB-ASVAL .
        IBSEG-BED     = IBSEG-BED + ITAB-BED  .
        IBSEG-ECS     = IBSEG-ECS + ITAB-ECS  .
        IBSEG-TAX_AMT = IBSEG-TAX_AMT + ITAB-TAX_AMT .
    
      ENDIF.
    
    
    ENDLOOP.
    
    APPEND IBSEG.
    
    
    
    SORT IBSEG BY TAX_CODE .
    
    
    LOOP AT IBSEG .
    
    
    
      WRITE:/1 SY-VLINE,  22 'TOTAL',90 SY-VLINE   ,
                          91 IBSEG-QTY        RIGHT-JUSTIFIED , 120 SY-VLINE
    ,
    
                          121 IBSEG-ASVAL     RIGHT-JUSTIFIED , 140 SY-VLINE
    ,
    
                          141 IBSEG-BED       RIGHT-JUSTIFIED , 160 SY-VLINE
    ,
    
                          161 IBSEG-ECS       RIGHT-JUSTIFIED , 180 SY-VLINE
    ,
    
                          181 IBSEG-TAX_CODE  RIGHT-JUSTIFIED, 200 SY-VLINE,
    
                          201 IBSEG-TAX_AMT RIGHT-JUSTIFIED , 220 SY-VLINE
    .
    
    
    
      ULINE.
    
    ENDLOOP .
    
    
    TOP-OF-PAGE.
      WRITE:/ 'PERIOD FOR' , DATE-LOW , 'TO' , DATE-HIGH .
      ULINE  .
      FORMAT COLOR COL_HEADING ON.
      WRITE:/1 SY-VLINE ,
                 2 'DOC. NO.', 12 SY-VLINE ,
                13 'PO DATE' ,24 SY-VLINE,
                25 'VENDOR',  35 SY-VLINE ,
                36 'VENDOR NAME',75 SY-VLINE ,
                 76 'PO NO', 90 SY-VLINE,
                 91 'qty'  , 120 SY-VLINE ,
                121 'AMOUNT'  , 140 SY-VLINE ,
                141 'BED', 160 SY-VLINE ,
                161 'CESS', 180 SY-VLINE ,
                181 'TAXCODE', 200 SY-VLINE,
                201 'TAXAMT' RIGHT-JUSTIFIED , 220 SY-VLINE.
                ULINE   .

    Thanks

    Anirudh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 12, 2008 at 06:13 AM

    Hi,

    USE the Function Module 'PRICING' and pass the required parameters,

    you will get the internal table of all the taxes,

    Hope this will be helpfull for you,

    Regards,

    KP

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 12, 2008 at 06:38 AM

    Hey,

    Find the below code.

    You have to use 'CALCULATE_TAX_ITEM' function module for getting the taxes.

    i am also sending the parameters to be passed.

    DATA : taxcom TYPE taxcom,

    taxcom-bukrs = wa_ekko-bukrs.

    taxcom-budat = wa_ekko-bedat.

    taxcom-bldat = wa_ekko-bedat.

    taxcom-waers = wa_ekko-waers.

    taxcom-hwaer = wa_ekko-waers.

    taxcom-kposn = wa_ekko-ebelp.

    taxcom-mwskz = wa_ekko-mwskz.

    taxcom-shkzg = 'H'.

    taxcom-wrbtr = wa_ekko-netwr.

    taxcom-xmwst = 'X'.

    taxcom-lifnr = wa_ekko-lifnr.

    taxcom-ekorg = wa_ekko-ekorg.

    taxcom-matnr = wa_ekko-matnr.

    taxcom-werks = wa_ekko-werks.

    taxcom-matkl = wa_ekko-matkl.

    taxcom-meins = wa_ekko-meins.

    taxcom-mglme = wa_ekko-menge.

    taxcom-mtart = wa_ekko-mtart.

    taxcom-land1 = 'IN'.

    CALL FUNCTION 'CALCULATE_TAX_ITEM'

    EXPORTING

    i_taxcom = taxcom

    • PRUEFEN = ' '

    • RESET = ' '

    • IMPORTING

    • E_NAVFW =

    • E_TAXCOM =

    • E_XSTVR =

    • NAV_ANTEIL =

    TABLES

    t_xkomv = lt_xkomv

    EXCEPTIONS

    mwskz_not_defined = 1

    mwskz_not_found = 2

    mwskz_not_valid = 3

    steuerbetrag_falsch = 4

    country_not_found = 5

    OTHERS = 6

    .

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 12, 2008 at 06:39 AM

    Hey,

    Find the below code.

    You have to use 'CALCULATE_TAX_ITEM' function module for getting the taxes.

    i am also sending the parameters to be passed.

    DATA : taxcom TYPE taxcom,

    taxcom-bukrs = wa_ekko-bukrs.

    taxcom-budat = wa_ekko-bedat.

    taxcom-bldat = wa_ekko-bedat.

    taxcom-waers = wa_ekko-waers.

    taxcom-hwaer = wa_ekko-waers.

    taxcom-kposn = wa_ekko-ebelp.

    taxcom-mwskz = wa_ekko-mwskz.

    taxcom-shkzg = 'H'.

    taxcom-wrbtr = wa_ekko-netwr.

    taxcom-xmwst = 'X'.

    taxcom-lifnr = wa_ekko-lifnr.

    taxcom-ekorg = wa_ekko-ekorg.

    taxcom-matnr = wa_ekko-matnr.

    taxcom-werks = wa_ekko-werks.

    taxcom-matkl = wa_ekko-matkl.

    taxcom-meins = wa_ekko-meins.

    taxcom-mglme = wa_ekko-menge.

    taxcom-mtart = wa_ekko-mtart.

    taxcom-land1 = 'IN'.

    CALL FUNCTION 'CALCULATE_TAX_ITEM'

    EXPORTING

    i_taxcom = taxcom

    TABLES

    t_xkomv = lt_xkomv

    .

    Add comment
    10|10000 characters needed characters exceeded