How to show ALV report in Popup screen in ABAP [June 2020] | Neutrace.com

In this article, we will discuss how to show a ALV report in Popup screen.

Method 1

" Local data declaration

    DATA: lo_popup_alv        TYPE REF TO cl_salv_table,
          lo_functions                TYPE REF TO cl_salv_functions_list,
          lo_display_settings     TYPE REF TO cl_salv_display_settings,
          lo_salv_columns         TYPE REF TO cl_salv_columns.

    TRY.

        " Get ALV object for popup
        cl_salv_table=>factory(
          IMPORTING
            r_salv_table = lo_popup_alv
          CHANGING
            t_table      = it_outtab[] ).

      CATCH cx_salv_msg INTO DATA(lo_message).

        IF lo_message IS BOUND.

          DATA(lv_message) = lo_message->get_text( ).
          MESSAGE lv_message TYPE 'I'.

        ENDIF.

        CLEAR: lo_message.
    ENDTRY.

    " Set Window Title                                           
    lo_display_settings = lo_popup_alv->get_display_settings( ).
    lo_display_settings->set_list_header( 'This is a popup ALV' ).          

    " Get all functions
    lo_functions = lo_popup_alv->get_functions( ).

    " Set required functions
    lo_functions->set_all( abap_true ).

    IF lo_popup_alv IS BOUND.

      " Set screen as popup
      lo_popup_alv->set_screen_popup(
        start_column = 25
        end_column  = 100
        start_line  = 6
        end_line    = 15 ).

      " Get list of all columns
      lo_salv_columns = lo_popup_alv->get_columns( ).
      lo_salv_columns->set_optimize( abap_true ). " Optimize column width

      " Prepare field catalog
      prepare_fcat( CHANGING cr_cols = lo_salv_columns ).

      " Display application document list ALV
      lo_popup_alv->display( ).

    ENDIF.

Comments