Skip to Content
author's profile photo Former Member
Former Member

Reset index of internal table.


I have a problem in resetting the index of internal table.

my table has five records.

once i reach third record i am checking for a condition , if that condition is successful i am executing a code.

once i am done with the execution i want to loop the internal table again from third record.

even if the change the sy-tabix to 3 , my internal table loop is reading fourth record .

can you let me know how to resolve this .



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Oct 17, 2006 at 08:35 PM

    Roby, your requirement is not 100% clear, but do you only want to read that one line after your condition code, try reading directly with READ statement before continuing on in the LOOP.

    Read table itab into wa index sy-tabix.


    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      You might get into trouble with an infinite loop here (it'll always be the third record). You could:

      loop at itab.
        if sy-tabix = 3.
      *   process.
      loop at itab from 3.
      * do the other processing.


  • Posted on Oct 17, 2006 at 08:43 PM

    Hi Roby,

    if you set SY-TABIX inside the loop, it will not work in the next loop iteration.

    If you want to read from the third record again, you can write logi like below...





    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 09:34 PM

    Hi Roby,

    Another solution would look like this:

    * Local
        BEGIN OF local_record_type,
          field1 TYPE syindex,
          field2 TYPE syindex,
        END OF local_record_type.
        number_of_records TYPE i,
        local_workarea    TYPE local_record_type,
        local_table       TYPE STANDARD TABLE OF local_record_type.
    * Test fill (demo purposes)
      DO 10 TIMES.
        local_workarea-field1 = sy-index.
        local_workarea-field2 = ( 10 - sy-index ).
        APPEND local_workarea TO local_table.
    * Your proces starts here
      DESCRIBE TABLE local_table LINES number_of_records.
    * Controlled process
      DO number_of_records TIMES.
          sy-index GE 2.
        IF sy-index EQ 3.   
          READ TABLE local_table INDEX sy-index INTO local_workarea.
    *     Your action
    *     ...
    *   After sy-index reaches 3 and the proces has taken place
    *   sy-index becomes 4 and you can READ the next record as above
    *   and do your stuff with it.
    *   ...



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.