Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Binu_Jacob
Explorer
SAP has two powerful frameworks to support a functional consultant. These are:

  • BRFplus

  • SAP Adhoc query.


In this blog I would like to share my experience in calling a BRFplus function within an SAP Adhoc query. This I hope with help in extending the reach that BRFplus and SAP Adhoc query can provide for your requirements.

 

Scenario:

I am using an Adhoc query based on a simple table based infoset to display a set of fields. The query reads data from a custom table used in a custom application developed with ABAP. Now in the underlying infoset used by the adhoc query, I have created an 'additional field' called 'staff' which is populated by a call to a BRFplus function.

Of course, there are other means to populate this additional field but the use of BRFplus is just to illustrate the power in using the combination of SAP Adhoc query with BRFplus.

 

A: Create a simple BRFplus application:

While this blog is focused mainly to show the use of both the above frameworks in tandem, I will not be going through in detail to create the brfplus artifacts. So only the high-level steps are shown.

This involves:

1. Creating an application in BRFplus (the transaction code is brfplus)

         


 

2. Create the Function:

This function has the input of 'User' (based on field UserID) and outputs 'PERNR' (based on fied PERNR). The ruleset used (ZJB01RS) consists of a 'Rule' that reads table 'PA0105' (standard table in HCM) passing User (UserID) and Subtype and fetching PERNR from table PA0105.


The RULESET called ZJB01RS.


The Database lookup "FETCHPERNR" used in rule above.


 

Once the BRFplus artifacts are saved and activated the 'simulation' to check the application is below.


 


 

Now that the BRFplus application works, the 'Class' to be generated as below. Use the "Generate Function" to do this under the "Code Generation' tab


 

Now to display the "code template' to be used in our infoset in the SAP Adhoc query. Click on the "Create Code Template' button (see the above image).

The code template is as shown below. Copy this code to be later used in our 'INFOSET'.


 

B: The SAP ADHOC Query:

The adhoc query creation has 2 steps:

1.Create the Infoset:

The infoset created using transaction 'SQ02' is based on a simple table as shown below.


I have added the required fields from the table and also create an 'Additional field' called 'staff'.


 

I will populate this field called 'Staff' using the brfplus function created earlier. Right click on the field "staff" and go to "field code".

Copy and paste the 'Code Template"" that we created in the brfplus to the below and make minor modifications in the code.


The modifications needed to read the data from the brfplus is below:

  1. There is a field in the infoset called "Name of the person who changed the object". This field is of the type "UserID'. Use the technical name of the field and assign to the input parameter of the code.

  2. Similarly assign the output parameter as below. Field 'Staff' is assigned to the importing field 'ea_result".


  TRY.
cl_fdt_function_process=>process( EXPORTING iv_function_id = lv_function_id
iv_timestamp = lv_timestamp
IMPORTING ea_result = staff
CHANGING ct_name_value = lt_name_value ).
CATCH cx_fdt into lx_fdt.

 

Save and Generate the infoset and assign to the appropriate 'User Group".

 

2. Create the query based on the above infoset.

Create the Query based on the above infoset


The fields used


 

Now execute the query. You will see the field "Staff" getting populated from the brfplus as below.


 

This blog post only provides a high-level overview of the creation of the BRFplus application and SAP Query since the idea was to only provide how BRFplus can be used in SAP Query and expand the reach of these two frameworks. Should you need details on the creation of the above artifacts, I am happy to provide.

If you have any questions, you can comment below. I would love to hear from you on how you were able to use this option to provide more value to your business.

 
2 Comments
Labels in this area