Home > ABAP, ALV > ALV Tips – Select Line

ALV Tips – Select Line

December 30th, 2009 Leave a comment Go to comments

We can make one or several lines in ALV report selectable according to select mode set in layout structure.

Step 1. Define another field in the output table with type c length 1. This field will be used to record the select status of front end in the backend.

* Data to be displayed
DATA: BEGIN OF gt_data OCCURS 50,
        k(10),
        a TYPE int1,
        mark(1) type c,
      END OF gt_data.

Step 2. Set this field name ‘MARK’ to the attribute ‘box_fname’ in layout structure.

gs_layout-sel_mode = 'A'.  " set the selection mode
gs_layout-box_fname = 'MARK'.

When user choose one or several lines in the report and trigger event in the frontend, you can easily loop the output table and the field mark with value ‘X’ is those user selected.

loop at gtouttab.
  if gtouttab-mark = 'X'.
* add your action hereendif.
endloop.

Below is description about selection mode from SAP help.
http://help.sap.com/saphelp_nw04/helpdata/en/ef/a2e9eff88311d2b48d006094192fe3/content.htm

Selection modes for SEL_MODE

Value Mode Possible selections Comment
SPACE same as ‘B’ see ‘B’ Default setting
‘A’ Column and row selection(see graphic)
  • Multiple columns
  • Multiple rows
The user selects the rows through pushbuttons at the left border of the grid control.
‘B’ Simple selection, list box
  • Multiple columns
  • Multiple rows
‘C’ Multiple selection, list box
  • Multiple columns
  • Multiple rows
‘D’ Cell selection
  • Multiple columns
  • Multiple rows
  • Any cells
The user selects the rows through pushbuttons at the left border of the grid control.
  1. No comments yet.
  1. No trackbacks yet.