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: 

selecting records on custom controls using checkboxes

Former Member
0 Kudos

well, it seems I didn't find the materials required to accomplish or complete my program.


I've created a screen holding a custom control to show table which i have done it successfully but how to show checkboxes for each record or line and reuse the selected lines on the same custom control when pressing a push-button?

I would be thankful if i get your recommendations.

1 ACCEPTED SOLUTION

former_member213275
Contributor
0 Kudos

Hi,

Add checkbox to fieldcatalog.

code after CALL METHOD alv_grid1->set_table_for_first_display.

 

CALL METHOD alv_grid1->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_modified

EXCEPTIONS

error = 1

OTHERS = 2.

Then add this code in DISPLAY button case.

 

WHEN 'DISPLAY'.

 

* CALL METHOD alv_grid1->get_selected_rows

* IMPORTING

* et_row_no = it_rows[].

*

* LOOP AT it_rows INTO wa_rows.

*

* READ TABLE it_mara INTO wa_mara INDEX wa_rows-row_id.

*

* IF sy-subrc = 0.

* SELECT SINGLE matnr werks dismm FROM marc INTO wa_marc

* WHERE matnr = wa_mara-matnr.

* IF sy-subrc = 0.

* APPEND wa_marc TO it_marc.

* CLEAR wa_marc.

* ENDIF.

* ENDIF.

* ENDLOOP.

 

LOOP AT it_mara INTO wa_mara WHERE check EQ 'X'.

SELECT SINGLE matnr werks dismm FROM marc INTO wa_marc

WHERE matnr = wa_mara-matnr.

IF sy-subrc = 0.

APPEND wa_marc TO it_marc.

CLEAR wa_marc.

ENDIF.

ENDLOOP.

IF it_marc IS INITIAL.

MESSAGE 'THERE IS NO PLANT RECORDS AVAILABLE FOR THE MATERIAL' TYPE 'E'.

ENDIF.

CALL METHOD alv_grid2->refresh_table_display.

Srikanth.

4 REPLIES 4

former_member213275
Contributor
0 Kudos

Hi,

Add checkbox to fieldcatalog.

code after CALL METHOD alv_grid1->set_table_for_first_display.

 

CALL METHOD alv_grid1->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_modified

EXCEPTIONS

error = 1

OTHERS = 2.

Then add this code in DISPLAY button case.

 

WHEN 'DISPLAY'.

 

* CALL METHOD alv_grid1->get_selected_rows

* IMPORTING

* et_row_no = it_rows[].

*

* LOOP AT it_rows INTO wa_rows.

*

* READ TABLE it_mara INTO wa_mara INDEX wa_rows-row_id.

*

* IF sy-subrc = 0.

* SELECT SINGLE matnr werks dismm FROM marc INTO wa_marc

* WHERE matnr = wa_mara-matnr.

* IF sy-subrc = 0.

* APPEND wa_marc TO it_marc.

* CLEAR wa_marc.

* ENDIF.

* ENDIF.

* ENDLOOP.

 

LOOP AT it_mara INTO wa_mara WHERE check EQ 'X'.

SELECT SINGLE matnr werks dismm FROM marc INTO wa_marc

WHERE matnr = wa_mara-matnr.

IF sy-subrc = 0.

APPEND wa_marc TO it_marc.

CLEAR wa_marc.

ENDIF.

ENDLOOP.

IF it_marc IS INITIAL.

MESSAGE 'THERE IS NO PLANT RECORDS AVAILABLE FOR THE MATERIAL' TYPE 'E'.

ENDIF.

CALL METHOD alv_grid2->refresh_table_display.

Srikanth.

former_member188827
Active Contributor
0 Kudos

Please check the following link:

http://scn.sap.com/message/14053533

Regards

former_member184569
Active Contributor
0 Kudos

Hi,

First declare the first field in your catalog as a check box.

  CLEAR gs_fcat.

   gs_fcat-fieldname  = 'CHECKBOX'.

   gs_fcat-seltext_m  = 'Select'.

   gs_fcat-checkbox  = 'X'.

   gs_fcat-edit     = 'X'.

   gs_fcat-input        = 'X'.

   APPEND gs_fcat TO gt_fcat.

Second, in the user command module, capture the button press event, save the edited grid and do the required coding.

   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

     EXPORTING

       i_callback_program           = gv_repid

       i_callback_user_command = 'USER_COMMAND'

       is_layout                          = gs_layout

       it_fieldcat                         = gt_fcat

     TABLES

       t_outtab                           = gt_data   .

FORM user_command USING r_ucomm LIKE sy-ucomm

                         rs_selfield TYPE slis_selfield.

case r_ucomm.

when 'FCODE'.

* Save the data edited in the grid.

  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_data into wa_data.

            if checkbox = 'X'.

                     perform coding.

             endif.

endcase.

RS_SELFIELD-REFRESH = 'X'.

endform.

Former Member
0 Kudos

thank you all for helping i gotta try them n apply the fittest one for the program i'm building

thank u soooo much