Sometimes we need to show an error log with multiples lines, and a popup window is a very good option to use here.
Using CL_SALV_TABLE class, we can achieve this requirement in a very easy way.
Here is a sample code to open a popup window with some records as icon and status message.
TYPES: BEGIN OF ys_log, icon TYPE c LENGTH 40, message TYPE c LENGTH 200, END OF ys_log. " Variáveis locais DATA: ls_log TYPE ys_log, lt_log TYPE TABLE OF ys_log, lr_table TYPE REF TO cl_salv_table, lr_display TYPE REF TO cl_salv_display_settings, lr_columns TYPE REF TO cl_salv_columns, lr_column TYPE REF TO cl_salv_column. " Sample data CLEAR ls_log. ls_log-icon = icon_led_green. ls_log-message = 'Status OK'. APPEND ls_log TO lt_log. CLEAR ls_log. ls_log-icon = icon_led_red. ls_log-message = 'Erros'. APPEND ls_log TO lt_log. " Create ALV table TRY. cl_salv_table=>factory( IMPORTING r_salv_table = lr_table CHANGING t_table = lt_log ). CATCH cx_salv_msg. ENDTRY. lr_display = lr_table->get_display_settings( ). lr_display->set_list_header( 'Error Log' ). " Set columns lr_columns = lr_table->get_columns( ). lr_columns->set_optimize( 'X' ). " Change Texts if needes TRY. lr_column = lr_columns->get_column( 'ICON' ). lr_column->set_short_text( 'Status' ). CATCH cx_salv_not_found. ENDTRY. TRY. lr_column = lr_columns->get_column( 'MESSAGE' ). lr_column->set_short_text( 'Message' ). CATCH cx_salv_not_found. ENDTRY. " Set a Popup lr_table->set_screen_popup( start_column = 1 end_column = 50 start_line = 1 end_line = 10 ). " Show ALV lr_table->display( ).
Regards,
Frisoni