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: 

Alv using class In list format

0 Kudos

Hi,

I am using a method set_table_for_first_display in class cl_gui_alv_grid to display ALV. but by default the output appears in grid format, I want to change the output in LIST format.

What can I do to change the output in list format.

Kind Regards,

Abhishek.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try this..

do this in the PBO..

sy-ucomm = '&PRINT_BACK_PREVIEW'.

  • G_GRID is your object for the class CL_GUI_ALV_GRID

CALL METHOD g_grid->fcode_bouncer

.

Thanks

Naren

7 REPLIES 7

Former Member
0 Kudos

Method set_table_for_first_display must only be called a second time if the structure of the output table changes.

hi check this for more info

http://help.sap.com/saphelp_nw04/helpdata/en/0a/b5533cd30911d2b467006094192fe3/frameset.htm

Former Member
0 Kudos

try this.... this is an example code.... don't use set_table_for_first_display rather use CL_SALV_TABLE and execute the below code


*&---------------------------------------------------------------------*
*& Report  ZAMIT_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zamit_test  MESSAGE-ID z_zzz_ca_messages.

* constants for icons
TYPE-POOLS: icon, col.

* type for internal table
TYPES: BEGIN OF x_sflight.
*       selfld TYPE char1.
        INCLUDE STRUCTURE sflight.
TYPES: seatsfree TYPE sflight-seatsocc,
       usage TYPE n,                    " exception
       icon_future TYPE icon-id,        " icon for future / past
       line_counter TYPE i,             " line counter
       it_colors TYPE lvc_t_scol, " internal tab for cell color info
END OF x_sflight.
* Internal table

DATA: i_sflight  TYPE STANDARD TABLE OF x_sflight,
      wa_sflight TYPE x_sflight,
      wa_colors  TYPE lvc_s_scol,
      list_display TYPE sap_bool,
      vref_cont    TYPE REF TO cl_gui_custom_container,
      vref_alv     TYPE REF TO cl_salv_table,      " ALV instance
      oref_error   TYPE REF TO cx_salv_error,      " Error instance
      l_text_alv_e TYPE string,
      ok_code      TYPE syucomm.

SELECT-OPTIONS: so_car FOR wa_sflight-carrid MEMORY ID car,
                so_con FOR wa_sflight-connid.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK alv WITH FRAME TITLE text-alv.
PARAMETERS: pa_full RADIOBUTTON GROUP alvd DEFAULT 'X',
            pa_cont RADIOBUTTON GROUP alvd,
            pa_list RADIOBUTTON GROUP alvd.
SELECTION-SCREEN END OF BLOCK alv.
PARAMETERS: p_layout TYPE slis_vari.

*----------------------------------------------------------------------*
*       CLASS lcl_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_handler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
    on_added_function FOR EVENT added_function OF cl_salv_events_table
            IMPORTING e_salv_function, " type salv_de_function
    on_double_click FOR EVENT double_click OF cl_salv_events_table
            IMPORTING row,   " type salv_de_row = int4
    on_link_click FOR EVENT link_click OF cl_salv_events_table
            IMPORTING row    " type salv_de_row = int4
                      column." type salv_de_column = char(30)
ENDCLASS. "lcl_handler definition

*-------------------------------------------------
* CLASS lcl_handler IMPLEMENTATION
*-------------------------------------------------
CLASS lcl_handler IMPLEMENTATION.
  METHOD on_added_function.
    DATA: l_oref_columns TYPE REF TO cl_salv_columns_table,
          l_oref_column  TYPE REF TO cl_salv_column_table,
          l_oref_column1 TYPE REF TO cl_salv_column,
          l_except1      TYPE REF TO cx_salv_not_found,   "Exception
          l_text1        TYPE string,                     "Exception msg
          l_lvc_s_colo TYPE lvc_s_colo.
    CASE e_salv_function.
      WHEN 'REORDER'.
* get the COLUMNS object
        l_oref_columns = vref_alv->get_columns( ).
