10-04-2006 4:36 PM
Hi friends,
Can you tell me how to do the following.
Ive an internal table ITAB with 10 lines of records. It is having 6 columns.
I display this ITAB in ALV using REUSE_ALV_GRID_DISPLAY.
Now my task is user may select one or more line of records in ALV and I have to move the selected lines of records to A Flat file.
Can you tell me how to do this?.
-
Thanks,
Nash
10-04-2006 5:36 PM
1. add one more field checkbox of length 1 to ur final internal tabel
2. in ur fieldcatalg add this line
wa_fcat-fieldname = 'CHECKBOx'.
wa_fcat-checkbox = 'X'.
wa_fcat-outputlen = '1'.
wa_fcat-col_pos = '1'.
append wa_fcat to it_fcat.
3.in ur layout , add this line
wa_layout-box_fieldname = 'CHECKBOX'.
4.In th USER_COMMAND subroutine of ur REUSE_ALV_GRID_DISpLAy FM
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
case p_ucomm.
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
when 'SAVE'.
loop at itab where checbox = 'X'.
* store these values in another itab
endloop.
use GUI_DOWNLOAD to download the entries to excel
.
10-04-2006 4:47 PM
Hi Nash
You can do it including a column that have a checkbox
Regards
David
10-04-2006 5:28 PM
10-04-2006 5:36 PM
David,
In the field catalog make check_box = 'X'.
My suggestion is if you are displaying the ALV using the OO method, this can be easily handled. There is no need of Check box. Directly we can use the method to get the selected rows.
Regards,
Prakash.
10-04-2006 5:32 PM
10-04-2006 5:36 PM
1. add one more field checkbox of length 1 to ur final internal tabel
2. in ur fieldcatalg add this line
wa_fcat-fieldname = 'CHECKBOx'.
wa_fcat-checkbox = 'X'.
wa_fcat-outputlen = '1'.
wa_fcat-col_pos = '1'.
append wa_fcat to it_fcat.
3.in ur layout , add this line
wa_layout-box_fieldname = 'CHECKBOX'.
4.In th USER_COMMAND subroutine of ur REUSE_ALV_GRID_DISpLAy FM
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
case p_ucomm.
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
when 'SAVE'.
loop at itab where checbox = 'X'.
* store these values in another itab
endloop.
use GUI_DOWNLOAD to download the entries to excel
.
10-04-2006 5:43 PM
Hi Nash
when populating the field catalog use this code for the check box at first column.
CLEAR ls_fieldcat.
ls_fieldcat-tabname = 'I_OUT1'.
ls_fieldcat-fieldname = 'CHECK_BOX'.
ls_fieldcat-col_pos = 1.
ls_fieldcat-seltext_l = 'EDIT'.
ls_fieldcat-checkbox = 'X'.
ls_fieldcat-edit = 'X'.
APPEND ls_fieldcat TO i_fieldcat.
in the internal table add
TYPES : BEGIN OF t_out,
check_box TYPE c,
end of t_out.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_pf_status_set = 'PF_STATUS_SET'
<b>i_callback_user_command = 'USER_COMMAND'</b>
is_layout = i_layout
it_fieldcat = i_fieldcat
TABLES
t_outtab = i_out2
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM user_command USING r_ucomm.
CASE R_UCOMM.
WHEN .....
LOOP AT ITAB WHERE CHECKBOX = 'X'.
ENDLOOP
ENDCASE.
ENDFORM.
regards.
David
10-04-2006 8:18 PM
hi
Now I did what Chandrasekhar and david mentioned but getting dump error 'field symbol has not been assigned'..i'm not using any field symbol then...?
Nash
10-04-2006 8:39 PM
In your fieldcat make sure that the table and field names are capitalized.
This should take care of your error.
10-04-2006 9:58 PM
Hi Nash
I check it and in some versions you don't neet to put fieldcat part, you can comment it instead of eliminate.
Regards,
David
10-07-2006 3:46 AM