Skip to Content
author's profile photo
Former Member

select & endselect

What happens if I use control break statement in between select & endselect?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Aug 22, 2007 at 06:31 AM

    Hi,

    It doesnt allow to write at new or at end of between select and endselect.

    It gives error saying that at end or at new should be used between loop...endloop.

    But it allows ON change of between select endselect.

    ON CHANGE OF f.

    Executes the processing block enclosed by the "ON CHANGE OF f" and "ENDON" statements whenever the contents of the field f change (control break processing).

    Normally, you use the statement to manipulate database fields during GET events or SELECT/ENDSELECT processing.

    ON CHANGE OF is unsuitable for recognizing control levels in loops of this type because it always creates a global auxiliary field which is used to check for changes. This global auxiliary field is only changed in the relevant ON CHANGE OF statement. It is not reset when the processing enters loops or subroutines, so unwanted effects can occur if the loop or subroutine is executed again. Also, since it is set to its initial value when created (like any other field), any ON CHANGE OF processing will be executed after the first test, unless the contents of the field concerned happen to be identical to the initial value.

    DATA T100_WA TYPE T100.

    SELECT * FROM T100

    INTO T100_WA

    WHERE SPRSL = SY-LANGU AND

    MSGNR < '010'

    ORDER BY PRIMARY KEY.

    ON CHANGE OF T100_WA-ARBGB.

    ULINE.

    WRITE: / '**', T100_WA-ARBGB, '**'.

    ENDON.

    WRITE: / T100_WA-MSGNR, T100_WA-TEXT.

    ENDSELECT.

    Displays all messages with their numbers in the logon language, provided the number is less than '010'.

    Each time the message class changes, it is output.

    AT END OF f.

    f is a sub-field of an internal table or extract dataset (EXTRACT) which is being processed with LOOP, i.e. the variants 1 and 2 only make sense within a LOOP.

    Both "AT NEW f." and "AT END OF f. " introduce processing blocks which are concluded by " ENDAT.".

    These processing blocks are processed whenever the contents of a field f or a sub-field defined before f change as a result of processing with LOOP. "AT NEW f." begins a new group of (table) lines with the same contents as the field f while "AT END OF f." concludes such a group.

    Within the AT ... ENDAT processing of internal tables, all argument fields following f are filled with "*".

    Examples

    1. AT for sub-fields of an internal table

    DATA: BEGIN OF COMPANIES OCCURS 20,

    NAME(30),

    PRODUCT(20),

    SALES TYPE I,

    END OF COMPANIES.

    ...

    LOOP AT COMPANIES.

    AT NEW NAME.

    NEW-PAGE.

    WRITE / COMPANIES-NAME.

    ENDAT.

    WRITE: / COMPANIES-PRODUCT, COMPANIES-SALES.

    AT END OF NAME.

    SUM.

    WRITE: / COMPANIES-NAME, COMPANIES-SALES.

    ENDAT.

    ENDLOOP.

    The AT statements refer to the field COMPANIES-NAME.

    reward if it helps..

    Regards,

    Omkar.

    Message was edited by:

    Omkaram Yanamala

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 22, 2007 at 06:33 AM

    we can use only on-chnage of

    Message was edited by:

    Ram

    Add comment
    10|10000 characters needed characters exceeded