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.

Getting Started 10.1

FROM ztvc_monsters

INTO CORRESPONDING FIELDS OF TABLE gt_monsters.

"It is bad news to pass system variables as parameters

ld_repid = sy-repid.

CREATE OBJECT lo_view.

lo_view->prepare_display_data(

EXPORTING

id_report_name = ld_repid

" Calling program

id_variant = p_vari " Display Variant as specified by user

CHANGING

ct_data_table = gt_monsters ).

Listing 10.1 Generic Code to Call the Custom API

There is only method being called in Listing 10.1: the PREPARE_DISPLAY_DATA

method. This method is inherited from the abstract class and implemented in the

concrete class but has a totally generic nature. Listing 10.2 examines the coding

for this method. First, initialize the underlying report object in whatever technology

you’re using. Then, pass control to the calling report to make changes specific

to the application. Finally, display the report using your chosen technology.

METHOD zif_bc_alv_report_view~prepare_display_data.

* Step One - Generic - Set up the Basic Report

initialise(

EXPORTING

id_report_name = id_report_name " Calling program

id_variant = id_variant " Layout

io_container = io_container

it_user_commands = it_user_commands " Toolbar Buttons

CHANGING

ct_data_table = ct_data_table ).

* Step Two - Application Specific

application_specific_changes( ).

* Step Three - Generic - Actually Display the Report

display( ).

ENDMETHOD.

Listing 10.2 Preparing and Displaying Data Method

The PREPARE_DISPLAY_DATA method orchestrates th e three mandat ory process

flow steps that are part of creating a report interface. These steps are discussed in

detail in the next section.

413

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

Saved successfully!

Ooh no, something went wrong!