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.

9

BRFplus

Here, there is only one result allowed, so if you have multiple values coming back

(the exception rather than the rule, you would think), then you have to define the

result object as a structure or a table rather than a data element. Do this by defining

a structure or a table type using SE11, and then set the type of the result data

object to be that DDIC structure or table. In Figure 9.10, you’ll see the completed

signature—input and output parameters —of your function; i.e., everything

below Context.

Now that you have a means to receive some data and send back a result, it’s time

to move on to the next level down, whic h is a ruleset. You could ask me what a

ruleset is, and I could answer that it’s a set of rules, but probably that would not

make you any better off. The best way of answering is by way of an example. In

this example, one of the monsters has been arrested for not killing enough peasants.

The sentence is destruction. The baron launches a legal appeal based on the

laws of Transylvania—an enormous set of legal rules built up over many centuries.

The judge cannot come to a decision, so th e case is referred to the court of the

European Union, where another judge wi ll consider the matter based on European

laws. That judge cannot come to a decision either, so the case is referred to

the United Nations to be tried under inte rnational law. This time, a decision is

made, and the monster is released on the condition that it does better next time.

In this case, the first (Transylvanian) set of rules cannot come back with a result,

so another attempt is made with a different (European) set of rules, which also produces

no result, and so a third (international) set of rules is invoked, which does

produce a result. In every case, the input data—the facts of the case—was the same.

The BRFplus equivalent of our real-life example is that a BRFplus function can have

many rulesets, and each ruleset can have one or many rules; the idea is to loop

through the rulesets until you get a result. If a certain set of rules is unable to make

a decision, then instead of giving up you can try a totally different strategy, by passing

a new set of rules the same input data to see if they can do a better job.

Just to keep this simple for the moment, there will be one ruleset with one rule.

Both the ruleset and the rule have the simple job of determining what type of

ingredients to use for a monster based on the customer requirements. In order to

create a ruleset, navigate from the Signature tab of the function to the Assigned

Rulesets tab; the screen will now look like Figure 9.11.

370

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

Saved successfully!

Ooh no, something went wrong!