cancel
Showing results for 
Search instead for 
Did you mean: 

Getting all the rulesets for a function

former_member227510
Participant
0 Kudos

Hi,

I want to get all the rulesets for a function. I would be passing the function ID and get all the rulesets for that function.

" passing the application ID for selection

ls_selection-queryfield = if_fdt_admin_data_query=>gc_fn_application_id.

ls_selection-sign   = 'I'.

ls_selection-option = 'EQ'.

ls_selection-low    = iv_appl_id.

APPEND ls_selection TO lt_selection.


" getting the instance of the query class

lo_query = cl_fdt_query=>get_instance( iv_object_type = if_fdt_constants=>gc_object_type_ruleset ).


"ID

ls_result_objects-queryfield = if_fdt_admin_data_query=>gc_fn_id.

APPEND ls_result_objects TO lt_result_objects.

" Name

ls_result_objects-queryfield = if_fdt_admin_data_query=>gc_fn_name.

APPEND ls_result_objects TO lt_result_objects.


" passing the application id and expression type ID to get the expressions of that type

lo_query->select_data(

   EXPORTING

     its_selection          = lt_selection

     its_result_field       = lt_result_objects

     is_object_category_sel = ls_object_category_sel

   IMPORTING

     eta_data               = lt_ruleset_id_name  ).


Using the above query, I will be able to get all the rulesets in the application.


However, I want all the rulesets for a function.






Other way is,

lo_function ?= so_factory->get_function( iv_function_id ).

   TRY.

       lo_function->get_usage_tree(

         IMPORTING

           ets_usage                      =    lts_usage         " List of usages

           ets_usage_tree                 =    lts_usage_tree    " Usage Tree

           ev_usages_exist                =    lv_usages_exist   " ABAP_TRUE: usages exist (magnitudes faster than ETS_USAGES!)

       ).

catch cx_fdt_input.

endtry.


Using this method, in the lts_usage, I am getting the rulesets.







Is there any way of getting the rulesets by the previous query class? for example: Another query field or something... where I can pass alongwith the application ID, the function ID or only pass the function ID and get all the rulesets....


Regards,

Gopa

Accepted Solutions (1)

Accepted Solutions (1)

christianlechne
Active Contributor
0 Kudos

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

former_member227510
Participant
0 Kudos

Hi Christian,

if_fdt_ruleset_query=>gc_fn_function_id_complete. This is what I was looking for.


I didn't check the if_fdt_ruleset_query interface. My mistake.


Thank you.


1) I tried if_fdt_ruleset_query=>gc_fn_function_id instead of gc_fn_function_id_complete, and it's not giving me the rulesets.

What is the difference?

2) I want to pass the timestamp or the version of the function and get the rulesets at that point in time.


Through if_fdt_query, I passed  if_fdt_admin_data_query=>gc_fn_version also as queryfield and  if_fdt_admin_data_query=>gc_fn_ch_timestamp....

but I am not getting the rulesets at that particular point in time.... getting zero data...


Scenario:

At timestamp 20160523050836 and version 000003, I had three rulesets.

At timestamp 20160523052421 and version 000005. I had five rulesets.

So if I pass either the timestamp or the version, I should be able to get the rulesets.


3) What is  if_fdt_ruleset_query=>gc_fn_switch_complete? Even if I don't pass it, I am getting the rulesets.


4) And, everytime I am activating a function in brf+, a new version is getting generated. Do you know the reason to this behaviour?




christianlechne
Active Contributor
0 Kudos

Hi Gopa,

ad 1) Honestly ... I have no idea and also debugging the code did not enlight me 😞

ad 2) I would have thought this should work as you described. I cross check that and come back to you

ad 3) In my case it is the other way round. As mentioned no documentation, so I don't know the semantics. Nevertheless, it is part of the DB table that contains the basic ruleset information.

ad 4) This is not really related to the original query, so you should open a new question in this forum, to make it accessible for others. As a rough guidance: Which versioning is selected in your application? You find information on that in help.sap.com (Versioning - Business Rule Framework plus (BRFplus) - SAP Library)

BR

Christian

former_member227510
Participant
0 Kudos

Hi Christian,

You mean the versioning mode? It's versioning on...

Language settings :

Text and document : Language and version dependent

Currently I am debugging and checking if there is some method to get the rulesets for a function for a particular timestamp and version.

Meanwhile, if you come across any, let me know. Appreciate your involvement.

Thanks and Regards,

Gopa

christianlechne
Active Contributor
0 Kudos

Hi Gopa,

ad 2) Adding the verison or timestamp option to the query does work for me. In both cases the query works as expected.

ad 4) Concerning the versioning: It is all stated in the documentation - your versioning setting creates a version whenever you activate an object -> Not recommended for productive usage

BR

Christian

former_member227510
Participant
0 Kudos

Hi Christian,

It's not working for me... I will try again at work tomorrow... Thanks

Regards,

Gopa

former_member227510
Participant
0 Kudos

Hi christian,

Can you send me the code that you are using to get the rulesets based on version?

I mean the query fields....

Regards,

Gopa

former_member227510
Participant
0 Kudos

Hi Christian,

I ran the code again. It's working fine now.
I am passing the timestamp to the select data method.

And I am getting all the rulesets at that point in time.

Below is the code:

ls_selection-queryfield = if_fdt_ruleset_query=>gc_fn_function_id_complete.

ls_selection-sign   = 'I'.

ls_selection-option = 'EQ'.

ls_selection-low    = '525400274A1E1EE688948A4E1BA3A22D'.

APPEND ls_selection TO lt_selection.

ls_selection-queryfield = if_fdt_admin_data_query=>gc_fn_marked_for_delete.

ls_selection-sign   = 'I'.

ls_selection-option = 'EQ'.

ls_selection-low    = abap_false.

APPEND ls_selection TO lt_selection.


lo_query_exp = cl_fdt_query=>get_instance( iv_object_type = if_fdt_constants=>gc_object_type_ruleset ).


"ID

ls_result_objects-queryfield = if_fdt_admin_data_query=>gc_fn_id.

APPEND ls_result_objects TO lt_result_objects.

" Name

ls_result_objects-queryfield = if_fdt_admin_data_query=>gc_fn_name.

APPEND ls_result_objects TO lt_result_objects.


" passing the application id and expression type ID to get the expressions of that type

lo_query_exp->select_data(

   EXPORTING

     its_selection          = lt_selection

     its_result_field       = lt_result_objects

     is_object_category_sel = ls_object_category_sel

     iv_timestamp           = '20160531044535'

   IMPORTING

     eta_data               = lt_ruleset_id_name  ).


Thanks and Regards,

Gopa

Answers (1)

Answers (1)

nabhish_saxena
Explorer
0 Kudos

Hi Gopa,

You can also have a look at class CL_FDT_FUNCTION method CHECK_ASSIGNED_RULESETS to have a look at how the list of rulesets can be found out to which your current function is linked. Initial lines of code using IF_FDT_ADMIN_DATA->GET_WHERE_USED will be helpful.

-Nabhish

former_member227510
Participant
0 Kudos

Hi nabhish,

I tried CHECK_ASSIGNED_RULESETS earlier. However, it was returning no data at all.

Thanks and Regards,

Gopa

nabhish_saxena
Explorer
0 Kudos

Hi Gopa,

This method is not to be used directly. It has the code to fetch all the assigned rulesets for a function, I was suggesting you to have a look at that piece of standard codeline and adopt in your custom code accordingly.....

-Nabhish