Application Development and Automation 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: 
Read only

Get ALV checkboxed rows

Former Member
0 Likes
960

Hello everyone,

I'm using FM "REUSE_ALV..." to display an ALV grid. I added a column checkbox, that i need for processing the chosen lines that are checked. The problem is when i click on the button designed to do that processing, the internal table still comes with checkbox fields empty.

I searched through the forum and i know that if i use the "save" button (sy-ucomm = "&DATA_SAVE") the internal table is immediatly refreshed with the new values for the checkboxes, but the same doesn´t happen to other buttons. There's a way: double-clicking, the ALV refreshes and the corresponding internal table refreshes with it.

But i don't want the user to double-click and then click "process" button. It should be unnecessary to do that.

How can i solve the problem ? How can i get the filled checkboxes immediatly in the internal table, in the form USER-COMMAND i have to control sy-ucomm.

Here is a sample of what i have till now:

Internal Table:

DATA: BEGIN OF gs_outtab,

sel(1), "Checkbox

bukrs LIKE ztable01-bukrs, "Company

butxt LIKE t001-butxt, "Company Name

(...)

DATA: END OF gs_outtab.

DATA: gt_outtab LIKE gs_outtab OCCURS 0 WITH HEADER LINE.

Fieldcatalog:

FORM fieldcat_init USING rt_fieldcat TYPE slis_t_fieldcat_alv.

DATA: ls_fieldcat TYPE slis_fieldcat_alv.

  • Field Catalog

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'SEL'.

ls_fieldcat-tabname = 'GT_OUTTAB'.

ls_fieldcat-checkbox = 'X'.

ls_fieldcat-emphasize = 'X'.

ls_fieldcat-edit = 'X'.

ls_fieldcat-outputlen = '6'.

APPEND ls_fieldcat TO rt_fieldcat.

User-command:

FORM user_command USING r_ucomm TYPE sy-ucomm

rs_selfield TYPE slis_selfield.

DATA: idx TYPE i.

rs_selfield-refresh = 'X'.

rs_selfield-col_stable = 'X'.

rs_selfield-row_stable = 'X'.

CLEAR gt_outtab.

READ TABLE gt_outtab INDEX rs_selfield-tabindex.

CLEAR tab_index.

tab_index = rs_selfield-tabindex.

IF r_ucomm = '&IC1'.

CASE rs_selfield-fieldname.

WHEN 'LIFNR'.

SET PARAMETER ID 'LIF' FIELD gt_outtab-lifnr.

SET PARAMETER ID 'BUK' FIELD gt_outtab-bukrs.

CALL TRANSACTION 'FK03'.

ENDCASE.

ELSEIF r_ucomm = '&LANC'.

LOOP AT gt_outtab WHERE NOT sel IS INITIAL. <--- The program neves catches this condition

ENDLOOP.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
775

Data: ref1 type ref to cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = ref1.

call method ref1->check_changed_data.

loop at gt_output where sel = 'X'.

.....

......

.....

endloop.

4 REPLIES 4
Read only

Former Member
0 Likes
776

Data: ref1 type ref to cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = ref1.

call method ref1->check_changed_data.

loop at gt_output where sel = 'X'.

.....

......

.....

endloop.

Read only

former_member194669
Active Contributor
0 Likes
775

Hi,

Change the user command lines


User-command:

FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.

  data p_ref1 type ref to cl_gui_alv_grid.      " Check these lines 
  call function 'GET_GLOBALS_FROM_SLVC_FULLSCR' " 
    importing                                   "
      e_grid = p_ref1.                          "
  call method p_ref1->check_changed_data.       " 



DATA: idx TYPE i.

rs_selfield-refresh = 'X'.
rs_selfield-col_stable = 'X'.
rs_selfield-row_stable = 'X'.

CLEAR gt_outtab.
READ TABLE gt_outtab INDEX rs_selfield-tabindex.

CLEAR tab_index.
tab_index = rs_selfield-tabindex.

IF r_ucomm = '&IC1'.
CASE rs_selfield-fieldname.
WHEN 'LIFNR'.
SET PARAMETER ID 'LIF' FIELD gt_outtab-lifnr.
SET PARAMETER ID 'BUK' FIELD gt_outtab-bukrs.
CALL TRANSACTION 'FK03'.
ENDCASE.
ELSEIF r_ucomm = '&LANC'.

LOOP AT gt_outtab WHERE NOT sel IS INITIAL. <--- The program neves catches this condition
ENDLOOP. 

ENDIF. 

aRs

Read only

Pawan_Kesari
Active Contributor
0 Likes
775

I think you forgot to fill these two field in ALV Layout

slis_layout_alv-box_fieldname

slis_layout_alv-box_tabname

fill them with fieldname of checkbox and internal table name

Read only

0 Likes
775

Thank you. Problem solved.