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

type-incompatible.

Former Member
0 Likes
626

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...

4 REPLIES 4
Read only

franois_henrotte
Active Contributor
0 Likes
580

define t like this:

t TYPE char1

Read only

0 Likes
580

hi,

thnx for ur reply

but stil givng the same error.

pls try 2 execute the code and reply

ketan..

Read only

0 Likes
580

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

Read only

0 Likes
580

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