Application Development and Automation 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: 
Read only

code for deleting a column

0 Likes
693

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
Read only

FredericGirod
Active Contributor
650

Is it possible to give detail ?

Read only

thkolz
Contributor
0 Likes
650
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