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

Former Member
0 Likes
479

hi all,

When i m executing this code an error " p & c are type incompatible" is coming.

Please advise.

REPORT ztx1013.

PARAMETERS p(20) DEFAULT 'c::
\xxx
yyy'.

DATA: c, "current character

n. "next character

DO 19 TIMES VARYING c FROM p0 NEXT p1

VARYING n FROM p1 NEXT p2.

IF c NA ':\'.

CONTINUE.

ENDIF.

IF c = n.

WRITE: / 'duplicate', c, 'found', 'at position', sy-index.

ENDIF.

ENDDO.

3 REPLIES 3
Read only

RaymondGiuseppi
Active Contributor
0 Likes
437

Try

REPORT ztx1013.
PARAMETERS p(20) DEFAULT 'c::\xxx\yyy'.
DATA: c, "current character
n. "next character

DO 19 TIMES VARYING c FROM p+0(1) NEXT p+1(1)
VARYING n FROM p+1(1) NEXT p+2(1).
IF c NA ':'.
CONTINUE.
ENDIF.
IF c = n.
WRITE: / 'duplicate', c, 'found', 'at position', sy-index.
ENDIF.
ENDDO.

Regards

Read only

0 Likes
437

this is not working.

Read only

0 Likes
437

I fear you have to remove the varying and replace them with

pos = sy-index - 1.
c = p+pos(1).
n = p+sy-index(1).

(less elegant)

I always used varying with subfields of a structure not with characters of a field. Abap documentation points on fields :

<i>This addition is useful if you have a series of fields of the same type and the same distance from each other.</i>

Regards