* positions: (MANDT column + 3 key colums)
        l_oref_columns->set_column_position( columnname = 'SEATSOCC'
                                             position = 5 ).
        l_oref_columns->set_column_position( columnname = 'SEATSOCC_B'
                                             position = 6 ).
        l_oref_columns->set_column_position( columnname = 'SEATSOCC_F'
                                             position = 7 ).
*       prepare color info

*       column SEATSOCC
        TRY.
            CALL METHOD l_oref_columns->get_column
              EXPORTING
                columnname = 'SEATSOCC'
              RECEIVING
                value      = l_oref_column1.
          CATCH cx_salv_not_found INTO l_except1.
            l_text1 = l_except1->get_text( ).
            MESSAGE i000 WITH l_text1.
            LEAVE LIST-PROCESSING.
        ENDTRY.
        l_oref_column ?= l_oref_column1.
        l_oref_column->set_color( value = l_lvc_s_colo ).

*       column SEATSOCC_B
        TRY.
            CALL METHOD l_oref_columns->get_column
              EXPORTING
                columnname = 'SEATSOCC_B'
              RECEIVING
                value      = l_oref_column1.
          CATCH cx_salv_not_found INTO l_except1.
            l_text1 = l_except1->get_text( ).
            MESSAGE i000 WITH l_text1.
            LEAVE LIST-PROCESSING.
        ENDTRY.
        l_oref_column ?= l_oref_column1.
        l_oref_column->set_color( value = l_lvc_s_colo ).

*       column SEATSOCC_F
        TRY.
            CALL METHOD l_oref_columns->get_column
              EXPORTING
                columnname = 'SEATSOCC_F'
              RECEIVING
                value      = l_oref_column1.
          CATCH cx_salv_not_found INTO l_except1.
            l_text1 = l_except1->get_text( ).
            MESSAGE i000 WITH l_text1.
            LEAVE LIST-PROCESSING.
        ENDTRY.
        l_oref_column ?= l_oref_column1.
        l_oref_column->set_color( value = l_lvc_s_colo ).
    ENDCASE.
  ENDMETHOD. "on_added_function
  METHOD on_double_click.
    DATA: message_text(70),
          lc_seatsfree_e(10),
          lc_seatsfree_b(10),
          lc_seatsfree_f(10).
    READ TABLE i_sflight INTO wa_sflight INDEX row.
    CHECK sy-subrc EQ 0.
    lc_seatsfree_e = wa_sflight-seatsmax - wa_sflight-seatsocc.
    lc_seatsfree_b = wa_sflight-seatsmax_b - wa_sflight-seatsocc_b.
    lc_seatsfree_f = wa_sflight-seatsmax_f - wa_sflight-seatsocc_f.
    CONCATENATE 'FREE SEATS:'(frs) 'ECONOMY:'(eco) lc_seatsfree_e
    'BUSINESS'(bus) lc_seatsfree_b 'FIRST'(fst) lc_seatsfree_f
                    INTO message_text SEPARATED BY space.
    MESSAGE message_text TYPE 'I'.
  ENDMETHOD. "on_double_click
  METHOD on_link_click.
    DATA: lc_carrname TYPE scarr-carrname,
    lc_currcode TYPE scarr-currcode,
    message_text(70).
    READ TABLE i_sflight INTO wa_sflight INDEX row.
    CHECK sy-subrc EQ 0.
    CASE column.
      WHEN 'CARRID'.
        SELECT SINGLE carrname currcode
        INTO (lc_carrname, lc_currcode)
        FROM scarr
        WHERE carrid = wa_sflight-carrid.
        IF sy-subrc EQ 0.
          CONCATENATE 'AIRLINE:'(air) wa_sflight-carrid
          'NAME:'(nme) lc_carrname
          'CURRENCY:' lc_currcode
          INTO message_text
          SEPARATED BY space.
          MESSAGE message_text TYPE 'I'.
        ENDIF.
      WHEN 'SELFLD'.
        MESSAGE i000 with 'Checkbox Clicked'.
    ENDCASE.
  ENDMETHOD. "on_link_click
ENDCLASS. "lcl_handler IMPLEMENTATION

START-OF-SELECTION.
* retrieve data into internal table
  SELECT * FROM sflight
  INTO CORRESPONDING FIELDS OF TABLE i_sflight
  WHERE carrid IN so_car
  AND connid IN so_con.


END-OF-SELECTION.
* fill additional data fields
  LOOP AT i_sflight INTO wa_sflight.
* seats free
    wa_sflight-seatsfree =
    wa_sflight-seatsmax + wa_sflight-seatsmax_b
    + wa_sflight-seatsmax_f
    - wa_sflight-seatsocc - wa_sflight-seatsocc_b
    - wa_sflight-seatsocc_f.
* usage (exception light)
    IF wa_sflight-seatsfree = 0.
      wa_sflight-usage = '1'.
    ELSEIF wa_sflight-seatsfree <= 20.
      wa_sflight-usage = '2'.
    ELSE.
      wa_sflight-usage = '3'.
    ENDIF.
* icon "in the future/not in the future"
    IF wa_sflight-fldate > sy-datum.
      wa_sflight-icon_future = icon_positive.
    ELSE.
      wa_sflight-icon_future = icon_negative.
    ENDIF.
* cell colors
* single cell if planetype is 747-400
    IF wa_sflight-planetype = '747-400'.
      CLEAR wa_colors.
      wa_colors-fname = 'PLANETYPE'.
      wa_colors-color-col = col_positive.
      wa_colors-color-int = 1.
      APPEND wa_colors TO wa_sflight-it_colors.
    ENDIF.
* whole line if seatsfree gt 200
    IF wa_sflight-seatsfree >= 200.
      CLEAR wa_colors.
      wa_colors-color-col = col_heading.
      wa_colors-color-int = 1.
      APPEND wa_colors TO wa_sflight-it_colors.
    ENDIF.
    MODIFY i_sflight
    FROM wa_sflight
         TRANSPORTING
    seatsfree
    usage
    icon_future
    it_colors.
  ENDLOOP.

  CASE 'X'.
    WHEN pa_full OR pa_list.
      IF pa_list IS NOT INITIAL.
        list_display = if_salv_c_bool_sap=>true.
      ELSE.
        list_display = if_salv_c_bool_sap=>false.
      ENDIF.
      TRY.
          CALL METHOD cl_salv_table=>factory
            EXPORTING
              list_display = list_display
            IMPORTING
              r_salv_table = vref_alv
            CHANGING
              t_table      = i_sflight.
        CATCH cx_salv_msg INTO oref_error.
          l_text_alv_e = oref_error->get_text( ).
          MESSAGE i000 WITH l_text_alv_e.
          LEAVE LIST-PROCESSING.
      ENDTRY.
* define settings
      PERFORM define_settings USING vref_alv.
* display ALV
      vref_alv->display( ).

    WHEN pa_cont.
      CALL SCREEN 100.
  ENDCASE.
*&---------------------------------------------------------------------*
*&      Form  define_settings
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_ALV      ALV object
*----------------------------------------------------------------------*
FORM define_settings USING p_alv TYPE REF TO cl_salv_table.
  PERFORM: sub_set_display    USING p_alv,
           sub_set_columns    USING p_alv,
           sub_set_sorts      USING p_alv,
           sub_set_aggregs    USING p_alv,
           sub_set_selections USING p_alv,
           sub_set_layout     USING p_alv,
           sub_set_functions  USING p_alv,
           sub_set_events     USING p_alv,
           sub_set_header     USING p_alv.
ENDFORM. " define_settings

*&-------------------------------------------
*& Form sub_set_display
*&-------------------------------------------
* set general display attributs
*--------------------------------------------
* -->P_ALV ALV object
*--------------------------------------------
FORM sub_set_display USING p_alv TYPE REF TO cl_salv_table.
  DATA: lr_display TYPE REF TO cl_salv_display_settings,
        l_title TYPE lvc_title.

