This is the second and final part of the blog

Basic BRFPlus example to confirm if an Employee is a Team Lead (Manager) or not.

http://scn.sap.com/community/it-management/alm/solution-manager/blog/2014/01/24/basic-brfplus-example-to-confirm-if-an-employee-is-a-team-lead-manager-or-not

We continue completing the SQL statements to complete the exercise and test the solution.

BRFPLUS2_9.gif

BRFPLUS2_A.gif

BRFPLUS2_B.gif

Same way

BRFPLUS2_C.gif

BRFPLUS2_D.gif

If by any chance a rule is not in the right place, you move it up or down.

BRFPLUS2_E.gif

Now the rules are in the right execution order.

BRFPLUS2_F.gif

You can save.  Also press Activate, which will give you the option of activating all referenced objects

BRFPLUS2_G.gif

Your Function is ready for testing.

BRFPLUS2_H.gif

To test out the Function, right-click on the function and choose.

BRFPLUS_2.gif

Input a BP of somebody who is a Manager and select Show also Results of Intermediate Steps, the Run Simulation.   You can also use the Import Test Data to import a file to test your Function.

http://scn.sap.com/servlet/JiveServlet/showImage/38-100787-370754/BRFPLUS_6.gif

BRFPLUS_6.gif

The result shows that the entered BP is a Manager.      The nice thing about the simulation is that you can see where in the processing a link was broken.

http://scn.sap.com/servlet/JiveServlet/showImage/38-100787-370753/BRFPLUS_5.gifBRFPLUS_5.gifBRFPLUS_5B.gif

As you can see in PPOMA_CRM, the BP ending with 28 is a Manager.  The Functon works fine.

PPOMA_CRM2.gif

Testing the function for BP ending with 44, the result is False.  The BP is not a Manager.

BRFPLUS_7.gif

Back in the function module, always using the Back to Workbench button, by expanding the Show More in the header, you get the Function ID, which is to be used when called in ABAP.   That piece of information will be used in the next section.

BRFPLUS_1.gif

That takes us to the final part of the blog.

2.  How to call a BRFPlus function in an ABAP program.  All the code below is standard, hence you need to define all the variables exactly as mentioned below.   The only elements we provided are the ones in bold characters:

The BRFPlus unique identifier:                001E0BEA00C41EE39E93CE6349D5E0FC.

The BRFPlus Input Parameter name:      BP_INPUT

The BRFPlus Input Parameter variable:   lv_rfcrequestertype crmt_partner_no

The BRFPlus Output variable:                lv_isteamlead type boolean.

You will need to add the code below to your ABAP program.

data:   lo_factory        type ref to   if_fdt_factory,
          lo_function      
type ref to   if_fdt_function,
          lo_context       
type ref to  if_fdt_context,
          lo_result          
type ref to  if_fdt_result,
          lv_result_string
type           string,
          lx_fdt              
type ref to   cx_fdt.

* Init BRFPlus

lo_factory  = cl_fdt_factory=>if_fdt_factory~get_instance( ).
lo_function
= lo_factory->get_function( iv_id = 001E0BEA00C41EE39E93CE6349D5E0FC).
try.
   lo_context
= lo_function->get_process_context( ).
   lo_context
->set_value( iv_name = ‘BP_INPUT’ ia_value = lv_rfcrequester ).
   lo_function
->process( exporting io_context = lo_context
   importing eo_result = lo_result ).
      lo_result
->get_value( importing ea_value = lv_isteamlead ).
   catch cx_fdt into lx_fdt.
   loop at lx_fdt->mt_message assigning <ls_message>.
   write / <ls_message>text.
   endloop.
endtry.
* End of BRFPlus

Some bibliography for you.

1.  BRFPlus – Business Rule management for ABAP Applications.

http://www.sap-press.com/products/BRFplus-%E2%80%94-Business-Rule-Management-for-ABAP-Applications.html

2.  BRFPlus.  There is this 1-2 days training in BRFplus you can get for free.  Excellent material, well organized.   There 3 sessions that tell you how that works.

http://scn.sap.com/docs/DOC-8824?rid=/webcontent/uuid/90754865-f283-2b10-6d9f-b10f3c28c3a0

Enjoy,

Juan-Carlos

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply