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.

Database Access 2.1

account of secondary indexes could be described as a passive improvement; if you

had SELECT statements on an indexed field that previously bypassed the buffer,

then as of release 7.4 your code will speed up without you having to lift a finger—

and a lot of standard SAP code will speed up as well.

Another passive example of buffering improvements in ABAP 7.4 is that up until

now you could not perform a FOR ALL ENTRIES on a buffered table, even if you

used the primary key, without having to go to the database; you had to do a loop

of SELECT SINGLES and then get warned about doing SELECTS in a loop by the

extended syntax check. This is now a thin g of the past. Because the data is all in

memory, the query treats the FOR ALL ENTRIES as a loop of SELECT SINGLES, and

thus database access is totally avoided. As an example, a lot of standard SAP

reports do a FOR ALL ENTRIES on buffered table SETLEAF, which relates to the

profit center hierarchy. Under a 7.4 environment, all such standard programs will

run much faster.

2.1.3 Creating while Reading

In Chapter 10 of this book, you will learn about CL_SALV_TABLE and how it is

clever enough to look at the definition of your internal table and turn that definition

into an ALV grid without you having to manually define each column again.

ABAP 7.4 has taken this one step further by doing away with the need to perform

the data declaration for the internal table in the first place.

To illustrate what this means, look at the following example. Say that you want a

list of all the monsters named Fred. Trad itionally, you would go about this as

shown in Listing 2.5.

TYPES: BEGIN OF l_typ_monsters,

monster_name TYPE zt_monsters-monster_name,

monster_number TYPE zt_monsters-monster_number,

sanity TYPE zt_monsters-sanity,

END OF l_typ_monsters.

DATA: lt_monsters TYPE STANDARD TABLE OF l_typ_monsters.

SELECT monster_name monster_number sanity

FROM zt_monsters

INTO CORRESPONDING FIELDS OF TABLE lt_monsters

WHERE monster_name = 'FRED'.

Listing 2.5 List of All Monsters Named Fred

87

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

Saved successfully!

Ooh no, something went wrong!