‎2013 Aug 20 9:56 PM
Hi ,
Can anybody please tell how to capture enter when trying to validate entries in module pool screen.My requirement was to create custom T-code to update two custom tables.I have done this requirement using custom container screen with ALV OOP.But now when trying to validate one of the table values which the user enters,I am able to do this requirement by doing validation when use clicks on sy-ucomm= 'save' and the 'check mark' icon on the top,but also the requirement is to validate it when the user enters value on one single field cell and hits enter ,it should pop up a error message then if it is a invalid entry. I am unable to do the validation when the enter key is pressed.Please suggest how to proceed with this?
Thanks
Sarita Panda
‎2013 Aug 21 7:02 AM
Hi Sarita,
there is event for ALV Oo, you could redefine it ..
or there is the module pool method :
CHAIN.
FIELD my_field.
ENDCHAIN.
it depends of your code.
regards
Fred
‎2013 Aug 21 7:03 AM
Hi,
1. Register data_changed event for your ALV grid.
SET HANDLER : ref_event_handler->on_data_changed_grid
FOR ref_grid_items,
2. Data_changed method definition
on_data_changed_grid FOR EVENT data_changed
OF /irm/cl_gui_alv_grid
IMPORTING er_data_changed
e_onf4
e_onf4_before
e_onf4_after,
3. Data_changed method implementation. Here set some new OK Code
METHOD on_data_changed_grid.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'ENTR'.
ENDMETHOD.
You can do validations for OK code ENTR.
Regards,
Praveen
‎2013 Aug 21 7:09 AM
Hi Sarita,
If you are using OO ALV you can use the event DATA_CHANGED to validate the input as soon as the user leaves the field or press enter or tab,
There are lot of samples available...
http://scn.sap.com/docs/DOC-10353
Regards
‎2013 Aug 22 2:47 PM
Hi ,
I tired with the solution mentioned in the link above http://scn.sap.com/docs/DOC-10353using event handle_data_change ,Now it triggers based on the enter command and I can validate ,but I am stuck up with a issue here wherein when a message pops up as a "invalid entry" I have to hit enter 3 times to let the pop up go and then if I go back to the previous screen and come back to this validation screen and again if there is a invalid entry to let the pop up go it needs 6 enters this time and each time it increases. Could anyone please suggest how to eliminate this repeated calling of the handling data change event?
Thanks
Sarita Panda
‎2013 Aug 21 7:17 AM
Hi Sarita,
Use the ALV Toolbar Buttons and Enable the SAVE button there. So that you can handle that data in the HANDLE_USER_COMMAND Method for Event USER_COMMAND.
If you want to make use of SAVE button on the SAP GUI Status then you need to make sure that what changes that he had made in the ALV Container.
For that purpose make use of HANDLE_DATA_CHANGE and HANDLE_DATA_CHANGE_FINISH Methods in the CL_GUI_ALV_GRID.
You can also do the 2 point in another way. Make sure that User Selects the Row in the ALV Container before he clicks SAVE button. To make the Selecting Button Enabled. You need to Pass
LVC_S_LAYO-SEL_MODE = 'D'.
Then When he clicks on SAVE call the Method GET_SELECTED_ROWS as shown below
CALL METHOD G_GRID->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS = LT_ROWS.
Hope you got it... Happy Coding
‎2013 Aug 21 7:39 AM
Hi Saritha,
In module pool screen, you can define 'ENTER' fuction code in the pf status of the particular screen. It can be given in the 'Function Keys'.
We can capture the f-code and do requred validation in the PAI.
Regards
‎2013 Aug 22 3:08 AM
Hi ,
I tired with the solution mentioned in the link above http://scn.sap.com/docs/DOC-10353 using event handle_data_change ,Now it triggers based on the enter command and I can validate ,but I am stuck up with a issue here wherein when a message pops up as a "invalid entry" I have to hit enter 3 times to let the pop up go and then if I go back to the previous screen and come back to this validation screen and again if there is a invalid entry to let the pop up go it needs 6 enters this time and each time it increases. Could anyone please suggest how to eliminate this repeated calling of the handling data change event?
Thanks
Sarita Panda
‎2013 Aug 22 4:43 AM
Hi Saritha,
You can use case- endcase , when ok_code = 'ENTER' then write the code you need. If you want a popup to come then also it will work, say inside a perform you can write the validation rule, if not call the popup fm.
Regards,
Nivedita.
‎2013 Aug 22 5:09 AM
Hi Sarita,
The best way to validate the fields is to write validation code inside CHAIN .. END CHAIN.
try seeing this link
http://scn.sap.com/message/4804973.
Or If u want to capture the 'ENTER' . try setting the PF status
Regards,
Sivaganesh