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

RETURN.

ENDIF.

lo_alv->get_frontend_fieldcatalog(

IMPORTING

et_fieldcatalog = lt_fcat ).

make_column_editable( :

EXPORTING id_column_name = 'MONSTER_HATS’

CHANGING ct_fcat = lt_fcat ),

EXPORTING id_column_name = 'MONSTER_HEADS'

CHANGING ct_fcat = lt_fcat ),

lo_alv->set_frontend_fieldcatalog( lt_fcat ).

ls_layout-stylefname = 'CELLTAB'.

lo_alv->set_frontend_layout( ls_layout ).

lo_alv->refresh_table_display( ).

cl_gui_cfw=>flush( ).

WHEN etc etc

Listing 10.32 User Command to Make a SALV Grid Editable

Naturally, now you need to code the custom methods called by Listing 10.32.

First, code the GET_ALV_GRID method in the ZCL_BC_VIEW_SALV_TABLE class (Listing

10.33), which has a single returnin g parameter typed as an instance of CL_

GUI_ALV_GRID. The method gets this instance by calling the equivalently named

method GET_ALV_GRID of the custom ZCL_SALV_MODEL class that was defined in

Section 10.3.3.

METHOD get_alv_grid.

* We have a container, so

* then the grid needs to be retrieved via the adapter

ro_alv_grid = mo_salv_model->get_alv_grid( ).

ENDMETHOD.

Listing 10.33 GET_ALV_GRID of ZCL_BC_VIEW_SALV_TABLE Method

Next, back in the co ntroller, define the MAKE_COLUMN_EDITABLE method, which

does the dirty work of changing the field catalog so that cells can be edited. This

code can be seen in Listing 10.34. Here , you need to loop through the internal

452

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

Saved successfully!

Ooh no, something went wrong!