* get display settings object
  lr_display = p_alv->get_display_settings( ).
* set header
  l_title = text-ttl.
  lr_display->set_list_header( value = text-ttl ).
* set horizontal lines off
  lr_display->set_horizontal_lines( value = ' '  ).
* set striped pattern
  lr_display->set_striped_pattern( value = 'X' ).
ENDFORM. " sub_set_display

*&---------------------------------------------------------------------*
*&      Form  sub_set_columns
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_ALV      text
*----------------------------------------------------------------------*
FORM sub_set_columns USING p_alv TYPE REF TO cl_salv_table.
  DATA: l_oref_columns TYPE REF TO cl_salv_columns_table,
        l_oref_column  TYPE REF TO cl_salv_column_table,
        l_oref_column1 TYPE REF TO cl_salv_column,
        l_except1      TYPE REF TO cx_salv_not_found,   "Exception
        l_except2      TYPE REF TO cx_salv_data_error,  "Exception
        l_text1        TYPE string,                     "Exception msg
        l_scrtext_s    TYPE scrtext_s,
        l_scrtext_m    TYPE scrtext_m,
        l_scrtext_l    TYPE scrtext_l,
        l_lvc_tip      TYPE lvc_tip,     " for tooltip
        l_pos          TYPE i,           " column position
        l_lvc_s_colo   TYPE lvc_s_colo.  " column color


  l_oref_columns = p_alv->get_columns( ).   " get columns object
* set exception column
  TRY.
      CALL METHOD l_oref_columns->set_exception_column
        EXPORTING
          value = 'USAGE'.
    CATCH cx_salv_data_error INTO l_except2.
      l_text1 = l_except2->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
  ENDTRY.

* set count column
  TRY.
      CALL METHOD l_oref_columns->set_count_column
        EXPORTING
          value = 'LINE_COUNTER'.
    CATCH cx_salv_data_error INTO l_except2.
      l_text1 = l_except2->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
  ENDTRY.

* set cell colors / line colors column
  TRY.
      CALL METHOD l_oref_columns->set_color_column
        EXPORTING
          value = 'IT_COLORS'.
    CATCH cx_salv_data_error INTO l_except2.
      l_text1 = l_except2->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
  ENDTRY.

* column ICON_FUTURE
  TRY.
      CALL METHOD l_oref_columns->get_column
        EXPORTING
          columnname = 'ICON_FUTURE'
        RECEIVING
          value      = l_oref_column1.
    CATCH cx_salv_not_found INTO l_except1.
      l_text1 = l_except1->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
  ENDTRY.
  l_oref_column ?= l_oref_column1.
  l_oref_column->set_icon( ).
  l_scrtext_s = text-fut.
  l_oref_column->set_short_text( value = l_scrtext_s ).
  l_oref_column->set_row( value = 2 ).

* Column SEATSFREE
  TRY.
      CALL METHOD l_oref_columns->get_column
        EXPORTING
          columnname = 'SEATSFREE'
        RECEIVING
          value      = l_oref_column1.
    CATCH cx_salv_not_found INTO l_except1.
      l_text1 = l_except1->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
  ENDTRY.
  l_oref_column ?= l_oref_column1.
* set color to COL_GROUP
  l_lvc_s_colo-col = col_group.
  l_lvc_s_colo-int = 1.
  l_oref_column->set_color( value = l_lvc_s_colo ).

** Column SELFLD
*  TRY.
*      CALL METHOD l_oref_columns->get_column
*        EXPORTING
*          columnname = 'SELFLD'
*        RECEIVING
*          value      = l_oref_column1.
*    CATCH cx_salv_not_found INTO l_except1.
*      l_text1 = l_except1->get_text( ).
*      MESSAGE i000 WITH l_text1.
*      LEAVE LIST-PROCESSING.
*  ENDTRY.
*  l_oref_column ?= l_oref_column1.
** set color to COL_GROUP
*  if pa_list = 'X'.
*  l_oref_column->set_cell_type( value =
*                               if_salv_c_cell_type=>CHECKBOX ).
*  ELSEIF pa_full = 'X'.
*    l_oref_column->set_cell_type( value =
*                               if_salv_c_cell_type=>CHECKBOX_HOTSPOT ).
*  endif.
ENDFORM.                    "sub_set_columns


