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

case is the CL_GUI_ALV_GRID at the heart of a SALV object, the model is the SALV

object itself, and the controller knows whether the report is running in full screen

mode or in container mode.

In this case, the report is running in container mode and always will be, but nonetheless,

because the theoretical possibility exists that it might not be, you can only

access the underlying grid object by pa ssing the controller object through two

adapters before you can extract the underlying grid object. The end result is a CL_

GUI_ALV_GRID instance that hides within CL_SALV_TABLE.

METHOD get_alv_grid.

* Local Variables

DATA: lo_grid_adapter TYPE REF TO cl_salv_grid_adapter,

lo_controller TYPE REF TO cl_salv_controller_model,

lo_adapter TYPE REF TO cl_salv_adapter.

lo_controller = mo_model->r_controller.

"Target = LO_ADAPTER type CL_SALV_ADAPTER

"Source = R_ADAPTER type CL_SALV_ADAPTER

"R_ADAPTER may actually be a subclass however

lo_adapter ?= lo_controller->r_adapter.

"We are in container mode

lo_grid_adapter ?= lo_adapter.

ro_alv_grid = lo_grid_adapter->get_grid( ).

ENDMETHOD.

Listing 10.30 Returning an ALV Grid Object from ZCL_SALV_MODEL

10.4.4 Changing the Calling Program

In order to let the user make the cells editable, you need a user command to be

added programmatically. As explained in Section 10.3, that means you need a

container. Therefore, in the example mo nster report that uses the custom SALV

class, now create the SALV object (called GO_VIEW in the code) with reference to a

container (Listing 10.31).

"No custom status, added user commands

"Editing possible

go_view->create_container_prep_display(

EXPORTING

id_title

= 'Monster Report'

id_report_name = gd_repid " Calling program

id_variant = p_vari "Variant specified by user

450

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

Saved successfully!

Ooh no, something went wrong!