Application Development and Automation 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: 
Read only

select query issue

Former Member
0 Likes
933

Hi all,

I have one requirement , i want to select 4 fields from MARD table using select statment .

the main issue is , for example if i am having 1000 records in DB table ,

my select query should select 5 times , ie 200, 200,200,200,200 and append into my internal table .

can any one help how to write this query.

Tnks in advance.

regards

veera

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
908

hi veera

You can use DESCRIBE TABLE itab..

DESCRIBE TABLE itab. " internal table for ALV GRID.

WRITE: / SY-TFILL. " Number of rows..

Is this what you want..

Thanks,

ravish

<b>dont forget to reward points if helpful</b>

8 REPLIES 8
Read only

Former Member
0 Likes
908

in SELECT statement, there's an option for UPTO n ROWS

DO 5 TIMES.

SELECT * UPTO 200 ROWS FROM..

ENDDO.

Read only

0 Likes
908

Darshil,

This logic will select same 200 records again & again....

I think he needs to select 0 to 200 , 201 to 400...so on.

It is possible only if we can mention UPTO <N> ROWS where <N> should be dyanmaic value

Regards,

sail

Read only

0 Likes
908

Hi ,

In database table how can i find out the value for 'N'.

how can i decide how many lines present in DB table for my where condtion.

Regards,

veera

Read only

Former Member
0 Likes
908

Hi

If yo0u can specify all the Keys in the Where Condition in the Select statement do that. Otherwise if you need to restrict the Size of your internal table use

" PACKAGE-SIZE n". This way u can restrict the size of your internal table and you can select 200 each in every fetch...

Reward All Helpfull answers............

Read only

0 Likes
908

Hi ,

Can u give a sample code for pakage size?

regards

veera

Read only

Former Member
0 Likes
908

sample code for you ..


do 5  times  .
SELECT bukrs belnr gjahr bldat monat budat xblnr awtyp awkey
  UP TO 200 ROWS
  FROM bkpf
  INTO TABLE it_bkpf

enddo. 

Girish

Read only

Former Member
0 Likes
908

Hi ,

I guess you want to select one record and want it to be appended in the internal table 5 times.

for that you can use the following

select field1 field2 field3 field4 from mard into wa_mard

where matnr = (whatever).

do 5 times.

append wa_mard to itab.

enddo.

endselect.

this way u can select that record once from the DB & append it 5 times to you internal table.

Kindly reward points to all helpful answers.

Besr Regards,

Gaurav

Read only

Former Member
0 Likes
909

hi veera

You can use DESCRIBE TABLE itab..

DESCRIBE TABLE itab. " internal table for ALV GRID.

WRITE: / SY-TFILL. " Number of rows..

Is this what you want..

Thanks,

ravish

<b>dont forget to reward points if helpful</b>