*&--------------------------------------------------
*& Form sub_set_sorts
*&--------------------------------------------------
* -->P_ALV text
*&--------------------------------------------------
FORM sub_set_sorts USING p_alv TYPE REF TO cl_salv_table.
  DATA: l_oref_sorts TYPE REF TO cl_salv_sorts,
        l_except1      TYPE REF TO cx_salv_not_found,   "Exception
        l_except2      TYPE REF TO cx_salv_existing,    "Exception
        l_except3      TYPE REF TO cx_salv_data_error,  "Exception
        l_text1        TYPE string.                     "Exception msg

* get the SORTS object
  l_oref_sorts = p_alv->get_sorts( ).
* add sorts
  TRY.
      CALL METHOD l_oref_sorts->add_sort
        EXPORTING
          columnname = 'CARRID'
          position   = 1.

    CATCH cx_salv_not_found INTO l_except1.
      l_text1 = l_except1->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
    CATCH cx_salv_existing  INTO l_except2.
      l_text1 = l_except2->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
    CATCH cx_salv_data_error INTO l_except3.
      l_text1 = l_except3->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
  ENDTRY.

  TRY.
      CALL METHOD l_oref_sorts->add_sort
        EXPORTING
          columnname = 'CONNID'
          position   = 2
          subtotal   = if_salv_c_bool_sap=>true.

    CATCH cx_salv_not_found INTO l_except1.
      l_text1 = l_except1->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
    CATCH cx_salv_existing  INTO l_except2.
      l_text1 = l_except2->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
    CATCH cx_salv_data_error INTO l_except3.
      l_text1 = l_except3->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
  ENDTRY.

  TRY.
      CALL METHOD l_oref_sorts->add_sort
        EXPORTING
          columnname = 'FLDATE'
          position   = 3.

    CATCH cx_salv_not_found INTO l_except1.
      l_text1 = l_except1->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
    CATCH cx_salv_existing  INTO l_except2.
      l_text1 = l_except2->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
    CATCH cx_salv_data_error INTO l_except3.
      l_text1 = l_except3->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
  ENDTRY.

ENDFORM. " sub_set_sorts
*&--------------------------------------------------
*& Form sub_set_aggregs
*&--------------------------------------------------
* -->P_ALV text
*&--------------------------------------------------
FORM sub_set_aggregs USING p_alv TYPE REF TO cl_salv_table.
  DATA: l_oref_aggregs TYPE REF TO cl_salv_aggregations,
        l_except1      TYPE REF TO cx_salv_data_error,  "Exception
        l_except2      TYPE REF TO cx_salv_not_found,   "Exception
        l_except3      TYPE REF TO cx_salv_existing,    "Exception
        l_text1        TYPE string.                     "Exception msg

  l_oref_aggregs = p_alv->get_aggregations( ).
  TRY.
      CALL METHOD l_oref_aggregs->add_aggregation
        EXPORTING
          columnname  = 'SEATSFREE'
          aggregation = if_salv_c_aggregation=>total.

    CATCH cx_salv_data_error INTO l_except1.
      l_text1 = l_except1->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
    CATCH cx_salv_not_found  INTO l_except2.
      l_text1 = l_except2->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
    CATCH cx_salv_existing   INTO l_except3.
      l_text1 = l_except3->get_text( ).
      MESSAGE i000 WITH l_text1.
      LEAVE LIST-PROCESSING.
  ENDTRY.
