Skip to Content

syntax..

dear friend,

tell me the syntax for move next line of the IT table..

loop at it_record.

if it_record-key = '39'.

"here i have to use the syntax for next line

endif.

endloop.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Dec 04, 2007 at 02:42 PM
    loop at it_record.
    if it_record-key = '39'.
    "here i have to use the syntax for next line  
    continue. " Else use read statement
    READ IT_RECORD into wa_record index sy-tabix. 
    endif.
    endloop. 
    
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 02:42 PM

    hi,

    you can reach the next line through sy-tabix (whihc contains the current line) + 1 :

    DATA : next TYPE sy-tabix.

    LOOP AT it_record.

    next = sy-tabix + 1.

    IF it_record-key EQ '39'.

    • read next line

    READ TABLE it_record INTO ... INDEX next

    • change next line

    MODIFY TABLE it_record FROM ... INDEX next.

    ENDIF.

    ENDLOOP.

    hope this helps

    ec

    Add a comment
    10|10000 characters needed characters exceeded

    • Naimesh Patel Thanuskodi Thangasamy

      It must work.

      Check this small example:

      REPORT  ZTEST_NP.
      
      data: begin of itab occurs 0,
            line(20),
            end   of itab.
      
      data: wa_itab like itab,
            l_index  type i.
      
      itab-line = 'Line 1'. append itab. clear itab.
      itab-line = 'Line 2'. append itab. clear itab.
      itab-line = 'Line 3'. append itab. clear itab.
      itab-line = 'Line 4'. append itab. clear itab.
      itab-line = 'Line 5'. append itab. clear itab.
      
      
      loop at itab.
        l_index = sy-tabix + 1.
        read table itab into wa_itab index l_index.
        if sy-subrc = 0.
          write: / itab-line, wa_itab-line.
        endif.
        clear: itab, wa_itab.
      endloop.

      Regards,

      Naimesh Patel

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 02:45 PM

    Hi ,

    If you want to move to next line in the loop processing you have to assign sy-tabix value to some local variable and you just increment.

    LOOP AT it_record.

    IF it_record-key = '39'.

    "here i have to use the syntax for next line

    v_indx = sy-tabix + 1.

    CLEAR : it_record.

    READ TABLE it_record INDEX v_indx.

    IF sy-subrc = 0.

    "Your code

    ENDIF.

    ENDIF.

    ENDLOOP.

    Or you can use below code to skip 39th record.

    LOOP AT it_record.

    IF it_record-key = '39'.

    "here i have to use the syntax for next line

    Continue.

    ENDIF.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 02:45 PM

    -> set a flag:

    if it_record-key = '39'.
     xflag = X.
    endif.

    so in next loop you can ask:

    if xflag = x.

    ...

    do not forget to clear xflag!

    A.

    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.