Hi Gopa,
imho the second approach via the administrative class that is part of the function class is feasible and is also used internally e. g. in the BRFplus workbench when displaying the rulesets that belong to the function (You can leave out the parameter ets_usage_tree which should speed up the call).
You can use the query too, but here due to a lack of documentation it is a little bit tricky to fill the right query parameters in the right way :-)
The following code should do the trick:
DATA lt_ruleset_id TYPE if_fdt_types=>ts_object_id.
* Get the ruleset query object
DATA(lo_query) = cl_fdt_factory=>if_fdt_factory~get_instance( )->get_query(
iv_object_type = if_fdt_constants=>gc_object_type_ruleset ).
* Fill the selection parameters to get the ruleset belonging to a function
DATA(lt_sel) = VALUE if_fdt_query=>ts_selection(
( queryfield = if_fdt_admin_data_query=>gc_fn_application_id
sign = 'I'
option = 'EQ'
low = '00505692515B1EE4B5D4ED75F18EEE65' )
( queryfield = if_fdt_ruleset_query=>gc_fn_switch_complete"_complete
sign = 'I'
option = 'EQ'
low = 'X' )
( queryfield = if_fdt_ruleset_query=>gc_fn_function_id_complete
sign = 'I'
option = 'EQ'
low = '00505692515B1EE4B5D4F5103A780E6D' )
).
* Fire the query and get the IDs of the rulesets
lo_query->select_data(
EXPORTING
iv_deleted_option = if_fdt_query=>gc_memopt_both
iv_memory_option = if_fdt_query=>gc_delopt_undeleted
iv_named_option = if_fdt_query=>gc_namopt_named
its_selection = lt_sel
IMPORTING
eta_data = lt_ruleset_id ).
I have no experience which way of fetching the ruleset IDs is faster, so you have to try that out.
BR
Christian