Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Selecting multiple line items with checkbox in ALV output

Hi experts,

I am developing an ALV report using reuse_alv_grid_display where the user wants the ability to select individual line items with a chekbox in the output. Once he has done this he clicks on a custom button the toolbar after which a BDC is triggered.

I have already copied the standard toolbar and customized it by adding the buttons on the toolbar. However now when i select a single line item using the checkbox it works fine. However, if i select multiple line items (as per requirement) then it just takes the last selected line item into consideration. For ex: if i select line items 2 and 4, then only line item 4 is taken.

I cannot use the line select option on the far left of the ALV output as the user wants a checkbox.

I would appreciate any help on this.

Regards,

Ritwik

Former Member
replied

Ok.. this really is perplexing..

can you create a new program with the following code in your system and see if it runs.. If it does, you can compare with your program.

DATA: BEGIN OF itab OCCURS 0,

matnr TYPE mara-matnr,

ersda TYPE mara-ersda,

ernam TYPE mara-ernam,

laeda TYPE mara-laeda,

aenam TYPE mara-aenam,

matkl TYPE mara-matkl,

sel TYPE char01,

END OF itab.

DATA it_field TYPE slis_t_fieldcat_alv.

DATA wa TYPE slis_fieldcat_alv.

SELECT matnr

ersda ernam

laeda aenam

matkl UP TO 10 ROWS FROM mara INTO TABLE itab.

CLEAR wa.

wa-fieldname = 'MATNR'.

APPEND wa TO it_field.

CLEAR wa.

wa-fieldname = 'ERSDA'.

APPEND wa TO it_field.

CLEAR wa.

wa-fieldname = 'ERNAM'.

APPEND wa TO it_field.

CLEAR wa.

wa-fieldname = 'LAEDA'.

APPEND wa TO it_field.

CLEAR wa.

wa-fieldname = 'AENAM'.

APPEND wa TO it_field.

CLEAR wa.

wa-fieldname = 'MATKL'.

APPEND wa TO it_field.

CLEAR wa.

wa-fieldname = 'SEL'.

wa-checkbox = 'X'.

wa-edit = 'X'.

APPEND wa TO it_field.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_user_command = 'USER'

it_fieldcat = it_field

TABLES

t_outtab = itab.

&----


*& Form user_command

&----


  • text

----


  • -->UCOMM text

  • -->SELFIELD text

----


FORM user USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

DATA: lv_ucomm TYPE sy-ucomm.

lv_ucomm = ucomm.

DATA: o_object TYPE REF TO cl_gui_alv_grid.

  • CASE lv_ucomm.

  • WHEN '&APPROVE'.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = o_object.

IF o_object IS NOT INITIAL.

CALL METHOD o_object->check_changed_data.

ENDIF.

BREAK-POINT.

endform.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question