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.

Internal Tables 2.6

WHEN cs_monster_header-sanity = 5 THEN 'VERY SANE'

WHEN cs_monster_header-sanity = 4 THEN 'SANE'.

WHEN cs_monster_header-sanity = 3 THEN 'SLIGHTLY MAD'.

WHEN cs_monster_header-sanity = 2 THEN 'VERY MAD'.

WHEN cs_monster_header-sanity = 1 THEN 'BONKERS'.

ELSE.

cs_monster_header-sanity_description = 'RENAMES SAP PRODUCTS'.

ENDIF.

Listing 2.41 Using the COND Constructor Operator

That looks just like a CASE statement, and the only bene fit in this change at this

point is that it’s a bit more compact. However, when the business decides that

you need to take the day into account whensaying if a monster is bonkers or not,

you can just change part of the COND construct. In the pre-7.4 situation, you had to

give up on the whole idea of a CASE statement and rewrite everything as an IF/

ELSE construct. The only change needed to the COND logic is shown in Listing 2.42.

WHEN cs_monster_header-sanity = 1 AND

ld_day = ‘Tuesday’ THEN ‘HAVING AN OFF DAY’.

WHEN cs_monster_header-sanity = 1 THEN 'BONKERS'.

ELSE.

cs_monster_header-sanity_description = 'RENAMES SAP PRODUCTS'.

ENDIF.

Listing 2.42 COND Constructor Operator with Updated Logic

2.6 Internal Tables

Internal tables are the bread and butter of programming in ABAP. A lot of other

languages, like Java, can only dream of having such a thing; they have to deal

with various sorts of arrays and stacks and hash browns and what have you. In

this section, you’ll learn about some new ABAP functionalities that relate to internal

tables.

2.6.1 Using Secondary Keys to Access the Same Internal Table in

Different Ways

7.02 Feature

This feature came about with ABAP 7.02, but is discussed here because it’s little known.

109

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

Saved successfully!

Ooh no, something went wrong!