Skip to Content
avatar image
Former Member

Field Symbols

What is ment by following statements?

ASSIGN A INCREMENT B TO <FS>.

ASSIGN A INCREMENT <FS1> TO <FS2>.

ASSIGN <FS1> INCREMENT <FS2> TO <FS3>.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Oct 13, 2008 at 05:28 AM

    Hi,

    Increments the field symbol <fs>, starting from f, by n times the length of f. You cannot use offset/length addressing in f. If the system cannot assign f to the field symbol - that is, if it addresses an invalid memory area - the field symbol remains unchanged and sy-subrc is set to 4.

    SY-SUBRC = 0:

    The field was assigned successfully.

    SY-SUBRC = 4:

    The field was not assigned successfully. the field symbol

    remains unchanged

    Example

    DATA: cf(26) TYPE c VALUE 'abcdefghijklmnopqrstuvwxyz'.

    FIELD-SYMBOLS: <fs> TYPE c.

    ASSIGN cf(2) TO <fs>.

    DO 5 TIMES.

    WRITE <fs>.

    ASSIGN <fs> INCREMENT 3 TO <fs>.

    ENDDO.

    In this example, the field symbol points to the first two characters of the field cf. Then in each loop pass, the field symbol is incremented 3 times 2 characters. The system then displays the result: ab gh mn st yz.

    Example

    TYPES: BEGIN OF comp,

    f1 TYPE string,

    f2 TYPE i,

    END OF comp.

    DATA: BEGIN OF stru,

    k1 TYPE comp,

    k2 TYPE comp,

    k3 TYPE comp,

    k4 TYPE comp,

    END OF stru.

    FIELD-SYMBOLS: TYPE comp.

    ASSIGN stru-k1 TO RANGE stru.

    DO 4 TIMES.

    ...

    ASSIGN INCREMENT 1 TO .

    ENDDO.

    This example shows you how to edit a sequence of identically-typed sub-structures in a loop.

    Source SAP Help,

    Regards,

    Amit

    Add comment
    10|10000 characters needed characters exceeded