2013 Sep 02 5:09 AM
Hello Experts ,
I have a requirement where in an alv grid display the user should be able to CHECK a block of records having the same value .
Please refer the sketch of the proposed screen below:
Scenario :
All the data will be displayed initially with blank Reference No. field ;
When the user clicks on a certain button a reference no is generated on the screen for a bunch of records;
Multiple records can have the same reference no.
So, when the reference no. is generated the user must be able to CHECK one reference no. rather than checking every record with same reference no.
Is this possible?
If yes then kindly answer ....
ORDER DETAILS | |||||||||
Mark | Reference No. | Brand Code | Dealer Code | Dealer Name | Dealer Location | Zone | LSP | Total | |
R0001 | SCROLL BAR | ||||||||
√ | R0002 | ||||||||
R0003 | |||||||||
R0004 | |||||||||
R0005 | |||||||||
R0006 | |||||||||
R0007 | |||||||||
R0008 | |||||||||
R0009 | |||||||||
R0010 | |||||||||
SCROLL BAR |
Regards,
Jay Kamdar.
2013 Sep 02 5:38 AM
Hi Jay,
U can try the below logic.
When a Mark field is checked for one reference no. entry on the ALV grid display, write a user command event handler.
in that handler form the logic could be : loop at the internal table used to display in the grid where the MARK field is checked, if so store the reference no. of the row. then LOOP again the same table with same reference no. but for which MARK field is not checked, inside the loop , move 'X' to MARK field.
EX: Below is the snippet
FORM user_command USING r_ucomm LIKE sy-ucomm
REFRESH : it_data1.
CASE r_ucomm.
WHEN 'CHECK'.
IF alv_list IS NOT INITIAL.
LOOP AT it_data INTO wa_data WHERE mark = 'X'.
r_refno = wa_data-refno.
LOOP AT it_data INTO wa_data2 WHERE refno = r_refno and MARK NE 'X'.
wa_data2-mark = 'X'.
MODIFY it_data INDEX sy-tabix FROM wa_data2.
ENDLOOP.
ENDLOOP.
2013 Sep 02 5:38 AM
Hi Jay,
U can try the below logic.
When a Mark field is checked for one reference no. entry on the ALV grid display, write a user command event handler.
in that handler form the logic could be : loop at the internal table used to display in the grid where the MARK field is checked, if so store the reference no. of the row. then LOOP again the same table with same reference no. but for which MARK field is not checked, inside the loop , move 'X' to MARK field.
EX: Below is the snippet
FORM user_command USING r_ucomm LIKE sy-ucomm
REFRESH : it_data1.
CASE r_ucomm.
WHEN 'CHECK'.
IF alv_list IS NOT INITIAL.
LOOP AT it_data INTO wa_data WHERE mark = 'X'.
r_refno = wa_data-refno.
LOOP AT it_data INTO wa_data2 WHERE refno = r_refno and MARK NE 'X'.
wa_data2-mark = 'X'.
MODIFY it_data INDEX sy-tabix FROM wa_data2.
ENDLOOP.
ENDLOOP.
2013 Sep 02 10:55 AM
2013 Sep 02 6:41 AM
First add a row selector or row selection button into your ALV.
You can process the selected rows in the callback user command subroutine.
In that loop through the table to find the matching reference of the selected row and then mark the matching ones as selected.
2013 Sep 02 7:25 AM
Hi,
if suppose your having one ref.no three time (R0001,R0001,R0001) so if you selected one ref.no then inside system has to be consider has 3 line times.
Means these 3 line items data should be present in the ALV Table(means which table your display as a final)
so then after use AT User command command like this.
FORM user_command USING r_ucomm LIKE sy-ucomm
sel_field like slis_selfield.
slis_selfield -- this one contains the fields data based on this you can mark the remaining 2 line items .
loop it_final into wa_final where field = sel_field-value. "field.
if wa_final-mark ne 'X'.
wa_final-mark = 'X'.
modify it_final from wa_final transporting mark.
endloop.
pls check.
thanks in advance,
krishna
2013 Sep 02 7:40 AM
First to handle event with checkbox, set hotspot in the field catalog for checkbox field.
CLEAR gs_fcat.
gs_fcat-fieldname = 'CHECKBOX'.
gs_fcat-seltext_m = 'Select'.
gs_fcat-checkbox = 'X'.
gs_fcat-hotspot = 'X'.
APPEND gs_fcat TO gt_fcat.
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_scarr.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
case r_ucomm.
when '&IC1'.
DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
"Reference to the ALV grid object
DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lr_grid.
CALL METHOD lr_grid->check_changed_data.
* Write the code to set checkbox = 'X' for all the records with same ref no. You can use the logic Shruti suggested.
* loop at the alv data table, if check box = 'X', set the checkbox of all records with same reference number to 'X'
"Calling method to refresh the data in the ALV
CALL METHOD lr_grid->refresh_table_display.
endcase.
ENDFORM. "user_command
2013 Sep 02 10:55 AM
2013 Oct 01 5:21 AM
Hello,
I am using the method set_table_for_first_display of class cl_gui_alv_grid to display the ALV grid in the screen,
how will i get the user command when the user marks a record ?
Please help .
2013 Oct 01 6:38 AM
Here the user command is triggered by the hotspot attribute of the checkbox.
So if you are using the OOPs method, just handle the hotspot click event.
METHODS: handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid.
Check this code.
http://wiki.scn.sap.com/wiki/display/Snippets/How+to+Add+button+and+hotspot+in+ALV+OOPS
2013 Oct 01 7:00 AM
2024 Mar 14 7:44 PM
Hii Krishna,
I Have written same logic to get select record but my program is going to dump after CALL METHOD ref_grid->CHECK_CHANGED_DATA.
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF ref_grid IS BOUND.
CALL METHOD ref_grid->CHECK_CHANGED_DATA.
ENDIF.
This Logic i have written can you give my suggestion on this.
2013 Sep 02 8:32 AM
Hi jay ,
To achieve the above requirement three simple steps :
1 ) To achieve the check all option place buttons in application toolbar using menu painter and name it accordingly like select all / deselect all .
2 ) For selecting particular reference number you can use filter option .By default it would available in the normal ALV Grid display application tool bar .
3 ) use this function module to get the value in the grid display after filtering process REUSE_ALV_GRID_LAYOUT_INFO_GET.
Steps to use the report after development .
1 ) Normal alv grid list display with all refernece numbers . (ie inital output screen).
2 )Use the filter option in the application toolbar to filter particular reference document alone .
By the required reference document alone selected .
3 ) The using the REUSE_ALV_GRID_LAYOUT_INFO_GET function module you could get the values in the grid list display after filtering .
4) Then you can use the select all option to select all / select particular records based on the user requirement .
attached a simple screen shot for reference
Feel free to contact for any clarifications.
Regards,
Sanjith N
2013 Sep 02 10:56 AM
Thanks but the requirement is different than your suggestion .
2013 Sep 02 9:09 AM
Hi Jay,
Display the reference-id as hotspot ,Define a handler for hot spot link in such a way that all the check box with the same reference-id will get automatically get selected.
I hope this will resolve your issue.
Thanks & Regards,
Krishna N
2013 Sep 02 10:58 AM