Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

internal table

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

9 REPLIES 9

Former Member
0 Kudos

Hi,

do this way ...

DO lv_tot TIMES.

SELECT * FROM kna1

APPENDING TABLE lt_kna1

UP TO 10 ROWS.

ENDDO.

0 Kudos

thanks for your reply,

but that way im jus getting same records...appending

thanks

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

lv_count1 is dynamic value

lv_count2 is static value

thanks

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.