ENDFORM. " sub_set_aggregs
*&--------------------------------------------------
*& Form sub_set_selections
*&--------------------------------------------------
* -->P_ALV text
*&--------------------------------------------------
FORM sub_set_selections USING p_alv TYPE REF TO cl_salv_table.
  DATA: lr_selections TYPE REF TO cl_salv_selections.
* get the SELECTIONS object
  lr_selections = p_alv->get_selections( ).
* set the selection mode
  lr_selections->set_selection_mode(
                 value = if_salv_c_selection_mode=>cell ).
ENDFORM. " sub_set_selections
*&--------------------------------------------------
*& Form sub_set_layout
*&--------------------------------------------------
* -->P_ALV text
*&--------------------------------------------------
FORM sub_set_layout USING p_alv TYPE REF TO cl_salv_table.
  DATA: lr_layout TYPE REF TO cl_salv_layout,
  ls_key TYPE salv_s_layout_key.
* get the LAYOUT object
  lr_layout = p_alv->get_layout( ).
* set the layout key
  ls_key-report = sy-cprog.
  lr_layout->set_key( value = ls_key ).
* set save restriction
* (restriction "none" is intended,
* so we may use the default)
  lr_layout->set_save_restriction(
* VALUE = IF_SALV_C_LAYOUT=>RESTRICT_NONE
  ).
* allow setting a default layout
  lr_layout->set_default( value = 'X' ).
* set initial layout
  lr_layout->set_initial_layout( value = p_layout ).
ENDFORM. " sub_set_layout

*&-----------------------------------------------
*& Form sub_set_functions
*&-----------------------------------------------
* -->P_ALV text
*------------------------------------------------
FORM sub_set_functions USING p_alv TYPE REF TO cl_salv_table.
  DATA: lr_functions TYPE REF TO cl_salv_functions_list,
        l_except1    TYPE REF TO cx_salv_existing,
        l_except2    TYPE REF TO cx_salv_wrong_call,
        l_text1      TYPE string,
* help variables for method call ADD_FUNCTION
        l_icon       TYPE string,
        l_text       TYPE string,
        l_tooltip    TYPE string.
IF pa_full = 'X' or pa_list = 'X'.
  p_alv->set_screen_status( pfstatus = 'SALV_TABLE_STANDARD'
                            report = sy-repid
                       set_functions = p_alv->c_functions_all ).
ENDIF.
* get the FUNCTIONS object
  lr_functions = p_alv->get_functions( ).
* offer all generic functions
  lr_functions->set_all( value = if_salv_c_bool_sap=>true ).
* subtract average
  lr_functions->set_aggregation_average(
                    value = if_salv_c_bool_sap=>false ).
* subtract all export functions
  lr_functions->set_group_export(
                    value = if_salv_c_bool_sap=>false ).
* enable exort to local file
  lr_functions->set_export_localfile(
                    value = if_salv_c_bool_sap=>true ).
* subtract transfer to lotus
  lr_functions->set_view_lotus(
                    value = if_salv_c_bool_sap=>false ).

* customer defined function:
* display occupied seats columns most left
* and highlight them
*  IF pa_cont = 'X'.
*    l_icon = icon_insert_row.
*    l_text = text-tot.
*    l_tooltip = text-ttt.
*
*    TRY.
*        CALL METHOD lr_functions->add_function
*          EXPORTING
*            name     = 'REORDER'
*            icon     = l_icon
*            text     = l_text
*            tooltip  = l_tooltip
*     position = if_salv_c_function_position=>right_of_salv_functions.
*      CATCH cx_salv_existing   INTO l_except1.
*        l_text1 = l_except1->get_text( ).
*        MESSAGE i000 WITH l_text1.
*        LEAVE LIST-PROCESSING.
*      CATCH cx_salv_wrong_call INTO l_except2.
*        l_text1 = l_except2->get_text( ).
*        MESSAGE i000 WITH l_text1.
*        LEAVE LIST-PROCESSING.
*    ENDTRY.
*  ENDIF.
ENDFORM. " sub_set_functions

