06-08-2011 7:59 PM
Hi All,
I have a requirement where i have a select option in which the input is table name , i need to use this input in my select statement and fetch entries in the table where bname is eq to ' ' or uname eq ' '.
the challenge that i am facing is not all the tables have both the fields (uname and Bname).
Request your help on how to code the above requirements.
Thanks,
Bhanu.
06-08-2011 8:15 PM
06-08-2011 10:37 PM
not sure which version you have, if RTTS is available, you can use class CL_ABAP_TABLEDESCR to get all the fields of table then check if the field you need is there or not,
06-09-2011 7:51 AM
06-09-2011 9:58 AM
Hello
better you use field-symbol.
first assign your table name to <FS> the use it in your select statement.
Like below.
<<linkfarm removed by moderator>>
Regards,
Sujeet Mishra
Edited by: kishan P on Jun 9, 2011 2:56 PM
06-09-2011 10:36 AM
Hi Bhanu,
Please use this sample code i made for your reference to solve your problem.
TABLES: dd02t.
SELECT-OPTIONS s_tabnme FOR dd02t-tabname NO INTERVALS OBLIGATORY.
SELECT field1 field3 field3
INTO TABLE gt_master_data
FROM s_tabnme-low
WHERE tablefield = condition.
hope this could help. Cheers.
Michaeldahm
06-10-2011 10:48 AM
Bhanu,
I don't know what exactly is your requirement but I don't see any reason why a business user enters a table name as input in the selection screen.
MANDT NAME TYPE NUMB SIGN OPTI LOW HIGH
223 ZPROGNAME P 0001 I EQ XXX ZTABLENAME
You can maintain an entry like the above in TVARVC table and get the table name using a select query on TVARVC and then use the table as below
SELECT SINGLE * FROM (l_tabname)
into g_wa_tab2
WHERE quosrc EQ g_wa_tab1-quosrc AND
quotyp EQ g_wa_tab1-quotyp AND
quotno EQ g_wa_tab1-quotno AND
quotdate EQ g_wa_tab1-quotdate.
Funda is using TAVRVC to maintain the table names and determine the table based on a condition and the using the table in the select query.
Thanks,
K.Kiran.
06-11-2011 8:08 AM
Hi Bhanu,
Sorry for not providing you code but you can try the logic given below:
1. Pick all table fields of table given in select options from table DD03L.
2. Now check what fields you need to pick or which fields exist in selection condition (where) from the list you got from point 1.
3. Accordingly either write you query or create a dynamic where condition in an internal table using these fields.
4. Use field symbol to create your structure at run time.
4. Now write query something like this:
SELECT SINGLE * FROM s_tab-low into <fs> where condition[] "here condition is your internal table with dynamic conditions.
Hope this solves your query.
Ravi
Edited by: Ravi Ahuja on Jun 11, 2011 12:38 PM