14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creating Rules in BRFplus: Basic Example 9.2

iv_name = 'MONSTER_USAGE' ia_value = ld_usage ),

iv_name = 'EVILNESS' ia_value = ld_evilness ),

iv_name = 'SCARINESS' ia_value = ld_scariness ),

iv_name = 'RAGES_PER_DAY' ia_value = ld_rages_pers_day ).

"Off we go!

lo_function->process( EXPORTING io_context = lo_context

IMPORTING eo_result = lo_result ).

"Retrieve Result

lo_result->get_value( IMPORTING ea_value = ld_ingredients ).

CATCH cx_fdt INTO lx_fdt.

LOOP AT lx_fdt->mt_message ASSIGNING <ls_message>.

MESSAGE <ls_message>-text TYPE 'I'.

ENDLOOP.

ENDTRY.

Listing 9.2 Calling a BRFplus Function

The only thing you will find puzzling in Listing 9.2 is the really long hexadecimal

string at the start. What’s that all abou t? You’ve been used to calling function

modules and methods with names like Z_GET_MONSTERS or ZCL_MONSTERS->GET_

MONSTERS( )—that is, names that are friendly to someone reading the program.

However, when you use BRFplus, you need to address the function via a unique,

32-digit ID, which is generated for you when the function is created; you can see

this number in the ID field of Figure 9.28.

Figure 9.28 Finding the UID for a BRFplus Function

This is rather like when you phone a bank to find yo ur balance, and a machine

guides you through 32 steps, and you have to choose an option each time before

hearing, “Sorry this service is offline at the moment.” I did a quick survey to find

out who thought that putting a meaningless 32-digit code in the middle of a program

was a good idea, and I only found one person who said that it was—and

then he told me to leave him alone, because he claimed to be Napoleon and was

busy plotting how to defeat the English at the Battle of Trafalgar.

387

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!