Skip to Content
0
Former Member
Oct 06, 2006 at 03:45 AM

Re: ALV Grid Control

30 Views

Dear Experts,

Pls. Find the following code.My requirement is i have to select Multiple rows without pressing 'Ctrl' Button.I tried with all options of SEL_MODE = 'A','B','C','D' But no luck.

pls. help on this how to achieve this functionality.

REPORT ysflight .

DATA ok_code LIKE sy-ucomm.

DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.

DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.

DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.

DATA gt_fieldcat TYPE lvc_t_fcat.

DATA gs_layout TYPE lvc_s_layo.

DATA BEGIN OF gt_list OCCURS 0.

INCLUDE STRUCTURE sflight.

DATA END OF gt_list.

DATA BEGIN OF gt_temp_list OCCURS 0.

INCLUDE STRUCTURE sflight.

DATA END OF gt_temp_list.

DATA lt_selected_rows TYPE lvc_t_roid.

DATA ls_selected_row TYPE lvc_s_roid.

SELECT * FROM sflight INTO TABLE gt_list.

CALL SCREEN 100.

----


  • MODULE DISPLAY_ALV OUTPUT

----


*

----


MODULE display_alv OUTPUT.

PERFORM display_alv.

ENDMODULE. "DISPLAY_ALV OUTPUT

&----


*& Form DISPLAY_ALV

&----


  • text

----


FORM display_alv.

SET PF-STATUS 'STAT'.

IF gr_alvgrid IS INITIAL.

CREATE OBJECT gr_ccontainer

EXPORTING

container_name = gc_custom_control_name

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CREATE OBJECT gr_alvgrid

EXPORTING

i_parent = gr_ccontainer

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

PERFORM prepare_field_catalog CHANGING gt_fieldcat.

PERFORM prepare_layout CHANGING gs_layout.

CALL METHOD gr_alvgrid->set_table_for_first_display

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

is_layout = gs_layout

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

it_outtab = gt_list[]

it_fieldcatalog = gt_fieldcat

  • IT_SORT =

  • IT_FILTER =

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

ENDFORM. "DISPLAY_ALV

&----


*& Form prepare_FIELD_CATALOG

&----


  • text

----


  • -->PT_FIELDCAT text

----


FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.

DATA ls_fcat TYPE lvc_s_fcat.

ls_fcat-fieldname = 'CARRID'.

ls_fcat-inttype = 'C'.

ls_fcat-outputlen = '3'.

ls_fcat-coltext = 'Carrier ID'.

ls_fcat-seltext = 'Carrier ID'.

APPEND ls_fcat TO pt_fieldcat.

CLEAR ls_fcat.

ls_fcat-fieldname = 'CONNID'.

ls_fcat-ref_table = 'SFLIGHT'.

ls_fcat-ref_table = 'CONNID'.

ls_fcat-outputlen = '3'.

ls_fcat-coltext = 'Connection ID'.

ls_fcat-seltext = 'Connection ID'.

APPEND ls_fcat TO pt_fieldcat.

ENDFORM. "prepare_FIELD_CATALOG

&----


*& Form prepare_layout

&----


  • text

----


  • -->PS_LAYOUT text

----


FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.

ps_layout-sel_mode = 'D'.

ENDFORM. "prepare_layout

*&----


*& Module USER_COMMAND_0100 INPUT

*&----


  • text

*----


MODULE user_command_0100 INPUT.

CASE ok_code.

WHEN 'BACK'.

LEAVE PROGRAM.

WHEN 'EDIT' .

CALL METHOD gr_alvgrid->get_selected_rows

IMPORTING

et_row_no = lt_selected_rows.

set pf-status 'STAT1'.

LOOP AT lt_selected_rows INTO ls_selected_row.

READ TABLE gt_list INDEX ls_selected_row-row_id.

IF sy-subrc EQ 0.

gt_temp_list = gt_list.

APPEND gt_temp_list.

LEAVE TO LIST-PROCESSING.

WRITE: / gt_temp_list-carrid ,gt_temp_list-connid input on.

ENDIF.

ENDLOOP.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

at user-command.

case sy-ucomm.

WHEN 'BACK'.

leave program.

endcase.

LEAVE PROGRAM.