2008 Sep 29 6:11 PM
hi,
my internal table is like this,
having 3 fields
number, material, quantiy values are
1,mat1,10
2,mat2,20
3,mat1,30
4,mat3,40
and i want o/p as mat1=30
mat2= 20,mat3=40
pls help me.
2008 Sep 29 7:32 PM
Hi,
Sort itab by matnr.
Delete adjacent duplicates from itab comparing matnr.
Hi Venkat,
to get collected values check the key word "COLLECT".
To remove duplicates sort the table by field you want to eliminate duplicates and use DELETE ADJACENT DUPLICATES FROM <itab> comparing <f1> ... <fn>
Regards,
Karol
2008 Sep 29 6:23 PM
If you are sure with your table format you can do this way:
<field-symbols>: <f_fs1> type data,
<f_fs2> type any.
data: l_text type string.
loop at itab into <f_fs1>.
do 3 times.
ASSIGN COMPONENT sy-index OF STRUCTURE <f_fs1> TO <f_fs2>.
if sy-index eq 1.
l_text = <f_fs2>
else.
concatenate <f_fs2> l_text into l_text.
enddo.
endloop.
regards,
SV.
2008 Sep 29 7:32 PM
Hi,
Sort itab by matnr.
Delete adjacent duplicates from itab comparing matnr.
2008 Sep 29 7:51 PM
Hi ,
U can use append sorted by statement.
and define internal table size is occurs 3.
it will append internal table upto 3 records only.
and mentioned the sort field by last field i mean ur number field (10,20,30)
then u will get correct answer.
try with this.
mean while i try and send you code.
thanks,
surendra Babu vemula
2008 Sep 29 8:00 PM
Hi Venkat,
to get collected values check the key word "COLLECT".
To remove duplicates sort the table by field you want to eliminate duplicates and use DELETE ADJACENT DUPLICATES FROM <itab> comparing <f1> ... <fn>
Regards,
Karol
2008 Sep 29 8:02 PM
Hi venkat,
you use this code and try you will get exact code what u r expecting.
DATA: BEGIN OF itab OCCURS 3,
f1 TYPE i,
f2(10) TYPE c,
f3 TYPE i,
END OF itab.
*
itab-f1 = 1.
itab-f2 = 'MAT1'.
itab-f3 = 10.
APPEND itab.
CLEAR itab.
*
itab-f1 = 2.
itab-f2 = 'MAT2'.
itab-f3 = 20.
APPEND itab.
CLEAR itab.
*
itab-f1 = 3.
itab-f2 = 'MAT1'.
itab-f3 = 30.
APPEND itab.
CLEAR itab.
*
itab-f1 = 4.
itab-f2 = 'MAT3'.
itab-f3 = 40.
APPEND itab.
CLEAR itab.
*
SORT itab BY f2 f3 DESCENDING.
DELETE ADJACENT DUPLICATES FROM itab COMPARING f2.
*
LOOP AT itab.
WRITE: / itab-f2, '=', itab-f3.
ENDLOOP.
output:
MAT1 = 30
MAT2 = 20
MAT3 = 40
thanks,
surendra babu vemula
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |