‎2006 Dec 29 9:34 AM
i want the sum of service which are same
now i m geting indivisual service tax for each item
but i want to sum all the service tax which are same.
for example i m getting like this
service tax 10.20 % 10
service tax 4.0% 4
service tax 10.20 % 100
service tax 4.0% 50
but i want like below
service tax 10.20 % 110
service tax 4.0% 54
i wote below code
IF ( t_komv-waers = '%' OR t_komv-kschl = 'JSRE' OR
t_komv-kschl = 'JSRF' ).
IF t_komv-kschl = 'JSRE' .
g_percentage = t_komv-kbetr / 10.
ELSE.
g_percentage1 = t_komv-kbetr / 10.
ENDIF.
add t_komv-kwert to l_stax-amt.
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.
ELSE.
g_percentage1 = t_komv-kbetr / 10.
ENDIF.
add t_komv-kwert to l_stax-amt.
ENDIF.
IF ( t_komv-waers = '%' OR t_komv-kschl = 'JSRC' OR
t_komv-kschl = 'JSRD' ).
IF t_komv-kschl = 'JSRC' .
g_percentage = t_komv-kbetr / 10.
ELSE.
g_percentage1 = t_komv-kbetr / 10.
ENDIF.
add t_komv-kwert to l_stax-amt.
ENDIF.
IF ( ( g_percentage IS NOT INITIAL AND
g_percentage1 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') ).
g_mul = g_percentage * g_percentage1.
g_percentage3 = g_percentage + ( g_mul / 100 ).
l_stax-per = g_percentage3.
append l_stax to it_stax.
clear : g_percentage, g_percentage1.
ENDIF.
ENDLOOP.
thanks in advanced
‎2006 Dec 29 9:43 AM
‎2006 Dec 29 10:07 AM
TRY TO DECLARE ANOTHER INTERNAL TABLE.
LOOP AT <YOUR INTERNAL TABLE ITAB1>
READ TABLE ITAB2 WITH KEY <SERVICE TAX COLUMN> = ITAB1-SRVCTAX.
IF SY-SUBRC = 0.
ITAB2-<VALUE> = ITAB2-<VALUE> + ITAB1-<VALUE>.
MODIFY ITAB2 INDEX SY-TABIX.
ELSE.
MOVE-CORRESPONDING ITAB1 TO ITAB2.
APPEND ITAB2.
ENDIF.
ENDLOOP.
REGARDS
SHIBA DUTTA
‎2006 Dec 29 10:20 AM
Hi
you an try this way...
1. sort your it_stax by per.
2. Have a similar internal table say itab1.
now,
clear: l_tax, l_amount.
loop at it_stax.
if l_tax NE it_stax-tax.
l_tax = it_stax-tax.
<b> <populate your itab1 here> along with l_amount</b>
clear l_amount.
else.
l_amount = l_amount + it_stax-amt.
endif.
endloop.
Regards,
Raj
‎2006 Dec 29 12:15 PM
hi here one error is coming it_stax is a table with out header line
i m donig this work in smartform
‎2006 Dec 29 11:50 AM
Even simplier just use the COLLECT statement.
- Simply set up your internal table with the key being made up of character types, and the the tax field as a numeric.
- Then simply loop round and collect the data. The collect wil automatcially add the new tax to the record in your itab with the same key..
‎2006 Dec 29 3:39 PM
Then you need to move your data into a work area.
DATA: it_stax TYPE STANDARD TABLE OF bahblah
wa_stax TYPE blahblah.
loop at it_stax INTO wa_stax.