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.

2

New Language Features in ABAP 7.4

AND zt_monster_pets~type LIKE 'GIGANTIC%'

AND zt_monster_pets~species IN ('SHARK','CROCODILE','DINOSAUR')

Listing 2.9 Joining Two Tables in Ways Not Possible Before

If you want a table of all the pets of va rious monsters along with some details

about the owning monsters, but you’re only interested in gigantic dinosaurs and

the like, then the query shown in Listing 2.9 is the one for you.

2.2 Declaring and Creating Variables

One of the main differences between ABAP and other languages is that in ABAP

we have been taught to declare all our variables at the start of the program—for

example, in a TOP INCLUDE . Other languages declare them just before they are

used, and such variables tend to be more local in scope—for example, within a

loop. Despite the official ABAP progra mming guidelines, many ABAP programmers

have taken to declaring variables just before they are used for the first time,

for purposes of making the program more readable by humans and hence easier

to change.

The good news is that as time goes on, changes in the ABAP language make this

unofficial practice more and more acceptable. This section will discuss several features

that contribute to this shift.

2.2.1 Omitting the Declaration of TYPE POOL Statements

7.02 Feature

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

Many programs use the ever-popular ABAP_TRUE and ABAP_FALSE constants, and

even more use the built-in icon consta nts to make ALV reports more visually

appealing to users. This us ed to involve declaring a TYPE POOL statement in the

TOP INCLUDE, or at the start of a program, or in the forward declaration property

of the global class. An example of this is shown in Listing 2.10.

TYPE-POOLS: abap,

icon.

Listing 2.10 Declaring a TYPE POOL

90

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

Saved successfully!

Ooh no, something went wrong!