‎2007 Apr 07 9:28 AM
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.
‎2007 Apr 07 9:40 AM
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
‎2007 Apr 07 9:50 AM
‎2007 Apr 07 10:04 AM
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