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

Manipulate Internal Table data

Former Member
0 Likes
925

Hello All,

I have fetched 2 records for a Particular Document Number into a Internal table called t_data.

and the data is:

KUNNR -


blart -


BELNR -- WRBTR - WMWST

TEST3 -


DR -


300000459 - 1000 - -7.00

TEST3 -


DR -


300000459 - 1000 - -8.00

I need to display on the List screen only one record like:

TEST3 -


DR -


300000459 - 1000 - -15.00

How can i achieve this.

Regards,

- PSK

9 REPLIES 9
Read only

Former Member
0 Likes
904

Hi Sravan,

1. COLLECT

This is the thing u require.

2. Declare one more internal table exactly like original.

say CITAB.

3. Loop at ITAB.

Collect ITAB into CITAB.

ENDLOOP.

4. Then display this CITAB.

Regards,

Amit M.

Read only

Former Member
0 Likes
904

use COLLECT ITAB.

Read only

Former Member
0 Likes
904

U can use collect on abap numeric types

Make sure that last field is of numeric type

Regards

PAVAN

Read only

Former Member
0 Likes
904

Hi again,

1. sample code (just copy paste)

REPORT abc LINE-COUNT 15 NO STANDARD PAGE HEADING.

DATA : BEGIN OF itab OCCURS 0,

f1(10) TYPE c,

f2(10) type c,

f3(10) type c,

f4(10) type c,

f5 type i,

END OF itab.

DATA : ctab LIKE itab OCCURS 0 WITH HEADER LINE.

itab-f1 = 'TEST3'.

itab-f2 ='DR'.

itab-f3 = '300000459'.

itab-f4 = '1000'.

itab-f5 = 7.

append itab.

itab-f1 = 'TEST3'.

itab-f2 ='DR'.

itab-f3 = '300000459'.

itab-f4 = '1000'.

itab-f5 = 8.

append itab.

LOOP AT itab.

COLLECT itab INTO ctab.

ENDLOOP.

break-point.

*----


SEE CTAB

regards,

amit m.

Read only

Former Member
0 Likes
904

Hi PSK,

You can use control break statement.

Sort the internal table by kunnr.

and in loop and endloop..use at end of kunnr, use SUM

and display the field.

Regards,

Sadiq

Read only

0 Likes
904
loop at itab.
MOVE ITab TO ITab1. "you will have backup of old data
collect itab1.  "itab1 is of same type of itab
                
endloop.
Read only

Former Member
0 Likes
904

will you have all KUNNR, BLART & BELNR same or will it differ ??

if you have only KUNNR unique you can do as below.

loop at itab1.

v_index = sy-tabix.

v_wmwst = v_wmwst + itab1-wmwst.

at end of KUNNR.

read table itab1 index v_index.

itab2-kunnr = itab1-kunnr.

itab2-blart = itab1-blart.

itab2-belnr = itab1-belnr

*--and so on.

itab2-wmwst = v_wmwst.

append itab2.

clear : v_wmwst.

endat.

endloop.

regards,

srikanth

Read only

0 Likes
904

Hello Srikanth,

Yes, in my case KUNNR, BLART and BELNR are the same.

Regards,

- Sravan

Read only

0 Likes
904

itab1 & itab3 both will have same structures.

then use like

sort itab1 by kunnr blart belnr.

loop at itab1.

itab3 = itab1.

collect itab3.

endloop.

regards

srikanth