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 from generic table

Former Member
0 Likes
1,026

Hello,

I have an internal table containing selection parameters determined at run-time.

eg. it_ipak_selections contains the entries.....

FIELDNAME SIGN OPT LOW

FISCVARNT I EQ K4

FISCPER I EQ 2006011

RBUKRS I EQ CH15

Using these entries I need to retrieve entries from database table rsseldone.

This (BW) table contains requests based on selection parameters.

Unfortunately the table structure is generic, field Fieldname can contain any selection parameter e.g. 'BUKRS'. and for one request there can be 'N' entries, depending on the number of selection parameters.

Here is the table structure with an example.

REQUEST FIELDNAME SIGN OPT LOW HIGH

REQU_123 BUKRS I EQ DE3

REQU_123 FISCPER I BT 2005001 2005003

REQU_987 BUKRS I EQ CH15

.......

For this reason a "Select.... for all entries" statement retrieves too much data.

SELECT rnr fieldname iobjnm sign opt low high

FROM rsseldone INTO CORRESPONDING FIELDS OF TABLE lt_rsseldone

FOR ALL ENTRIES IN it_ipak_selections

WHERE fieldname = it_ipak_selections-fieldname

AND iobjnm = it_ipak_selections-iobjnm

AND sign = it_ipak_selections-sign

AND opt = it_ipak_selections-opt

AND low = it_ipak_selections-low

AND high = it_ipak_selections-high.

Does anyone know an efficient way to select the data?

Thank you,

Rod

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
685

Move the selection to individual ranges and do a 'in' in the where clause and remove 'for all entries'.

- Suman

3 REPLIES 3
Read only

Former Member
0 Likes
686

Move the selection to individual ranges and do a 'in' in the where clause and remove 'for all entries'.

- Suman

Read only

0 Likes
685

Hello Suman,

I did a quick test with what you suggested as below.

SELECT rnr fieldname iobjnm sign opt low high

FROM rsseldone INTO CORRESPONDING FIELDS OF table lt_rsseldone

WHERE fieldname in r_fieldname

AND low in r_low.

Maybe I misunderstood your suggestion but as it is above, I´m afraid that won´t work since an entry with selection parameters BUKRS = CH15 will be retreived from the table but which doesn´t necessary have the date as 2006011. I need only the entries that satisfy all the selection parameters.

Thanks for your help,

Rod

Read only

Former Member
0 Likes
685

Hi,

Your code will work perfectly. Please do the following modification?

<b>If it_ipak_selections[] is not initial.</b>

SELECT rnr fieldname iobjnm sign opt low high

FROM rsseldone INTO TABLE lt_rsseldone

FOR ALL ENTRIES IN it_ipak_selections

WHERE fieldname = it_ipak_selections-fieldname

AND iobjnm = it_ipak_selections-iobjnm

AND sign = it_ipak_selections-sign

AND opt = it_ipak_selections-opt

AND low = it_ipak_selections-low

AND high = it_ipak_selections-high.

<b>endif.</b>

If still not working please let me know. I will help you.

CORRESPONDING FIELDS clause won't work properly.

Regards

Bhupal Reddy

Message was edited by:

Bhupal Reddy Vendidandi