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: 

dynamic select

Former Member
0 Kudos
98

Hello,

how to write a dynamic select stateement.

in the where clause of the select statement , the number of fields will vary dynamically.

points will be rwarded.

Thanks.

ramya

1 ACCEPTED SOLUTION
4 REPLIES 4

rodrigo_paisante3
Active Contributor
0 Kudos
66

Hi, see these links:

Hope they help you.

Former Member
0 Kudos
66

First, declare an internal table with a single text field

example:

DATA: BEGIN OF GT_CONDITION OCCURS 0,

LINE,

END OF GT_CONDITION.

Then insert or concatenate in the table the conditions as a text

For example:

gt_condition-line = ‘mandt eq ‘000’‘.

append gt_condition.

Note: In order to insert the quotations in the field, you’ll need to do something like this:

concatenate ‘mandt eq’ ‘’‘’ ‘000’ ‘’‘’ into gt_condition-line.

And the selection can be done as follows:

select * from table where (gt_condition).

endselect.

Former Member
0 Kudos
66

Hi,

Try the following,

DATA: w_tabname TYPE w_tabname,

w_dref TYPE REF TO data.

in input option give the table name and assign to w_tabname.

start-of-selection.

START-OF-SELECTION.

CREATE DATA w_dref TYPE TABLE OF (w_tabname).

ASSIGN w_dref->* TO <t_itab>.

SELECT * FROM (w_tabname)

INTO TABLE <t_itab>.

Regards,

Billa