03-27-2015 9:30 AM
Hi Dear Experts,
Thank you for your attention first, Thank you. I put the checkbox at the first colunm of the ALV output. Now my requirement is that with the stanrdard tool bar button 'Select All', when we click the select all, all the records' checkbox will be flagged. Now when I click the button, all the records will be selected, instead of checkbox be flagged.
Yes, I know we can meet this requirment by adding a new button and modify the output table and refresh the ALV. But I want to know if the standard function can do that if we set some settings in the filedcatlog or layout attributes.
BTW, I tried in alv block list, it works, you can test using demo reprot BALVBT01. But I want to do it using reuse_alv_grid_display.
Thanks
Jay
03-28-2015 10:09 AM
Hi Jay,
I doubt that you can achieve this as easily in case of grid, as you are able to do it in list display. (I think this because with the possibility of selecting rows in a grid the check box based technique lost its relevance). So you are left with workaround solutions.
I can think of two ways to do this without additional buttons in the toolbar (so it will look like from user point of view that it is the standard behavior):
BR,
Gabor
03-27-2015 9:37 AM
Hi,
For your refrence please check program BCALV_EDIT_05.
module pai input.
save_ok = ok_code.
clear ok_code.
case save_ok.
when 'EXIT'.
perform exit_program.
when 'SELECT'.
perform select_all_entries changing gt_outtab[].
when 'DESELECT'.
perform deselect_all_entries changing gt_outtab[].
when 'RESET'.
perform reset_selected_entries changing gt_outtab[].
when 'SWITCH'.
perform switch_activation changing gt_outtab[].
endcase.
endmodule.
03-28-2015 7:52 AM
Hi Choubey,
It is PAI event, but I'n wandor if the standard function can realize the requirement.
BR
Jay
03-28-2015 6:20 AM
Hi Fan,
IN LAYOUT U GET 2 FIELD
BOX_FIELDNAME | ||
BOX_TABNAME |
IN BOX_FIELDNAME PASS A FIELD OF FINAL DISPLAY TABLE HAVING 1CHAR AND TABNAME THE TABLE NAME.
DEMO CODE
sel is single char field in gt_final
GS_LAYOUT-BOX_FIELDNAME = 'SEL'
GS_LAYOUT-BOX_TABNAME = 'gt_final'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
it_fieldcat = gt_fcat
i_save = 'A'
is_variant = gs_variant
is_layout = gs_layout
* IT_EVENTS = IT_EVENTS[]
tables
t_outtab = gt_final
exceptions
program_error = 1
others = 2.
Hope this will help you
03-28-2015 7:55 AM
Hi Choubey,
I coded as you are, but when I click the button to select all, just the whole line of the ALV table be selected, not with checkbox flagged. So sad, I'm not sure if we can reallize that.
BR
Jay
03-28-2015 8:08 AM
Hi,
We did a similar requirement recently. Hopefully, this will be helpful.
* ASSIGN THE FUNCTION CODE TO VARIABLE R_UCOMM
R_UCOMM = SY-UCOMM.
CASE R_UCOMM.
WHEN '&SEL_ALL'.
* TO SELECT ALL THE RECORDS DISPLAYED IN ALV GRID
LOOP AT IT_WEIGH INTO WA_WEIGH.
WA_WEIGH-V_CHECK = 'X'.
MODIFY IT_WEIGH FROM WA_WEIGH TRANSPORTING V_CHECK.
CLEAR WA_WEIGH.
ENDLOOP.
* REFRESH THE ALV GRID OUTPUT FROM INTERNAL TABLE
RS_SELFIELD-REFRESH = C_CHECK.
WHEN 'DESEL_ALL'.
* TO DESELECT ALL THE RECORDS DISPLAYED IN ALV GRID
LOOP AT IT_WEIGH INTO WA_WEIGH.
WA_WEIGH-V_CHECK = ' '.
MODIFY IT_WEIGH FROM WA_WEIGH TRANSPORTING V_CHECK.
CLEAR WA_WEIGH.
ENDLOOP.
* REFRESH THE ALV GRID OUTPUT FROM INTERNAL TABLE
RS_SELFIELD-REFRESH = C_CHECK.
Humble Regards,
Abhijeet
03-28-2015 8:13 AM
Hi Gupta,
Thank you for your help. But it is custom PAI event, I mean, I don't know to write codes to modify the output table. If we can use standard button to realize it?
BR
Jay
03-28-2015 10:09 AM
Hi Jay,
I doubt that you can achieve this as easily in case of grid, as you are able to do it in list display. (I think this because with the possibility of selecting rows in a grid the check box based technique lost its relevance). So you are left with workaround solutions.
I can think of two ways to do this without additional buttons in the toolbar (so it will look like from user point of view that it is the standard behavior):
BR,
Gabor
03-28-2015 1:24 PM
Hi Gabor,
Thank you for your reply. Here I encounter another issue.
I add the addtional button select/deselect and write the logic to modify the output table. As I click select all button, the whole row of all the records will be selected, while with all the checkbox flagged.
The next step, with another addtional button 'Download file with checkbox flagged', if I want to excludd some of the records, I will unfalg the correspoding checkboxes, and click the download button, its logic will download records with these flagged, I found that, in debugging, the whole output table's filed 'Checkbox' is initial again!
BR
Jay
03-28-2015 3:13 PM
Hi Jay,
1. I tried my second suggestion in my demo system and it works fine for me. What I've done was to simply copy the GUI status STANDARD_FULLSCREEN from function group SLV_FULLSCREEN, deleting the select/deselect buttons, and create new ones with the same icons and without the leading '&' character in function code, and it is working perfectly, without selecting the rows. My USER_COMMAND now looks like:
FORM user_command USING r_ucomm TYPE sy-ucomm
CHANGING rs_selfield TYPE slis_selfield.
FIELD-SYMBOLS:
<gs_data> LIKE LINE OF gt_data.
CASE r_ucomm.
WHEN 'ALL'.
LOOP AT gt_data ASSIGNING <gs_data>.
<gs_data>-check = abap_true.
ENDLOOP.
WHEN 'SAL'.
LOOP AT gt_data ASSIGNING <gs_data>.
<gs_data>-check = abap_false.
ENDLOOP.
ENDCASE.
rs_selfield-refresh = abap_true.
rs_selfield-row_stable = abap_true.
ENDFORM.
2. This is caused by the fact, that the modifications you make in the grid (modification of checkboxes) only exists in front-end (check out the documenation of control framework), and data transfer won't occur by pushing a button on the application toolbar (triggering PAI).
In order to change this behavior you have to use function module parameter I_GRID_SETTINGS, field EDT_CLL_CB setting it to 'X'. It will trigger data transfer between the grid and the application every time you edit a cell.
BR,
Gabor
03-28-2015 3:47 PM
Hi Gabor,
you said you achieve that? I did as you said, but fialed again. You said, the row did not choose, just the checkbox? But me not,,,
And when I choose all, then I unflaged some of them, then I click download button, it get nothing, which means, the flag set to be inital to all the records.... I don;t know what happend.... Here is my main codes, could you please show me if there is anything wrong, Thank you so much,
FORM display_data.
DATA: ls_alv_layout TYPE slis_layout_alv,
lt_alv_events TYPE slis_t_event,
ls_alv_event TYPE slis_alv_event,
lt_alv_sort TYPE slis_t_sortinfo_alv,
ls_alv_exit_caused_by_user TYPE slis_exit_by_user,
ls_alv_print TYPE slis_print_alv,
lv_alv_formname TYPE slis_formname,
ls_is_variant TYPE disvariant,
is_grid_settings TYPE lvc_s_glay.
ls_alv_layout-colwidth_optimize = 'X'.
ls_alv_layout-zebra = 'X'.
ls_alv_layout-box_fieldname = 'CHECKBOX'.
is_grid_settings-edt_cll_cb = gc_x.
CLEAR: gt_fieldcat[], lt_alv_events[], ls_alv_event.
* build alv event
ls_alv_event-name = 'END_OF_LIST'.
ls_alv_event-form = 'BUILD_ALV_FOOTER'.
APPEND ls_alv_event TO lt_alv_events.
PERFORM field_cat.
**** Display the report to the user
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'PF_STATUS_SET'
is_layout = ls_alv_layout
it_fieldcat = gt_fieldcat[]
it_sort = lt_alv_sort[]
it_events = lt_alv_events[]
i_save = 'A'
is_variant = ls_is_variant
is_print = ls_alv_print
i_grid_settings = is_grid_settings
IMPORTING
es_exit_caused_by_user = ls_alv_exit_caused_by_user
TABLES
t_outtab = gt_output
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
FORM pf_status_set USING extab TYPE slis_t_extab.
SET PF-STATUS '0200' EXCLUDING extab.
ENDFORM.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: lv_fullpath TYPE string.
DATA: lv_error_message TYPE string.
CASE r_ucomm.
WHEN '&ZALL'.
PERFORM modify_output USING gc_x.
rs_selfield-refresh = gc_x.
rs_selfield-row_stable = gc_x.
WHEN '&ZSAL'.
PERFORM modify_output USING ' '.
rs_selfield-refresh = gc_x.
rs_selfield-row_stable = gc_x.
WHEN '&ZDWN'.
PERFORM prepare_file.
IF gt_download[] IS INITIAL.
lv_error_message = text-025.
MESSAGE i013 WITH lv_error_message.
ELSE.
PERFORM get_file_path USING lv_fullpath.
PERFORM down_file USING lv_fullpath.
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDFORM.
FORM modify_output USING p_checkbox.
FIELD-SYMBOLS: <ls_output> TYPE t_output.
LOOP AT gt_output ASSIGNING <ls_output>.
<ls_output>-checkbox = p_checkbox.
ENDLOOP.
ENDFORM.
FORM prepare_file.
DATA: lv_error_message TYPE string.
DATA: ls_output TYPE t_output.
DATA: ls_download TYPE t_download.
CLEAR gt_download.
* CALL METHOD go_ref->check_changed_data.
LOOP AT gt_output INTO ls_output WHERE checkbox = gc_x.
MOVE-CORRESPONDING ls_output TO ls_download.
APPEND ls_download TO gt_download.
ENDLOOP.
ENDFORM.
FORM field_cat.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
CLEAR: ls_fieldcat.
CLEAR: gt_fieldcat.
ls_fieldcat-col_pos = 1.
ls_fieldcat-fieldname = 'CHECKBOX'.
ls_fieldcat-checkbox = gc_x.
ls_fieldcat-edit = gc_x.
* ls_fieldcat-input = gc_x.
ls_fieldcat-outputlen = '1'.
APPEND ls_fieldcat TO gt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = 2.
ls_fieldcat-fieldname = 'DOCU_NO'.
ls_fieldcat-seltext_l = text-003.
ls_fieldcat-ref_tabname = 'GT_OUTPUT'.
APPEND ls_fieldcat TO gt_fieldcat.
ENDFORM.
03-28-2015 6:04 PM
Hi Jay,
I tried your code and didn't want to believe my eyes, it worked as you described.
I managed to realize that the harmful statement is:
ls_alv_layout-box_fieldname = 'CHECKBOX'.
Looks like it not just useless but harmful in case of GRID display.
Remove this line, and it should work!
Gabor
03-29-2015 3:19 AM
Hi Gabor
Sorry for the late reply. I tried your suggestion, it works! How do you find that, debug? I mean you are really awful! Thank you so much!
BR
Jay
03-30-2015 7:50 PM
Hi Jay,
All I did was to start to comment out the parameters line by line from FM REUSE_ALV_GRID_DISPLAY and check whether its behavior has been corrected. It didn't take much time to realize variable ls_layout was causing the trouble.
BR,
Gabor