2011 Jan 07 6:05 AM
Hi All,
I have created an ALV using CL_GUI_ALV_GRID->set_table_for_first_display
I have 2 editable fields which should be made mandatory.
I have to validate if these fields are filled and the data is proper.
If the user tries to select any of the tool bar events like PRINT & EXPORT without filling the mandatory fields then it should not allow the action.
Please suggest
Regards,
Deepti
Edited by: Deepti Vohra on Jan 7, 2011 7:06 AM
2011 Jan 07 6:19 AM
Are the fields your ALV layout fields or selection-screen fields ?
You can check if that field is INITIAL or NOT-INITIAL at USER-COMMAND
2011 Jan 07 6:22 AM
2011 Jan 07 6:28 AM
Fine...
Then use SY-UCOMM and check if the fields are initial or not. Add your logic further.
IF sy-ucomm = 'PRINT'.
IF <field> is initial.
MESSAGE e000 WITH text-001.
ENDIF.
ENDIF.
Edited by: K.Manas on Jan 7, 2011 7:31 AM
2011 Jan 07 6:32 AM
you can use handle data change finished method. at this time ur alv data table will be updated with all the changes user has done. but the thing is this will only get triggered if there is a data change. if your using the standard user command buttons you might need to check another method which will get triggered before the functionality is called
2011 Jan 07 6:56 AM
Hi Nafran,
What you have said is right. I am searching for a way when user does not enter the mandatory fields and presses the tollbar buttons.
Regards,
Deepti
2011 Jan 07 7:18 AM
Try to manage event [BEFORE_USER_COMMAND|http://www.sdn.sap.com/irj/scn/advancedsearch?query=before_user_command]. (SAP documentation via F1 or [before_user_command|http://help.sap.com/saphelp_NW70EHP1core/helpdata/en/ee/c8e059d52611d2b468006094192fe3/frameset.htm] in [ALV Grid Control|http://help.sap.com/saphelp_NW70EHP1core/helpdata/en/bf/3bd1369f2d280ee10000009b38f889/frameset.htm]) - you may require to call also method [check_changed_data|http://www.sdn.sap.com/irj/scn/advancedsearch?query=check_changed_data] to raise [data_changed|http://www.sdn.sap.com/irj/scn/advancedsearch?query=data_changed] event before performing checks.
Regards,
Raymond
2011 Jan 07 7:45 AM
Hi Deepti,
In the PAI of screen, for user command PRINT, call method check_changed_data before performing validations.
If ok_code = 'PRINT'.
CALL METHOD v_grid->check_changed_data(
IMPORTING
e_valid = lf_valid ).
This will capture if any values are changed in ALV
Then you can perform your validations here
endif.
You also need to register the edit event after calling set_table_for_first_display in PBO
CALL METHOD v_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
Thanks
Radhika
2011 Jan 07 8:25 AM
Hi,
After validations are done I have to forward the data for printing.
Is ther any function module which behaves like the standard PRINT button functionality like displaying the print screen list pop up to enter the printer parameters like output device no. of copies and all...
Regrads,
Kusuma
2011 Jan 07 8:36 AM
Not sure if you can do this :
You can check : GET_PRINT_PARAMETERS and SET_PRINT_PARAMETERS and NEW-PAGE PRINT ON PARAMETERS function modules
Edited by: K.Manas on Jan 7, 2011 9:37 AM
2011 Jan 10 5:32 AM
Thank you Raymond,
The problem got resolved using before_user_command . In that I throw the error message and clear the function code of the toolbar button using
CALL METHOD go_alv2->set_user_command
EXPORTING
i_ucomm = space.
Thank you all for your replies.
Regards,
Deepti