Skip to Content
avatar image
Former Member

type incompatible in do ---varying

Dear all,

I had a statement like

DO len TIMES VARYING C FROM int_objec-ausp1+0 NEXT

int_objec-ausp1+1.

c length 30 char type,

ausp1 also char type,

Bu I am getting error - the above two are type incompatible.

Please give me the solution.

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Aug 21, 2007 at 08:09 AM

    Hi!

    I've found it in the help of the DO statement...

    Addition 1

    ... VARYING f FROM f1 NEXT f2

    Effect

    This addition is useful if you have a series of fieldsof the same type and the same distance from each other.

    f is a variable which you define in a DATA statement. Oneach loop pass, f contains a new value. The field f1after "FROM" specifies the first value of the variable f,while the field f2 after "NEXT" specifies the value to beassigned to the variable f in the second pass. For eachsubsequent pass, the variable f contains the next value in thesequence determined by the distance between the fields f, f1 and f2 in memory.

    The fields f1 and f2 should be type-compatible andconvertible to f.

    If the value of f changes during the loop pass, the new value isthen placed in the appropriate field fn assigned to f(transfer type: pass by value and result). If the loop pass terminatesbecause of a dialog message, the new value is not passed back if f changes.

    The addition ... VARYING f FROM f1 NEXT f2 can be used severaltimes in a DO statement.

    Example

    DATA: BEGIN OF WORD,

    ONE VALUE 'E',

    TWO VALUE 'x',

    THREE VALUE 'a',

    FOUR VALUE 'm',

    FIVE VALUE 'p',

    SIX VALUE 'l',

    SEVEN VALUE 'e',

    EIGHT VALUE '!',

    END OF WORD,

    LETTER1, LETTER2.

    DO VARYING LETTER1 FROM WORD-ONE NEXT WORD-THREE

    VARYING LETTER2 FROM WORD-TWO NEXT WORD-FOUR.

    WRITE: LETTER1, LETTER2.

    IF LETTER2 = '!'.

    EXIT.

    ENDIF.

    ENDDO.

    The resulting output is the character string

    "E x a m p l e !".

    Note

    When using this addition, ensure that the DO loopterminates at the "right" time, in order to avoid assigning meaninglessvalues that happen to be in memory after this sequence of fields. Thiscould result in a runtime error.

    Regards

    Tamá

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 21, 2007 at 09:06 AM

    HI ravi,

    1. If there is a repeat structure, then we should use do varying.

    2. If u have

    int_objec-ausp1

    int_objec-ausp2

    int_objec-ausp3

    int_objec-ausp4... and so on,

    and u need to loop at such fields, then use do varying.

    3. More over, i m not sure, wheterh +0 , +1 (offset concept)

    is allowed here or not.

    4.

    It should be ideally like this.

    DO len TIMES VARYING C <b>

    FROM int_objec-ausp1 NEXT int_objec-ausp2</b>

    where c is of type int_objec-ausp1

    regards,

    amit m.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 29, 2007 at 09:36 PM

    Ravi

    I had the same problem but changed the code as follows

    <b>Old</b>

    DO len TIMES VARYING C FROM int_objec-ausp1+0 NEXT

    int_objec-ausp1+1.

    <b>New</b>

    DO len TIMES VARYING C FROM int_objec-ausp1(1) NEXT

    int_objec-ausp1+1(1).

    and it works fine.

    Jagraj Dhillon

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      THANKU BUT MY REQUIREMNT IS LIKE BELOW,

      INT_OBJEC-AUSP1+0 100.00 kg

      INT_OBJEC-AUSP1+1 00.00 kg

      INT_OBJEC-AUSP1+2 0.00 kg

      INT_OBJEC-AUSP1+3 .00 kg

      INT_OBJEC-AUSP1+4 00 kg

      INT_OBJEC-AUSP1+5 0 kg

      INT_OBJEC-AUSP1+6 kg

      INT_OBJEC-AUSP1+7 kg

      INT_OBJEC-AUSP1+8 g

      INT_OBJEC-AUSP1+9

      Please help me,

      Thanks in advance,

      Ravi