14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9

BRFplus

To find the appropriate percentage split among ingredients using just the spreadsheet,

the business logic would be as follows:

왘 Remove any lines that do not match the region, brain size, or color specification.

왘 If a particular model has been specifie d, then go through the lines for that

model looking for a match. If no result is found, then go through all lines with

no model specified, looking for a match.

왘 If a minimum oxtail soup percentage has been defined (any value), then a line

is only a match if it has an X in the MOS SPECD column.

왘 If a growth percentage has been specifie d (any value), then a line is only a

match if it has an X in the Growth SPECD column.

왘 If an early age strength has been specified, then a line is only a match if it has

an X in the EAS SPECD column.

왘 If early age strength has been specified and there are two lines in the spreadsheet

with an X in the EAS SPECD column, then the one th at is chosen is the

one in which the Days column is less than or equal to the early age chosen by

the user. If the user has specified 15 days and the spreadsheet line has 10 days,

then choose the line on the spreadsheet in which no days have been specified.

Remember, this is a real-life requirement! The data in question was not so frivolous,

but the logic was exactly as complicated as this example.

Traditional Rules Management

An author’s confession: I initially tried to solve this by using ABAP. I created a Z table

with four primary keys: region, brain size, color, and model, because these fields are

mandatory. Then I would read all the records with a match on all four and loop through

them, performing all sorts of convoluted lo gic to determine which record was the best

possible match. If I could not find any matches, then I did another database read to get

all records with a match on region, brain size, and color but for which the model was

blank. I then looped through these records, applying the same complicated logic checks

as before.

This worked, but it took a lot of doing, and when wrong results were being returned,

debugging the code was a nightmare.

BRFplus to the rescue!

Because that spreadsheet you were given by the business user looks just like a

BRFplus decision table, using that expression type in BRFplus is clearly the way to

go. (This may seem like a forced example, but if you look back through all the real

390

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

Saved successfully!

Ooh no, something went wrong!