Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

code for deleting a column

0 Kudos

Hi experts,

i need a code to delete a column at the output while user unselected the check box and vice versa.

thanks

2 REPLIES 2

FredericGirod
Active Contributor

Is it possible to give detail ?

thkolz
Contributor
0 Kudos
REPORT ztest2.

PARAMETERS:
p_nocarr TYPE abap_bool AS CHECKBOX.

DATA:
t_flight TYPE STANDARD TABLE OF sflight.

* Build ALV
TRY.
cl_salv_table=>factory(
EXPORTING
r_container = cl_gui_container=>screen0
IMPORTING
r_salv_table = DATA(r_salv_table)
CHANGING
t_table = t_flight
).

IF p_nocarr EQ abap_true.
* Don't show carrier

* Remove column from the layout
r_salv_table->get_columns( )->get_column( 'CARRID' )->set_technical( abap_true ).

** If you don't want to show the column, but it should be available in the layout
* r_salv_table->get_columns( )->get_column( 'CARRID' )->set_visible( abap_false ).
ENDIF.


CATCH cx_salv_msg
cx_salv_not_found
INTO DATA(r_exc).
MESSAGE r_exc->get_text( ) TYPE 'E' DISPLAY LIKE 'I'.
ENDTRY.

* optimize columns
r_salv_table->get_columns( )->set_optimize( ).


* Enable functions
r_salv_table->get_functions( )->set_all( ).

r_salv_table->display( ).

WRITE space. "Important to force generation of cl_gui_container=>screen0