2006 Jan 05 6:01 AM
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
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
2006 Jan 05 6:04 AM
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.
2006 Jan 05 6:06 AM
2006 Jan 05 6:06 AM
U can use collect on abap numeric types
Make sure that last field is of numeric type
Regards
PAVAN
2006 Jan 05 6:09 AM
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.
2006 Jan 05 6:12 AM
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
2006 Jan 05 6:19 AM
loop at itab.
MOVE ITab TO ITab1. "you will have backup of old data
collect itab1. "itab1 is of same type of itab
endloop.
2006 Jan 05 7:13 AM
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
2006 Jan 05 7:23 AM
Hello Srikanth,
Yes, in my case KUNNR, BLART and BELNR are the same.
Regards,
- Sravan
2006 Jan 05 7:46 AM
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
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |