09-10-2008 6:41 PM
I need some immediate help regarding Grid ALV.
My Requirement: I need to display an ALV grid report along with checkboxes. Further, I need to provide an option wherein the user can checkboxes and select the records that I need to process further (by clicking the process button on the ALV Report).
My Query: The problem here is that I am not able to capture the status of the checkboxes. This means that I am not able to capture which of the records have been selected by checking their resp checkboxes.
Solutions that I have tried: I have tried capturing the same at user command by checking the value in slis_selfield. But all the records show the value as 1 for the checkbox field.
Kinldy suggest how to go about it.
I am not using Object Oriented ALV. Please suggest something to be used in ALV Grid display in 4.6C version.
Regards,
Namrata
09-10-2008 6:52 PM
Here is a Sample code , it might help you
********************************************************
TABLES : sflight.
TYPE-POOLS: slis.
DATA : w_repid LIKE sy-repid.
w_repid = sy-repid.
DATA: BEGIN OF it_sflight OCCURS 0,
checkbox(1),
carrid LIKE sflight-carrid,
END OF it_sflight.
*layout
DATA: wa_layout TYPE slis_layout_alv.
*field catalog
DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
wa_fieldcatalog TYPE slis_fieldcat_alv.
START-OF-SELECTION.
SELECT carrid FROM sflight
INTO CORRESPONDING FIELDS OF TABLE it_sflight.
END-OF-SELECTION.
CLEAR it_fieldcatalog.
REFRESH it_fieldcatalog.
wa_fieldcatalog-fieldname = 'CHECKBOX'.
wa_fieldcatalog-outputlen = '3'.
wa_fieldcatalog-col_pos = '1'.
wa_fieldcatalog-seltext_m = 'Chk'.
wa_fieldcatalog-checkbox = 'X'.
wa_fieldcatalog-edit = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'CARRID'.
wa_fieldcatalog-outputlen = '10'.
wa_fieldcatalog-col_pos = '2'.
wa_fieldcatalog-seltext_m = 'Carrid'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
is_layout = wa_layout
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = it_fieldcatalog
TABLES
t_outtab = it_sflight
EXCEPTIONS
program_error = 1
OTHERS = 2.
*&----
*& Form USER_COMMAND
*&----
FORM user_command USING p_ucomm TYPE sy-ucomm
p_selfld TYPE slis_selfield.
CASE p_ucomm.
WHEN '&DATA_SAVE'.
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 it_sflight WHERE checkbox = 'X'.
DELETE it_sflight INDEX sy-tabix.
ENDLOOP.
p_selfld-refresh = 'X'.
ENDCASE.
ENDFORM. "user_command
09-10-2008 7:32 PM
Hi Bala,
I am not using OO ALV,so just wanted to confirm if the method, check_changed_data, will work for simple grid ALV.
Can this method be called without using any other concept of OO ALV?
Also confirm if this can work in 4.6C version of SAP.
Thanks for a quick response!
Regards,
Namrata
09-10-2008 7:38 PM
Yes, it will work, it is defined in FORM itself
DATA ref1 TYPE REF TO cl_gui_alv_grid.
09-11-2008 6:05 AM
Hi Bala,
I am using the method CALL METHOD ref1->check_changed_data as suggested by you.
But it is not fetching any value. It goes to this method and then exits the Form. The control automatically goes to the output screen wherein all the checkboxes are refreshed.
Please advise how to proceed.
Thanks!
Regards,
Namrata
09-11-2008 3:28 AM
in the user_commnad form if you place this code, that will be update the internal table with the changes.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1. "get the reference of the grid object
CALL METHOD ref1->check_changed_data. "this will update the changes.
09-11-2008 6:00 AM
Hi,
Loop the ITAB and select only the records which has the value 'X' for the field checkbox (Definitely you have declared checkbox field in your ITAB).
Loop at ITAB where checkbox = 'X' -
> (caps 'X')
Endloop.
Pickup the value and based on that you can process.
Revert for further issues.
Regards,
V Kumar
09-11-2008 6:08 AM
Hi Kumar,
Thanks for ur response.
But all the records contain a '0' value for the check box field. None of then has a different value.
Please help.
Regards,
Namrata
09-11-2008 6:12 AM
Show your code. I am not sure what you are doing. just post it here...
09-11-2008 6:29 AM
Hi Vijay,
Please find below an extract of my code:
**************************************************************
Displaying ALV.
FORM alv_display_data.
report_id = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = report_id
i_callback_pf_status_set = 'ALV_SET_PF_STATUS'
i_callback_user_command = 'ALV_USER_COMMAND'
is_layout = ls_layout
it_fieldcat = pi_field_cat
i_save = 'A'
TABLES
t_outtab = i_output
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "display_data
**************************************************************
User Command Sub-routine
FORM alv_user_command USING r_ucomm LIKE sy-ucomm
p_selfld TYPE slis_selfield.
r_ucomm = sy-ucomm.
DATA: wa_output TYPE ty_output.
CASE r_ucomm.
WHEN '&CONTINUE'.
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 i_output INTO wa_output WHERE check_box = 'X'.
DELETE i_output INDEX sy-tabix.
ENDLOOP.
p_selfld-refresh = 'X'.
ENDCASE.
ENDFORM. "alv_user_command
**************************************************************
Please tell me where am I going wrong.
Thanks!
Regards,
Namrata
09-11-2008 8:03 AM
just apply these changes. and more over are you Firing the Continue function.
FORM alv_user_command USING r_ucomm LIKE sy-ucomm
p_selfld TYPE slis_selfield.
"r_ucomm = sy-ucomm. "Why are you doing this....
"comment the above line
DATA: wa_output TYPE ty_output.
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.
CASE r_ucomm.
WHEN '&CONTINUE'.
LOOP AT i_output INTO wa_output WHERE check_box = 'X'.
DELETE i_output INDEX sy-tabix.
ENDLOOP.
p_selfld-refresh = 'X'.
ENDCASE.
ENDFORM. "alv_user_command
09-11-2008 6:16 AM
hi namrata
u have to creat a variable in ur internal table which is getting dispaly
DATA: ROW TYPE C,
LAYOUT TYPE SLIS_LAYOUT_ALV.
LAYOUT-BOX_FIELDNAME = 'ROW'.
LAYOUT-GET_SELINFOS = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = 'PF-STATUS'
I_CALLBACK_USER_COMMAND = 'UCOM'
I_STRUCTURE_NAME =
IS_LAYOUT = LAYOUT
IT_FIELDCAT = I_FCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = I_VBAK[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FORM UCOM USING L_UCOMM LIKE SY-UCOMM
L_SELFIELD TYPE SLIS_SELFIELD.
CASE L_UCOMM.
WHEN 'SUMMARY'.
LOOP AT I_VBAK WHERE ROW = 'X'.
ENDLOOP.
IF I_VBAK-ROW IS INITIAL.
MESSAGE E064(ZVIKALP).
ENDIF.
10-03-2008 8:08 AM