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.

Creating and Using Shared Memory Objects 14.2

Figure 14.2 Declaring a Custom Table Type

PUBLIC SECTION.

*"* public components of class ZCL_MONSTER_SHMO_ROOT

*"* do not include other source files here!!!

INTERFACES if_shm_build_instance .

TYPES: mtt_monsters TYPE HASHED TABLE OF ztvc_monsters

WITH UNIQUE KEY monster_number.

DATA: mt_monsters TYPE mtt_monsters.

Listing 14.1 Data Declarations in the Root Class

You have a place for the data to live, but how does the data get there in the first

place? Surely, you have to go to the database at least once? Yes you do, and in

order to enable this you need yo ur root class to implement the IF_SHM_BUILD_

INSTANCE interface, which has the BUILD method. BUILD is called automatically by

the SAP system, but you cannot code the method until you’ve created the broker

class, so Section 14.2.2 will return to this topic.

In the meantime, you can define your own LOAD method (Figure 14.3) to transfer

the entire database table to an equivalent internal table.

Figure 14.3 Defining the LOAD Method

637

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

Saved successfully!

Ooh no, something went wrong!