‎2010 Mar 18 10:53 AM
Hi Experts,
this code giving some error
report ztry.
data: begin of it occurs 5,
i like sy-index,
t,
end of it,
alpha(5) value 'CBABB'.
do 5 times varying it-t from alpha+0 next alpha+1.
it-i = sy-index.
append it.
enddo.
loop at it.
write: / it-i, it-t.
endloop.
skip.
sort it by t.
loop at it.
write: / it-i, it-t.
endloop.
skip.
sort it by t.
loop at it.
write: / it-i, it-t.
endloop.
skip.
sort it by t i.
loop at it.
write: / it-i, it-t.
endloop.
skip.
sort it by t descending i.
*same as: sort it descending by t i ascending.
loop at it.
write: / it-i, it-t.
endloop.
skip.
sort it.
*same as: sort it by t.
loop at it.
write: / it-t.
endloop."ALPHA" and "IT-T" are type-incompatible.
pls help me in this regards.
ketan...
‎2010 Mar 18 11:01 AM
‎2010 Mar 18 11:08 AM
hi,
thnx for ur reply
but stil givng the same error.
pls try 2 execute the code and reply
ketan..
‎2010 Mar 18 11:11 AM
Hi ,
Please try the below code.
DATA: BEGIN OF it OCCURS 5,
i LIKE sy-index,
t TYPE char1,
END OF it.
DATA : letter.
DATA : BEGIN OF alpha,
one VALUE 'C',
two VALUE 'B',
thr VALUE 'A',
END OF alpha.
DO 3 TIMES VARYING letter FROM alpha-one NEXT alpha-two.
it-i = sy-index.
it-t = letter.
APPEND it.
ENDDO.
LOOP AT it.
WRITE: / it-i, it-t.
ENDLOOP.
SKIP.
SORT it BY t.
LOOP AT it.
WRITE: / it-i, it-t.
ENDLOOP.
SKIP.
SORT it BY t.
LOOP AT it.
WRITE: / it-i, it-t.
ENDLOOP.
SKIP.
SORT it BY t i.
LOOP AT it.
WRITE: / it-i, it-t.
ENDLOOP.
SKIP.
SORT it BY t DESCENDING i.
*same as: sort it descending by t i ascending.
LOOP AT it.
WRITE: / it-i, it-t.
ENDLOOP.
SKIP.
SORT it.
*same as: sort it by t.
LOOP AT it.
WRITE: / it-t.
ENDLOOP.
The output looks like :
1 C
2 B
3 A
3 A
2 B
1 C
3 A
2 B
1 C
3 A
2 B
1 C
1 C
2 B
3 A
A
B
C
Regards,
Chitra
Edited by: Chitra Parameswaran on Mar 18, 2010 4:41 PM
‎2010 Mar 18 11:26 AM
Use simple string offset to get correct aphla.
DATA: pos TYPE i.
DO 5 TIMES.
it-t = alpha+pos(1). "get one char each time, just change the offset
pos = sy-index.
it-i = sy-index.
APPEND it.
ENDDO.
...
Regards
Marcin