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

tax calculation.

naimkhans_babi
Active Participant
0 Likes
764

Dear firends

I am having one problem is with Tax calculation, I am calculating 2 types of tax one is with education cess and another without it. my problem is i found the amount which i have calculated which is not proper,

please look at my code and tell me where i am making mistakes.

regards

Naeem

loop at t_komv .

IF ( t_komv-waers = '%' OR

t_komv-kschl = 'JSRE' OR

t_komv-kschl = 'JSRF' OR

t_komv-kschl = 'JES8' ).

IF t_komv-kschl = 'JSRE' .

g_percentage = t_komv-kbetr / 10.

ELSEIF t_komv-kschl = 'JSRF'.

g_percentage1 = t_komv-kbetr / 10.

ELSEif t_komv-kschl = 'JES8'.

g_percentage2 = t_komv-kbetr / 10.

ENDIF.

ADD t_komv-kwert TO l_stax1-amt. <---- here i am not receiving the correct amount. ( on 20000 @12.36 it should be 2472 but i am receiving @12.24% 2448)

ENDIF.

IF ( t_komv-waers = '%' OR

t_komv-kschl = 'JSER' OR

t_komv-kschl = 'JSVD' ).

IF t_komv-kschl = 'JSER' .

g_percentage = t_komv-kbetr / 10.

ELSEif t_komv-kschl = 'JSVD'.

g_percentage1 = t_komv-kbetr / 10.

ENDIF.

ADD t_komv-kwert TO l_stax1-amt. (here i receive correct result 10000 @ 12.24% 1224).

ENDIF.

IF ( t_komv-waers = '%' OR

t_komv-kschl = 'JSRC' OR

t_komv-kschl = 'JSRD' OR

t_komv-kschl = 'JES3' ).

IF t_komv-kschl = 'JSRC' .

g_percentage = t_komv-kbetr / 10.

ELSEIF t_komv-kschl = 'JSRD'.

g_percentage1 = t_komv-kbetr / 10.

ELSEif t_komv-kschl = 'JES3'.

g_percentage2 = t_komv-kbetr / 10.

ENDIF.

ADD t_komv-kwert TO l_stax1-amt.

*add t_komv-kwert to l_stax-amt.

ENDIF.

IF ( ( g_percentage IS NOT INITIAL AND

g_percentage1 IS NOT INITIAL AND

g_percentage2 IS NOT INITIAL ) AND

( t_komv-kschl = 'JSRE' OR

t_komv-kschl = 'JSRF' OR

t_komv-kschl = 'JSER' OR

t_komv-kschl = 'JSVD' OR

t_komv-kschl = 'JSRC' OR

t_komv-kschl = 'JSRD' OR

t_komv-kschl = 'JES8' OR

t_komv-kschl = 'JES3') ).

g_mul = g_percentage * ( g_percentage1 + g_percentage2 ).

g_percentage3 = g_percentage + ( g_mul / 100 ).

l_stax1-per = g_percentage3.

COLLECT l_stax1 INTO it_stax.

wa_sitem-item = <fs>-ebelp.

wa_sitem-per = l_stax1-per.

SHIFT wa_sitem-item LEFT DELETING LEADING '0'.

APPEND wa_sitem TO it_sitem.

CLEAR wa_sitem.

*append l_stax1 to it_stax.

CLEAR : g_percentage, g_percentage1 ,g_percentage2 .

  • ENDIF.

elseif

( ( g_percentage IS NOT INITIAL AND

g_percentage1 IS NOT INITIAL AND

g_percentage2 IS INITIAL ) AND

( t_komv-kschl = 'JSRE' OR

t_komv-kschl = 'JSRF' OR

t_komv-kschl = 'JSER' OR

t_komv-kschl = 'JSVD' OR

t_komv-kschl = 'JSRC' OR

t_komv-kschl = 'JSRD' ) ).

g_mul = g_percentage * g_percentage1 .

g_percentage3 = g_percentage + ( g_mul / 100 ).

l_stax1-per = g_percentage3.

COLLECT l_stax1 INTO it_stax.

wa_sitem-item = <fs>-ebelp.

wa_sitem-per = l_stax1-per.

SHIFT wa_sitem-item LEFT DELETING LEADING '0'.

APPEND wa_sitem TO it_sitem.

CLEAR wa_sitem.

*append l_stax1 to it_stax.

CLEAR : g_percentage, g_percentage1 .

ENDIF.

*comment ends here

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
740

HI naim,

i have done the same check my code,

SELECT VBELN FKART FKDAT KNUMV

FROM VBRK

INTO CORRESPONDING FIELDS OF TABLE IT_VBRK

WHERE FKDAT IN S_DATE.

IF IT_VBRK[] IS NOT INITIAL.

SELECT VBELN POSNR MATNR FKIMG NETWR WERKS VKORG_AUFT PRCTR

FROM VBRP

INTO CORRESPONDING FIELDS OF TABLE IT_VBRP

FOR ALL ENTRIES IN IT_VBRK

WHERE VBELN = IT_VBRK-VBELN

AND WERKS IN S_WERKS

AND VKORG_AUFT IN S_VKORG.

ENDIF.

IF IT_VBRK[] IS NOT INITIAL.

SELECT KNUMV KPOSN KWERT KBETR

FROM KONV

INTO CORRESPONDING FIELDS OF TABLE IT_KONV

FOR ALL ENTRIES IN IT_VBRK

WHERE KNUMV = IT_VBRK-KNUMV.

ENDIF.

IF IT_VBRK[] IS NOT INITIAL.

SELECT KNUMV KPOSN KSCHL

KWERT KBETR

INTO CORRESPONDING FIELDS OF TABLE IT_COND

FROM KONV

FOR ALL ENTRIES IN IT_VBRK

WHERE KNUMV = IT_VBRK-KNUMV.

ENDIF.

SORT IT_COND BY KWERT DESCENDING.

LOOP AT IT_VBRP.

READ TABLE IT_VBRK WITH KEY VBELN = IT_VBRP-VBELN.

READ TABLE IT_COND WITH KEY KNUMV = IT_VBRK-KNUMV KPOSN = IT_VBRP-POSNR KSCHL = 'MWST'.

*here u can check for other condition

IF SY-SUBRC = 0.

IT_FINAL-VBELN = IT_VBRK-VBELN.

IT_FINAL-FKART = IT_VBRK-FKART.

IT_FINAL-FKDAT = IT_VBRK-FKDAT.

IT_FINAL-MATNR = IT_VBRP-MATNR.

IT_FINAL-FKIMG = IT_VBRP-FKIMG.

IT_FINAL-NETWR = IT_VBRP-NETWR.

IT_FINAL-WERKS = IT_VBRP-WERKS.

IT_FINAL-VKORG_AUFT = IT_VBRP-VKORG_AUFT.

IT_FINAL-PRCTR = IT_VBRP-PRCTR.

IT_FINAL-KWERT = IT_COND-KWERT.

IT_FINAL-KBETR = IT_COND-KBETR.

APPEND IT_FINAL.

ENDIF.

ENDLOOP.

LOOP AT IT_FINAL.

IT_FINAL-KBETR = IT_FINAL-KBETR / 10.

MODIFY IT_FINAL TRANSPORTING KBETR.

ENDLOOP.

dont forget to reward points,

Regards,

Imran

Dear firends

I am having one problem is with Tax calculation, I am calculating 2 types of tax one is with education cess and another without it. my problem is i found the amount which i have calculated which is not proper,

please look at my code and tell me where i am making mistakes.

regards

Naeem

loop at t_komv .

IF ( t_komv-waers = '%' OR

t_komv-kschl = 'JSRE' OR

t_komv-kschl = 'JSRF' OR

t_komv-kschl = 'JES8' ).

IF t_komv-kschl = 'JSRE' .

g_percentage = t_komv-kbetr / 10.

ELSEIF t_komv-kschl = 'JSRF'.

g_percentage1 = t_komv-kbetr / 10.

ELSEif t_komv-kschl = 'JES8'.

g_percentage2 = t_komv-kbetr / 10.

ENDIF.

ADD t_komv-kwert TO l_stax1-amt. <---- here i am not receiving the correct amount. ( on 20000 @12.36 it should be 2472 but i am receiving @12.24% 2448)

ENDIF.

IF ( t_komv-waers = '%' OR

t_komv-kschl = 'JSER' OR

t_komv-kschl = 'JSVD' ).

IF t_komv-kschl = 'JSER' .

g_percentage = t_komv-kbetr / 10.

ELSEif t_komv-kschl = 'JSVD'.

g_percentage1 = t_komv-kbetr / 10.

ENDIF.

ADD t_komv-kwert TO l_stax1-amt. (here i receive correct result 10000 @ 12.24% 1224).

ENDIF.

IF ( t_komv-waers = '%' OR

t_komv-kschl = 'JSRC' OR

t_komv-kschl = 'JSRD' OR

t_komv-kschl = 'JES3' ).

IF t_komv-kschl = 'JSRC' .

g_percentage = t_komv-kbetr / 10.

ELSEIF t_komv-kschl = 'JSRD'.

g_percentage1 = t_komv-kbetr / 10.

ELSEif t_komv-kschl = 'JES3'.

g_percentage2 = t_komv-kbetr / 10.

ENDIF.

ADD t_komv-kwert TO l_stax1-amt.

*add t_komv-kwert to l_stax-amt.

ENDIF.

IF ( ( g_percentage IS NOT INITIAL AND

g_percentage1 IS NOT INITIAL AND

g_percentage2 IS NOT INITIAL ) AND

( t_komv-kschl = 'JSRE' OR

t_komv-kschl = 'JSRF' OR

t_komv-kschl = 'JSER' OR

t_komv-kschl = 'JSVD' OR

t_komv-kschl = 'JSRC' OR

t_komv-kschl = 'JSRD' OR

t_komv-kschl = 'JES8' OR

t_komv-kschl = 'JES3') ).

g_mul = g_percentage * ( g_percentage1 + g_percentage2 ).

g_percentage3 = g_percentage + ( g_mul / 100 ).

l_stax1-per = g_percentage3.

