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

Processing Internal Table - AT END or ATLAST

Former Member
0 Likes
643

S.No WBS matnr menge menge1

1 00000507 0010000503 00010 1000.000 0.000

2 00000507 0010000504 00010 900.000 0.000

3 00000507 0010000511 00030 3000.000 0.000

4 00000507 0010000511 00060 2000.000 0.000

5 00000531 0010000511 00010 1000.000 0.000

6 00000531 0010000511 00040 1000.000 0.000

7 00000532 0010000511 00020 2000.000 0.000

8 00000532 0010000511 00050 1000.000 0.000

above is an internal table.

how to code that the output should be in such a manner that all identical WBS quantity should be added and displayed correspondingly in the same internal table itself.

S.No WBS matnr menge menge1

1 00000507 0010000503 00010 1000.000 0.000

2 00000507 0010000504 00010 900.000 0.000

3 00000507 0010000511 00030 3000.000 0.000

4 00000507 0010000511 00060 2000.000 6900.00

5 00000531 0010000511 00010 1000.000 0.000

6 00000531 0010000511 00040 1000.000 2000.00

7 00000532 0010000511 00020 2000.000 0.000

8 00000532 0010000511 00050 1000.000 3000.00

This should be the output.

Help with the code.

Thanks for yout time.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
615

Hi

first you need to sort your table by WBS and then apply loop, Use AT END OF event for wbs and calculate the sum of WBS.

like

data: sum type i value = 0.

sort table by EBS.

loop at table.

at end of wbs.

sum = sum + wbs.

endat.

endloop.

try something like this.

Thanks

lalit Gupta

Hi

first you need to sort your table by WBS and then apply loop, Use AT END OF event for wbs and calculate the sum of WBS.

like

data: sum type i value = 0.

sort table by EBS.

loop at table.

at end of wbs.

sum = sum + wbs.

endat.

endloop.

try something like this.

Thanks

lalit Gupta

2 REPLIES 2
Read only

Former Member
0 Likes
616

Hi

first you need to sort your table by WBS and then apply loop, Use AT END OF event for wbs and calculate the sum of WBS.

like

data: sum type i value = 0.

sort table by EBS.

loop at table.

at end of wbs.

sum = sum + wbs.

endat.

endloop.

try something like this.

Thanks

lalit Gupta

Read only

0 Likes
615

Hi ,

Please follow the below step .

- Make sure WBS is the first field in your internal table.

- It must be sorted.

- Calculate the sum for each loop

- Use AT END Control break and update the table with calculated sum.

Please check the below program created based on your requirement.

Loop at it_tab INTO lw_tab.

lv_sum = lv_sum + lw_tab-menge1.

at END OF wbs.

READ TABLE it_tab ASSIGNING <fs_tab> INDEX sy-tabix.

if sy-subrc = 0.

<fs_tab>-total = lv_sum.

clear lv_sum.

endif.

ENDAT.

endloop.

This above code snippet work fine as per your requirement.

Regards,

Deban