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.

Using BOPF to Write a DYNPRO-Style Program 8.2

ELSE.

cs_monster_header-hat_size_description = 'NORMAL HAT'.

ENDIF.

* Fill the Sanity Description

IF cs_monster_header-sanity > 75.

cs_monster_header-sanity_description = 'VERY SANE'.

ELSEIF cs_monster_header-sanity > 50.

cs_monster_header-sanity_description = 'SANE'.

ELSEIF cs_monster_header-sanity > 25.

cs_monster_header-sanity_description = 'SLIGHTLY MAD'.

ELSEIF cs_monster_header-sanity > 12.

cs_monster_header-sanity_description = 'VERY MAD'.

ELSEIF cs_monster_header-sanity > 1.

cs_monster_header-sanity_description = 'BONKERS'.

ELSE.

cs_monster_header-sanity_description = 'RENAMES SAP PRODUCTS'.

ENDIF.

ENDMETHOD. "Fill Header Derived Fields

Listing 8.8 Filling Derived Header Fields

The code in Listing 8.8 to fill the derived fields is deliberately simple. In real life,

you would perform some text lookups to get the sales organization description

based on the sales organization code or some such, or you would multiply two

fields together to get a third. (The exampl e is also unrealistic in that in the real

world surely nobody would be mad enough to rename their entire product portfolio

every month.)

Now, you have the business logic code; ne xt, you’ll learn how you can tell the

BOPF determination class to make use of this logic. As mentioned previously, this

involves the implementation of three methods: CHECK_DELTA, CHECK, and EXECUTE.

The CHECK_DELTA Method

I started off programming in 1981 on a computer with 1K of memory and a processor

with a tiny fraction of the processing power we are used to today. The

restrictions this forced upon me have stayed with me all my life, and even to this

day I am obsessed with not executing a single line of code that does not need to

be run (in order to put less strain on the CPU). In this example, you can reduce the

number of lines of code that run in this way: Instead of redetermining the hat size

text every time a user changes anything, only run the code when the hat size value

changes. This is somewhat analogous to ON INPUT in the DYNPRO framework.

311

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

Saved successfully!

Ooh no, something went wrong!