12-27-2007 11:08 AM
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
12-27-2007 11:13 AM
Hi,
http://www.sap-img.com/abap/how-can-we-give-dynamic-table-name-in-select-statement.htm
http://help.sap.com/saphelp_nw04/helpdata/en/67/93b80914a911d2953c0000e8353423/content.htm
Dynamic fields in select statement: -
http://www.saptechies.com/dynamic-fields-in-select-statement/
Useful link on dynamic open SQL statements: -
http://www.susanto.id.au/papers/DynOpenSQL.asp
Reward points for helpful answers.
Regards,
Hari
12-27-2007 11:13 AM
Hi,
http://www.sap-img.com/abap/how-can-we-give-dynamic-table-name-in-select-statement.htm
http://help.sap.com/saphelp_nw04/helpdata/en/67/93b80914a911d2953c0000e8353423/content.htm
Dynamic fields in select statement: -
http://www.saptechies.com/dynamic-fields-in-select-statement/
Useful link on dynamic open SQL statements: -
http://www.susanto.id.au/papers/DynOpenSQL.asp
Reward points for helpful answers.
Regards,
Hari
12-27-2007 11:20 AM
12-27-2007 11:24 AM
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, youll 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.
12-27-2007 4:28 PM
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