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 a particular record

Former Member
0 Likes
1,184

Hi,

How to select a particular record, say record number 45 from a database table?

Thanks,

Sachin.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,151

Hi Sachin Bhatnagar ,

Try this logic, it will work,,,

select * from dbtable into itab ,,,

Loop at itab.

AT ENDOF Storage Bin.

Storage Bin. = Storage Bin + 1.

Endat.

End loop.

Hope it is helps.

Regards,

T.Durai murugan.

Hi,

How to select a particular record, say record number 45 from a database table?

Thanks,

Sachin.

9 REPLIES 9
Read only

Former Member
0 Likes
1,151

Hey!

I didn't get your question. what is your requirement?

Read only

former_member125931
Active Participant
0 Likes
1,151

Suppose you r selecting a particular record like material no : 100 from MARA table

write query like below

select matnr from mara into tablr itab

where matnr = '100'.

if you want total record of this materia no then write like below

select * from mara into table itab

where matnr = '100'.

Hope it will helpful.

Read only

Former Member
0 Likes
1,151

If you know the index, then it's easy...

If not, I would like to ask why you want to retrieve a specific record number. If this is a recurring need, you should consider defining such a field (counter, record number) as part of the key, or as a secondary index.

If not, I can only say I don't really see the need...

Read only

0 Likes
1,151

Hi Trond,

I actually want to insert some records after the last record in the table, and for the reocrds to be inserted, I need a value from the last record.

All the records have a field Storage Bin. Now, suppose its value is 125.

I have to insert the reocrds in increasing order, like next bin should be 126, then 127 and so on. All these values are not provided in any file, rather than the program is generating them depending on whatever the number of last bin in database was.

Thanks,

Sachin.

Read only

Former Member
0 Likes
1,151

Hi Sachin,

Try the following:

Select *

from <dbtable>

into <itab>

where rec_no = 45.

dbtable = database table

itab = internal table

Hope this helps you.

Regards,

Chandra Sekhar

Read only

Former Member
0 Likes
1,151

hi,

Did you mean fetching a record on the particular line in the table.

try this

w_index = sy-tabix.

select * from <table> into <structure>

where index EQ w_index.

Hope this will Help.

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
1,152

Hi Sachin Bhatnagar ,

Try this logic, it will work,,,

select * from dbtable into itab ,,,

Loop at itab.

AT ENDOF Storage Bin.

Storage Bin. = Storage Bin + 1.

Endat.

End loop.

Hope it is helps.

Regards,

T.Durai murugan.

Read only

0 Likes
1,151

Hi Murugan,

Thanks.. It worked...

Read only

former_member125931
Active Participant
0 Likes
1,151

Have u checked my logic,give me ur requirement i will provide you the suitable code or logic

but I given you the answer is appropriated try it once.