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.

10

ALV SALV Reporting Framework

repetitive tasks of creating a COLUMNS object out of the SALV object, and then creating

a COLUMN object out of the COLUMNS object, and then setting the attribute,

again and again.

METHOD set_hotspot.

TRY.

mo_column ?= mo_columns->get_column( id_column_name ).

CALL METHOD mo_column->set_cell_type

EXPORTING

value = if_salv_c_cell_type=>hotspot.

CATCH cx_salv_not_found.

"Raise fatal exception

ENDTRY.

ENDMETHOD. "Set Hotspot

Listing 10.11 SET_HOTSPOT Method

Listing 10.12 shows the code for the SET_VISIBLE method. Note that all columns

in the internal table passed into the SA LV object during creation are visible by

default; you have to pass ABAP_FALSE into this method to hide the ones you don’t

want to be seen on the initial screen, but the lucky old user can add them back in

later if he so desires.

METHOD set_visible.

TRY.

mo_column ?= mo_columns->get_column( id_field_name ).

mo_column->set_visible( if_is_visible ).

CATCH cx_salv_not_found.

"Raise Fatal Exception

ENDTRY.

ENDMETHOD.

Listing 10.12 SET_VISIBLE Method

Listing 10.13 is for when you don’t want the user to ever see the column in a

report. Often, there are helper fields in your internal tables to aid in interim calculations.

It would be painful to have two almost identical internal tables, one to

prepare the data and one just with the display columns. That would take up twice

as much memory, and you would have to go to the effort of moving data from

one to the other.

430

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

Saved successfully!

Ooh no, something went wrong!