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

fixed number of rows

hi,

all.

i wnt to dispaly only fixed no of row in output but there mayee to more record in internal table .how can i do that

suppose i want to dispaly only 10 record in output but there maye be more that 10 record in inetrnal table,we will

not fixe in selection query,how we will do that.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Posted on Sep 10, 2009 at 09:44 AM

    Hi,

    Use a counter and move the fixed number of records to another internal table and display it.

    loop at itab.
    count = count + 1.
    move-corresponding itab to itab1.
    append itab1.
    if count > 10.
    exit.
    endif.
    endloop.
    

    Now use itab1 to display the output.

    Regards,

    Vikranth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2009 at 09:52 AM

    Hi,

    Use some counter variable and use in loop.

    data : m_count type i.

    loop at <internal table>

    m_count = m_count + 1.

    if m_count > 10.

    exit.

    endif.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2009 at 10:01 AM

    Hi ,

    Try This.

    data : m_count type i.

    loop at itab into wa.

    m_count = m_count + 1.

    write : / wa-f1, wa-f2.

    if m_count > 10.

    exit.

    endif.

    endloop.

    Hope this will help you.

    Regards,

    Vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 10, 2009 at 10:07 AM

    This displays only 10 records:

    data: begin of itab occurs 0,
            matnr like mara-matnr,
           end of itab.
    
    select matnr into table itab up to 20 rows from mara.
    
    loop at itab from 1 to 10.
      write:/ itab-matnr.
    endloop.

    Also you can display from the specified row position.

    Edited by: Mahesh Reddy on Sep 10, 2009 12:08 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 10, 2009 at 10:38 AM

    loop at itab FROM 1 to 10.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2009 at 10:50 AM

    HI,

    Use 2 Itab (Internal tables)

    like this:-

    loop at itab into wa.

    if sy-tabix >= 10.

    append wa to itab2.

    endif.

    endloop.

    Now Use itab2 in ur ALV.

    regards,

    Manish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2009 at 11:07 AM

    BEST WAY IS TO LOOP FOR THE REQUIRED NO OF RECORDS.

    EX: LOOP ITAB FROM 1 TO 50.

    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.