‎2011 Nov 18 9:08 AM
Hi ,
I need to work out a general select query which is used in multiple places. The select query uses FOR ALL ENTRIES on different internal tables but the WHERE condition remain the same. Can anyone help me in this I am writing this in a Function pool using the subroutines.
How to get the generic query,
for example I have two internal Tables
ITAB1 and ITAB2
Which are used in two different includes of the fumction pool. As the where condition is generic can I make it as a single select query using the fieldsymbols?
SELECT bname
name_first
name_last
name_text
FROM v_usr_name
INTO TABLE ct_user_name
FOR ALL ENTRIES IN <fs>
WHERE bname = <fs>-created_by OR
bname = <fs>-changed_by.
.
But the select query throws an error.
Regards
‎2011 Nov 18 9:31 AM
‎2011 Nov 18 9:24 AM
refer this link, you will get idea,
http://sapient.wordpress.com/2007/12/11/how-to-use-dynamic-sql-in-abap-report/
‎2011 Nov 18 9:31 AM
‎2011 Nov 18 10:31 AM
Hi,
The query is leading to a dump saying that the fields are not available in the table. But the Table is having the specified fields in the run time.
Please check the code and let me know the feasible solution.
PERFORM fetch_user_name_data USING gt_res_coll
CHANGING lt_user_name.
FORM fetch_user_name_data USING ut_userid TYPE ANY TABLE
CHANGING ct_user_name TYPE ty_t_user_name.
DATA: lt_where_cond(100) OCCURS 0 WITH HEADER LINE.
DATA:lt_coll TYPE TABLE OF ty_result_col.
APPEND 'BNAME = UT_USERID-CREATED_BY' TO lt_where_cond.
APPEND 'BNAME = UT_USERID-CHANGED_BY' TO lt_where_cond.
SELECT bname
name_first
name_last
name_text
FROM v_usr_name
INTO TABLE ct_user_name
FOR ALL ENTRIES IN ut_userid
WHERE (lt_where_cond).
Regards
‎2011 Nov 18 10:35 AM
‎2011 Nov 18 10:42 AM
Hello,
APPEND 'BNAME = UT_USERID-CREATED_BY' TO lt_where_cond.
APPEND 'BNAME = UT_USERID-CHANGED_BY' TO lt_where_cond.This is not correct
Read the SAP documentation on how to use [dynamic WHERE clauses|http://help.sap.com/abapdocu_702/en/abenwhere_logexp_dynamic.htm].
BR,
Suhas