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

internal table

hi guyz,

i have an internal table with 20records. and im looping on the table

for eg:

TABLES : kna1.

DATA : lt_kna1 TYPE TABLE OF kna1 WITH HEADER LINE.

DATA : lv_count1(2) TYPE c VALUE '21',

lv_count2(2) TYPE c VALUE '10',

lv_div TYPE c,

lv_rem TYPE c,

lv_tot TYPE c.

lv_div = lv_count1 / lv_count2.

lv_rem = lv_count1 MOD lv_count2.

lv_tot = lv_div + lv_rem.

DO lv_tot TIMES.

SELECT * FROM kna1

INTO TABLE lt_kna1

UP TO 10 ROWS.

ENDDO.

so wot i want is if the lv_tot = 3

in the first loop i should get first 10 records

in the second loop i should get next 10 records

and so on...

plz advise..

regds

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 11:31 AM

    DATA: GT_KNA1 TYPE STANDARD TABLE OF KNA1,

    GT_TEMP TYPE STANDARD TABLE OF KNA1,

    START TYPE I,

    END TYPE I.

    START = 1.

    END = 10.

    SELECT * FROM KNA1 INTO TABLE GT_KNA1.

    DO 3 TIMES.

    APPEND LINES OF GT_KNA1 FROM START TO END TO GT_TEMP.

    *do the processing of gt_temp

    *clear gt_temp

    START = START + 10.

    END = END + 10.

    ENDDO.

    Add this logic in your code.

    Hope this helps,

    Reward points if useful

    Janani

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 11:17 AM

    Hi,

    do this way ...

    DO lv_tot TIMES.

    SELECT * FROM kna1

    APPENDING TABLE lt_kna1

    UP TO 10 ROWS.

    ENDDO.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 11:18 AM

    Hi ,

    You can use the addition From and to in the loop statement.

    in a varaible get the total number of recods in the internal table and create a while loop , which is executed till all the records in the table are porcessed.

    Inside the while loop use the loop at statemnet with the addition.

    Regards

    Arun

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 11:23 AM

    Hiiii

    could u lpzz tell me whats that lv_count1 and lv_count2 ...are they static values or wether that values ned to be entered by the end user ......

    regards

    chandu reddy

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 11:26 AM

    Hi,

    You have to change the Up to n rows dyanamically.

    For the 1 st loop select upt o10 rows , for the second loop select up to 20 rows . for the third loop select up to 30 rows .

    finally delete duplicate records.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 11:29 AM

    Hi,

    you can do like this given in a piece of code.

    -


    REPORT demo_select_into_package .

    DATA: wa TYPE spfli,

    itab TYPE SORTED TABLE OF spfli

    WITH UNIQUE KEY carrid connid.

    SELECT carrid connid

    FROM spfli

    INTO CORRESPONDING FIELDS OF TABLE itab

    PACKAGE SIZE 3.

    LOOP AT itab INTO wa.

    WRITE: / wa-carrid, wa-connid.

    ENDLOOP.

    SKIP 1.

    ENDSELECT.

    -


    Or you can write the select query as

    SELECT * FROM kna1

    appending TABLE lt_kna1

    UP TO 10 ROWS.

    I hope this will help you out.

    Help children of U.N World Food Program by rewarding them and encourage others to answer your queries

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 11:48 AM

    report .

    TABLES : kna1.

    DATA : lt_kna1 TYPE TABLE OF kna1 WITH HEADER LINE,

    lt_kna2 TYPE TABLE OF kna1 WITH HEADER LINE.

    DATA : lv_count1(2) TYPE c VALUE '21',

    lv_count2(2) TYPE c VALUE '10',

    lv_div TYPE c,

    lv_rem TYPE c,

    lv_tot TYPE c,

    n1 type i,

    n2 type i .

    lv_div = lv_count1 / lv_count2.

    lv_rem = lv_count1 MOD lv_count2.

    lv_tot = lv_div + lv_rem.

    SELECT * FROM kna1

    into TABLE lt_kna1 .

    n1 = 1.

    n2 = 10.

    DO lv_tot TIMES.

    append lines of lt_kna1 from n1 to n2 to lt_kna2.

    loop at lt_kna2.

    write:/ lt_kna2-kunnr .

    endloop.

    refresh lt_kna2.

    n1 = n1 + 10.

    n2 = n2 + 10.

    ENDDO.

    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.