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

9.1.3 Rules in ABAP

Programmers know that they can make ABAP do whatever they want it to do, and

quickly at that. As you can see in Listing 9.1, it’s not too difficult to whip up some

lines of code to achieve the result demanded by the mo nster business rule

requirement.

IF ld_sanity GT 75.

CASE ld_usage.

WHEN 'BALLROOM_DANCER'.

ld_ingredients = 1.

WHEN 'MORTGAGE_SALESMAN'.

ld_ingredients = 3.

WHEN OTHERS.

ld_ingredients = 2.

ENDCASE.

ELSEIF ld_sanity LE 74 AND

ld_sanity GE 16.

CASE ld_scariness.

WHEN 'EXTRA_SCARY'.

ld_ingredients = 3.

WHEN OTHERS.

ld_ingredients = 2.

ENDCASE.

ELSE."Sanity is 15% or less

CASE ld_evilness.

WHEN 'MODERATE'.

IF ld_rages_per_day LE 1.

ld_ingredients = 2.

ELSE.

ld_ingredients = 3.

ENDIF."Rages per Day

WHEN OTHERS.

ld_ingredients = 3.

ENDCASE."Evilness

ENDIF."Sanity Percentage

ASSERT ld_ingredients NE 0.

Listing 9.1 Monster Rule in ABAP

Although this code is easy to write, the perceived problem is that the logic is hidden

away in ABAP. From the business expert’s point of view, and even from that

of the poor old business analyst, this really is a black box. However, customizing

tables and ABAP code are the traditiona l way in which business rules have been

implemented since the dawn of SAP.

364

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

Saved successfully!

Ooh no, something went wrong!