COLLECT l_stax1 INTO it_stax.

wa_sitem-item = <fs>-ebelp.

wa_sitem-per = l_stax1-per.

SHIFT wa_sitem-item LEFT DELETING LEADING '0'.

APPEND wa_sitem TO it_sitem.

CLEAR wa_sitem.

*append l_stax1 to it_stax.

CLEAR : g_percentage, g_percentage1 ,g_percentage2 .

  • ENDIF.

elseif

( ( g_percentage IS NOT INITIAL AND

g_percentage1 IS NOT INITIAL AND

g_percentage2 IS INITIAL ) AND

( t_komv-kschl = 'JSRE' OR

t_komv-kschl = 'JSRF' OR

t_komv-kschl = 'JSER' OR

t_komv-kschl = 'JSVD' OR

t_komv-kschl = 'JSRC' OR

t_komv-kschl = 'JSRD' ) ).

g_mul = g_percentage * g_percentage1 .

g_percentage3 = g_percentage + ( g_mul / 100 ).

l_stax1-per = g_percentage3.

COLLECT l_stax1 INTO it_stax.

wa_sitem-item = <fs>-ebelp.

wa_sitem-per = l_stax1-per.

SHIFT wa_sitem-item LEFT DELETING LEADING '0'.

APPEND wa_sitem TO it_sitem.

CLEAR wa_sitem.

*append l_stax1 to it_stax.

CLEAR : g_percentage, g_percentage1 .

ENDIF.

*comment ends here

ENDLOOP.

5 REPLIES 5
Read only

Former Member
0 Likes
741

HI naim,

i have done the same check my code,

SELECT VBELN FKART FKDAT KNUMV

FROM VBRK

INTO CORRESPONDING FIELDS OF TABLE IT_VBRK

WHERE FKDAT IN S_DATE.

IF IT_VBRK[] IS NOT INITIAL.

SELECT VBELN POSNR MATNR FKIMG NETWR WERKS VKORG_AUFT PRCTR

FROM VBRP

INTO CORRESPONDING FIELDS OF TABLE IT_VBRP

FOR ALL ENTRIES IN IT_VBRK

WHERE VBELN = IT_VBRK-VBELN

AND WERKS IN S_WERKS

AND VKORG_AUFT IN S_VKORG.

ENDIF.

IF IT_VBRK[] IS NOT INITIAL.

SELECT KNUMV KPOSN KWERT KBETR

FROM KONV

INTO CORRESPONDING FIELDS OF TABLE IT_KONV

FOR ALL ENTRIES IN IT_VBRK

WHERE KNUMV = IT_VBRK-KNUMV.

ENDIF.

IF IT_VBRK[] IS NOT INITIAL.

SELECT KNUMV KPOSN KSCHL

KWERT KBETR

INTO CORRESPONDING FIELDS OF TABLE IT_COND

FROM KONV

FOR ALL ENTRIES IN IT_VBRK

WHERE KNUMV = IT_VBRK-KNUMV.

ENDIF.

SORT IT_COND BY KWERT DESCENDING.

LOOP AT IT_VBRP.

READ TABLE IT_VBRK WITH KEY VBELN = IT_VBRP-VBELN.

READ TABLE IT_COND WITH KEY KNUMV = IT_VBRK-KNUMV KPOSN = IT_VBRP-POSNR KSCHL = 'MWST'.

*here u can check for other condition

IF SY-SUBRC = 0.

IT_FINAL-VBELN = IT_VBRK-VBELN.

IT_FINAL-FKART = IT_VBRK-FKART.

IT_FINAL-FKDAT = IT_VBRK-FKDAT.

IT_FINAL-MATNR = IT_VBRP-MATNR.

IT_FINAL-FKIMG = IT_VBRP-FKIMG.

IT_FINAL-NETWR = IT_VBRP-NETWR.

IT_FINAL-WERKS = IT_VBRP-WERKS.

IT_FINAL-VKORG_AUFT = IT_VBRP-VKORG_AUFT.

IT_FINAL-PRCTR = IT_VBRP-PRCTR.

IT_FINAL-KWERT = IT_COND-KWERT.

IT_FINAL-KBETR = IT_COND-KBETR.

APPEND IT_FINAL.

ENDIF.

ENDLOOP.

LOOP AT IT_FINAL.

IT_FINAL-KBETR = IT_FINAL-KBETR / 10.

MODIFY IT_FINAL TRANSPORTING KBETR.

ENDLOOP.

dont forget to reward points,

Regards,

Imran

Read only

Former Member
0 Likes
740

Hi Naim ,

are u getting wrong amt in alll cases?

Regards

Peram

Read only

0 Likes
740

No , Only in frist case.. where calculation is at 12.36% but i am having result at 12.24%

regards

naeem

Read only

Former Member
0 Likes
740

I hope u are doing for P.O. or INVOICE, please debug it find, ihope u r missing some condition types or rounding off problem.

regards

prabhu

reward if helpful.

Read only

naimkhans_babi
Active Participant
0 Likes
740

I have used At end of kposn

endat.

and use flag to refresh this thing

it workes

regards

naeem