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.

10

ALV SALV Reporting Framework

3. Change the INITIALIZE method to pass in the container object to the SALV factory

class.

4. Code the method that adds a list of user commands received from the calling

program to the SALV report object.

5. Pass in the list of user commands from the calling program.

This process of creating a screen automa tically is going to seem quite complicated;

it involves calling a method, whic h calls a function module, which calls

another method; it’s enough to make your head spin. Nonetheless, this only has

to be set up once, and all of this complexity is hidden from the calling program

forevermore.

If you want the screen and associated co ntainer to magically create themselves,

then first you split the initialization into two steps: creating such a screen (Section

10.3.1) and then the rest of the initialization steps you normally have to do manually

in each report (Section 10.3.2 and Section 10.3.3). Then, once the screen

and container are in place, you move on to looking at how the SALV-specific view

class goes about programmatically adding new custom commands to the toolbar

(Section 10.3.4) and how the calling pr ogram tells the view what custom commands

it wants the view to display (Section 10.3.5).

10.3.1 Creating a Method to Automatically Create a Container

In order to automatically create a contai ner, you have to create a method called

CREATE_CONTAINER_PREP_DISPLAY and add it to the concrete ZCL_BC_VIEW_SALV_

TABLE class, which is going to be invoked from the calling program instead of the

usual INITIALIZE method.

The first half of Listing 10.23 puts the in put parameters into global (to the class

instance) variables, and then a function module is called, the purpose of which

revolves around creating a screen and container. The call needs to be to a function

module, because function modules can call screens, but methods cannot.

METHOD create_container_prep_display.

md_report_name = id_report_name.

ms_variant-report = id_report_name.

ms_variant-variant = id_variant.

mt_user_commands[] = it_user_commands[].

442

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

Saved successfully!

Ooh no, something went wrong!