Application Development 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: 

Type-incompatible error occur when using 'DO - varying'. How to fix it?

Former Member
0 Kudos

Hi, all,

When i do my program, i meet an error message like this: " "FX01" and "VAR" are type-incompatible. ".

And the following is part of my coding:

DATA: FX1(36) VALUE 'MENGE MEINS DMBTR WAERS ERFMG ERFME WRBTR'.

DATA: FX2(36) VALUE 'BPMNG BPRME BSTMG BSTME EXBWR VKWRT '.

DATA: FX3(36) VALUE 'EXVKW VKWRA LSMNG LSMEH SHKZG $$$$$ '.

DATA: VAR(6), NAME(20), TYPE.

FIELD-SYMBOLS: <F>.

DATA: COLOR TYPE SLIS_T_SPECIALCOL_ALV WITH HEADER LINE.

DATA: BELEGE TYPE BELEGTAB OCCURS 0 WITH HEADER LINE.

DO VARYING VAR FROM FX1 NEXT FX1+6.

IF VAR(1) = '$'. EXIT. ENDIF.

CONCATENATE 'BELEGE-' VAR(5) INTO NAME.

ASSIGN (NAME) TO <F>.

COLOR-FIELDNAME = VAR.

COLOR-COLOR-INT = 0.

IF BELEGE-SHKZG = 'H'.

DESCRIBE FIELD <F> TYPE TYPE.

COLOR-COLOR-COL = '6'.

APPEND COLOR.

ELSEIF BELEGE-SHKZG = 'S'.

COLOR-COLOR-COL = '5'.

APPEND COLOR.

ENDIF.

ENDDO.

So, does anyone have any idea about this?

Thanks in advance.

5 REPLIES 5

Former Member
0 Kudos

dont know your exact requirement but see..

a varying syntax would be like :

>DO VARYING VAR FROM FX1(1) NEXT FX1+6(1) RANGE fx1.

here VAR has to be of type char1.

Former Member
0 Kudos

complete code should be:-


TYPE-POOLS: imrep, slis.

TYPES: BEGIN OF mseg_typ.
INCLUDE TYPE imrep_matbeleg_typ.
TYPES: END OF mseg_typ.

TYPES: BEGIN OF belegtab.
INCLUDE TYPE mseg_typ.
TYPES: END OF belegtab.

DATA: color TYPE slis_t_specialcol_alv WITH HEADER LINE.
DATA: belege TYPE belegtab OCCURS 0 WITH HEADER LINE.

DATA: fx1(36) VALUE 'MENGE MEINS DMBTR WAERS ERFMG ERFME WRBTR'.
DATA: fx2(36) VALUE 'BPMNG BPRME BSTMG BSTME EXBWR VKWRT '.
DATA: fx3(36) VALUE 'EXVKW VKWRA LSMNG LSMEH SHKZG $$$$$ '.
DATA: var(6), name(20), type.

FIELD-SYMBOLS: <f>.

DO VARYING var FROM fx1 NEXT fx1+6.
  IF var(1) = '$'. EXIT. ENDIF.
  CONCATENATE 'BELEGE-' var(5) INTO name.
  ASSIGN (name) TO <f>.
  color-fieldname = var.
  color-color-int = 0.
  IF belege-shkzg = 'H'.
    DESCRIBE FIELD <f> TYPE type.
    color-color-col = '6'.
    APPEND color.
  ELSEIF belege-shkzg = 'S'.
    color-color-col = '5'.
    APPEND color.
  ENDIF.
ENDDO.

Code Formatted by: Alvaro Tejada Galindo on Jan 4, 2010 3:53 PM

0 Kudos

Hi Jainsi,

Change the Do statement liek this:


DO VARYING var FROM fx1(6) NEXT fx1+6(6) RANGE fx1.

FYI, Do Varying statement has been marked as obsolete control structure

Regards,

Swarna Munukoti

0 Kudos

check this. done use obsolete codes..

DATA: fx1(36) VALUE 'MENGE MEINS DMBTR WAERS ERFMG ERFME'.
*DATA: var(6), name(20), type.
DATA: result_tab TYPE match_result_tab.
data: len type i, den type i.
FIELD-SYMBOLS: <f>.
"find ALL OCCURRENCES OF ` ` in fx1 RESULTS result_tab.
"describe table result_tab lines den.
DO." den times. 
  len = len + 6.
  ASSIGN fx1+len(6) TO <f>.
  if <f> is ASSIGNED.
  WRITE:/ <f>.
  else.
    exit.
  endif.
ENDDO.

the commented code can be kept or removed..

Former Member
0 Kudos

Hi Jiansi,

Just modify slightly the statement to, and it will work. I just now tried.



DO 10 times VARYING VAR FROM FX1(6) NEXT FX1+6(6)  range fx1.


Note : You may have to determine the number of times.. I have taken 10 for example.

Regards,

Amit Mittal.