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: 

select limited records

Former Member
0 Kudos

Hi,

i do select from big DB table in fm and i wont to now if i can select limited records,

meaning not more then 1000 records if it happen raise massage like to much records .

Regards

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos

Hi,

You can also check FM RFC_READ_TABLE on how to read DB table with row skips and row count options.

Regards,

Ferry Lianto

6 REPLIES 6

former_member194669
Active Contributor
0 Kudos

Hi,

Instead of raising a exception in the function module may be you can do is

1. Create a import parameter in the function module as "No of Hits" ( if want make it as optional /mandatory)

2. In the select


    select *
       into corresponding fields of table i_mara
       up to p_maxsel rows   
       from mara.
" Here p_maxsel is the import parameter in the function module.
" that contains the number of records to be selected

Former Member
0 Kudos

Hi ,

We can limit our selection criteria.

If you are using a function module , then create a parameter for holding the value of the number of records to be selected.

In the Fm use select query as follows:

"Select fields from source_name into destination_table up to X rows." where X is the mo of records parameter sent from the FM.

once the query gets executed then you can raise an error message or warning message or abend message.

samplecode:

call Function 'GETDATA'

exporting

mx_records = 1000

tables = itab.

select field1 field2 ..... fieldn from source_table into itab up to mx_records rows.

if mxrows > 1000.

message e000(0) with 'Too Many Records'.

endif.

thats all the requirement.

Reward points if helpful.

thanks and regards.

ferry_lianto
Active Contributor
0 Kudos

Hi,

You can also check FM RFC_READ_TABLE on how to read DB table with row skips and row count options.

Regards,

Ferry Lianto

Former Member
0 Kudos

U can select limited records .. using up to ..n rows

select * from <table> into table it_tab up to n rows ..

Former Member
0 Kudos

hi check this program..

tables: mara.

data: begin of itab occurs 0,

matnr like mara-matnr,

meins like mara-meins,

pstat like mara-pstat,

end of itab.

select-options:s_matnr for mara-matnr.

parameters:p_no type i.

select matnr

meins

pstat

from mara

into table itab

up to p_no rows

where matnr in s_matnr.

loop at itab.

write:/ itab-matnr,

itab-meins,

itab-pstat.

endloop.

regards,

venkat.

Former Member
0 Kudos

hi,

u can use select ..... upto 1000 rows.

It fetches only 1000 records and comes out of that statment...

No mgs display in required...

if u use any other ways it hits the database several times...

u program performence will get reduce....

Regards,

priya