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

please check below code

laxman_sankhla3
Participant
0 Likes
624

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

6 REPLIES 6
Read only

Former Member
0 Likes
600

Hi Laxman,

Try using AT NEW event for that field in the loop.

Read only

Former Member
0 Likes
600

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

Read only

Former Member
0 Likes
600

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

Read only

0 Likes
600

hi here one error is coming it_stax is a table with out header line

i m donig this work in smartform

Read only

Former Member
0 Likes
600

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..

Read only

Former Member
0 Likes
600

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.