*&------------------------------------------------
*& Form sub_set_events
*&------------------------------------------------
* text
*-------------------------------------------------
* -->P_ALV text
*-------------------------------------------------
FORM sub_set_events USING p_alv TYPE REF TO cl_salv_table.
  DATA: lr_event TYPE REF TO cl_salv_events_table.
* get the EVENT object
  lr_event = p_alv->get_event( ).
  SET HANDLER :
  lcl_handler=>on_added_function FOR lr_event,
  lcl_handler=>on_double_click   FOR lr_event,
  lcl_handler=>on_link_click     FOR lr_event.
ENDFORM. " sub_set_events

*&------------------------------------------------
*& Form sub_set_header
*&------------------------------------------------
* -->P_ALV text
*-------------------------------------------------
FORM sub_set_header
USING p_alv TYPE REF TO cl_salv_table.
  DATA: lr_grid TYPE REF TO cl_salv_form_layout_grid.
* 1st step: create the grid object
  CREATE OBJECT lr_grid.
* 2nd step: add some text items
  lr_grid->create_header_information( row = 1  column = 1
                         text = 'Flight List Grp ##'(fll) ).
  lr_grid->create_text( row = 2  column = 1
                         text = 'Please check utilization'(uti) ).
* 3rd step: declare grid as header of list
  p_alv->set_top_of_list( value = lr_grid ).
ENDFORM. " sub_set_header

*&---------------------------------
*& Module STATUS_0100 OUTPUT
*&---------------------------------
* text
*----------------------------------
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SALV_TABLE_STANDARD'.
  SET TITLEBAR 'T100'.
ENDMODULE. " STATUS_0100 OUTPUT
*&-------------------------------------
*& Module create_control OUTPUT
*&-------------------------------------
* text
*--------------------------------------
MODULE create_control OUTPUT.
  IF vref_cont IS NOT BOUND.
* create container control
* and link it to the dynpro
    CREATE OBJECT vref_cont
    EXPORTING
      container_name = 'MY_CONTAINER'
    EXCEPTIONS
      OTHERS = 1.

    IF sy-subrc <> 0.
      MESSAGE e000 WITH 'Error when creating the container object'.
    ENDIF.
* create ALV and
* link it to the container control
    TRY.
        cl_salv_table=>factory(
        EXPORTING
          r_container = vref_cont
        IMPORTING
          r_salv_table = vref_alv
        CHANGING
          t_table = i_sflight ).
      CATCH cx_salv_msg INTO oref_error.
        l_text_alv_e = oref_error->get_text( ).
        MESSAGE i000 WITH l_text_alv_e.
        LEAVE LIST-PROCESSING.
    ENDTRY.
* display ALV
    vref_alv->display( ).
  ENDIF.
ENDMODULE. " create_control OUTPUT

*&--------------------------------------
*& Module USER_COMMAND_0100 INPUT
*&--------------------------------------
* text
*---------------------------------------
MODULE user_command_0100 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
      SET SCREEN 0.
  ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*&      Module  exit  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE exit INPUT.
  SET SCREEN 0.
ENDMODULE.                 " exit  INPUT

former_member188685
Active Contributor
0 Kudos

Did you check this Ravikumar Blog...

If not Check it once.

0 Kudos

No not a good idea, Don't want to implement a BADI for converting ALV grid to List display..

any other idea please.

any simple layout parameter change to display list...

Cheers,

Abhishek...

0 Kudos

No not a good idea, Don't want to implement a BADI for converting ALV grid to List display..

any other idea please.

any simple layout parameter change to display list...

Cheers,

Abhishek...

Former Member
0 Kudos

Hi,

Try this..

do this in the PBO..

sy-ucomm = '&PRINT_BACK_PREVIEW'.

  • G_GRID is your object for the class CL_GUI_ALV_GRID

CALL METHOD g_grid->fcode_bouncer

.

Thanks

Naren

0 Kudos

Narendran,

You are champ. It works...

Thanks,

Abhishek.