‎2011 Apr 13 4:36 PM
Hi,
Am using a FM HR_DISPLAY_BASIC_LIST to display results in an ALV grid . I want to select one are more records in the report to delete the selected records. I was not able to select more than one record at a time. Is there any way we can achive this.
Thanks,
Kumar.
‎2011 Apr 13 4:51 PM
‎2011 Apr 13 4:48 PM
Hi
before displaying your alv. try this
suppose you have table itab which is final table and select option s_vbeln.
and you want to check the values of field vbeln.
do this:
loop at itab into wa.
if wa-vbeln not in s_vbeln.
delete itab from wa.
modify itab.
endif.
endloop.
the above code will loop through the table and check the values of vbeln in select option s_vbeln and if there is not value in the s_vbeln then the value will be deleted.
thanks
LG
‎2011 Apr 13 4:57 PM
Hi Lalit,
My issue is different , i need to delete after the display of alv. Here i need to have an option to select one or more records.
Regards,
Kumar.
‎2011 Apr 13 4:51 PM
‎2011 Apr 13 5:00 PM
Hi Sandeep,
What can be passed to the lay_out option as the type is i. We lnow that 'SEL' can be passed in normal ALV GRID DISPLAY.
Thanks,
Kumar.
‎2011 Apr 13 8:08 PM
If i understood,
you can select more rows pressing CTRL Key
Edited by: alessandro spadoni on Apr 13, 2011 9:57 PM
‎2011 Apr 14 12:46 AM
1) Declare one field say 'SEL' in your final ALV table structure. This field 'SEL' will hold the records which you select in your ALV report.
TYPES: BEGIN OF ty_final,
sel, " Means one character
mandt TYPE mandt,
'
'
'
END of ty_final.
2) You do the needful to show your ALV Report
i.e.
Build field catalog
PERFORM f_build_fieldcatalog.
Build layout
PERFORM f_build_layout.
Display report
PERFORM f_display_alv_report.
3) Tell the layout that 'SEL' is the field name which will store which records you have selected (press Control for multiple row)
FORM f_build_layout .
k_gd_layout-box_fieldname = 'SEL'. " Set field name to store row selection
k_gd_layout-zebra = 'X'.
k_gd_layout-colwidth_optimize = 'X'.
ENDFORM.
4) In your ALV, call USER_COMMAND routine. In this routine you need to do whatever you want to do with the selected records.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'F_USER_COMMAND'
i_grid_title = 'Select the row(s) and click save button to clear the status'
is_layout = k_gd_layout
it_fieldcat = i_fieldcatalog[]
i_save = 'X'
TABLES
t_outtab = i_echo_request
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM f_user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Local data declaration
DATA: lk_update_data TYPE zot_echo_request.
Check function code
CASE r_ucomm.
WHEN '&DATA_SAVE'. " user presses SAVE
LOOP AT i_echo_request INTO k_echo_request
WHERE SEL EQ 'X'.
Do what you want to do with the selected rows
ENDLOOP.
SET PF-STATUS space. " This will call the Standard GUI
LEAVE TO LIST-PROCESSING. " In case you want show some report
ENDFORM.
Hope this should solve your issue. To select multiple records, press Control and then the records.
With Regards,
Raju
‎2011 Apr 14 9:15 AM
Hi,
I am using the below FM to display the grid. CRTL key is not working in this case to select multiple records.
CALL FUNCTION 'HR_DISPLAY_BASIC_LIST'
EXPORTING
basic_list_title = sy-title
file_name = 'trce'
head_line1 = text-a
foot_note1 = text-b
foot_note2 = text-c
dyn_pushbutton_text1 = text-d
dyn_pushbutton_text2 = text-e
current_report = report
list_level = 01
IMPORTING
return_code = return_code
TABLES
data_tab = ctab
fieldname_tab = fieldname
select_tab = sel
ERROR_TAB =
EXCEPTIONS
download_problem = 1
no_data_tab_entries = 2
table_mismatch = 3
print_problems = 4
OTHERS = 5.
Regards,
Kumar
‎2011 Apr 14 10:26 AM
‎2011 Apr 14 10:28 AM
Hi Kumar,
You can solve this issue like this.
when ever your ALV grid is having editable fields then a selection column appears as first column in the form of buttons on ur alv.
then u can select multiple rows.
In your field catalog make a field as editable.like
lwa_fldcat-edit = 'X'.
Then delete the seleted rows using delete key or delete row button on the alv tool bar.
and manage it programatically.
reply if any queries..
Regards,
Murthy.
‎2011 Apr 14 4:19 PM
Please pass the EXPORTING PARAMTER
no_alv_grid = 'X'.
This should solve your issue.
For reference use the following code:
TABLES:
marc.
DATA: BEGIN OF mtab_materials OCCURS 0,
matnr LIKE marc-matnr,
werks LIKE marc-werks,
pstat LIKE marc-pstat,
mmsta LIKE marc-mmsta,
END OF mtab_materials.
DATA: BEGIN OF mtab_fieldnames OCCURS 3,
title(60) TYPE c,
table(6) TYPE c,
field(10) TYPE c,
type(1) TYPE c,
END OF mtab_fieldnames.
DATA: headline(80).
DATA: BEGIN OF error_tab OCCURS 10. "Error table
INCLUDE STRUCTURE hrerror.
DATA: END OF error_tab.
PERFORM get_data.
PERFORM set_column_headers.
PERFORM setup_control.
&----
*& Form get_data
&----
FORM get_data .
SELECT * UP TO 500 ROWS FROM marc INTO CORRESPONDING FIELDS OF TABLE
mtab_materials.
ENDFORM. " get data
&----
*& Form set_column_headers
&----
text
----
FORM set_column_headers.
mtab_fieldnames-title = 'Material Number'.
mtab_fieldnames-table = 'MARC'.
mtab_fieldnames-field = 'MATNR'.
mtab_fieldnames-type = ''.
APPEND mtab_fieldnames.
mtab_fieldnames-title = 'Plant'.
mtab_fieldnames-field = 'WERKS'.
APPEND mtab_fieldnames.
mtab_fieldnames-title = 'Maintenance status'.
mtab_fieldnames-field = 'PSTAT'.
APPEND mtab_fieldnames.
mtab_fieldnames-title = 'Plant-Specific Material Status'.
mtab_fieldnames-field = 'MMSTA'.
APPEND mtab_fieldnames.
ENDFORM.
&----
*& Form setup_control
&----
FORM setup_control .
CALL FUNCTION 'HR_DISPLAY_BASIC_LIST'
EXPORTING
file_name = sy-repid
head_line1 = 'head1'
foot_note1 = 'foot1'
dyn_pushbutton_text1 = 'Push1'
dyn_pushbutton_text2 = 'Push2'
LIST_LEVEL = '01'
no_alv_grid = 'X'
TABLES
data_tab = mtab_materials
fieldname_tab = mtab_fieldnames .
ENDFORM.