Handy SAP function module to automate user events
Let me start my first blog with a useful function module that I came to know while solving one of the commonly faced issues in SAP.
ABAP Statement: MESSAGE ‘Text’ TYPE ‘E’.
On execution of this statement,processing stops,screen input field(s) gets disabled and the poor end-user has to press ENTER key to input again the screen input values. During my initial days as an ABAPer,I was not aware of the useful message_options of the MESSAGE statement (DISPLAY LIKE ‘W‘ and ‘E‘). So I googled without any hope to find out if there is any way that I could automate the event of user pressing the ENTER key.Wow! I got one.Made me wonder whether there is anything that ABAP doesn’t provide. ABAP is too good!!!!!
*Begin-Auto triggers ENTER command
CALL FUNCTION ‘SAPGUI_SET_FUNCTIONCODE‘
EXPORTING
functioncode = ‘ENTER‘
EXCEPTIONS
function_not_supported = 1
OTHERS = 2.
*End-Auto triggers ENTER command
Similarly we can work around with standard function codes (viz.,SAVE,EXECUTE etc.) and custom function codes (which we add in push button,radio button,hyperlink etc.) with this wonderful FM.
Regards,
K.Arun Prabhu.
“Never calculate the height of a mountain before you climb it. When you reach the top, you will realise how low it was”
@Arun: Good solution to the problem. However, I found something for avoiding the ENTER issue. Can you please help me understand what is the difference if we do thing as this way.
MESSAGE 'Text' TYPE 'S' DISPLAY LIKE 'E'.
Preetam,
I have already mentioned in this blog about DISPLAY LIKE message_option of the MESSAGE statement 🙂 If we use this option, processing won't stop on execution and we have to use either return/leave to screen to stop the processing.
MESSAGE 'Text' TYPE 'S' DISPLAY LIKE 'E'.
return / leave to screen XXXX.
Thanks for the precise reply. 🙂
Hey Thanks, never knew about this function module.
Though, as you say for message statement there are other better options but this function module could be a boon in some scenarios 🙂 .
Cheers,
Shreya
This is one to keep in mind, when I find myself in times of trouble 🙂
Hi
thanks for the solution .
Hi Prabhu,
Thanks for sharing this function module.....
Hi Prabhu,
Interesting FM 🙂 . There are many such interesting FMs. Check TH_POPUP for one.
BR,
Shankar.
Informative...Many Thanks for the share.
Best Regards,
Naresh K.
Good Information
Hi K.Arun Prabhu,
The FM you have mentioned is new for me and it is very helpful. Thanks a lot sharing the information.
Cheers dude! 🙂
Hey Its awesom..........Its nice and please try to share such useful things because without knowledge sharing we cant survive.
Thanks a lot Alenlee James 🙂
HI Arun,
Good blog 🙂 🙂 , Thanks For Sharing 😉 😉 .
Regards,
Grii
Thanks a lot Giri Peram 🙂
Great Job 🙂
Thanks for sharing 🙂
Cheers,
Akberhusain
Hi,
interesting and useful.
Thanks for sharing
Cheers
Ivan
Nice information Arun.
Keep sharing.
Cheers
PS
Thanks for sharing. useful FM.
Hi Arun,
The information is interesting and useful.
Thanks for sharing
Thanks,
Ajay Bose
Came across something really handy. Thanks for sharing 🙂
Cheers
Intresting Article and really handy.
Gud Article...i tried this one..really helpful. Thank u.
Informative Article. 🙂
Nice..Keep posting
Hi Arun,
Good to know about the new FM. Thanks for sharing 🙂
But one quick question. This FM can be used in our customized programs right ?
Then why don't we can use the message type as 'I' or "S" instead of "E".
Could you please brief little bit for me...please........ 🙁
Regards,
Krishna Chaitanya.
Hi Krishna.
This FM can be used in our customized programs. Otherwise how I would have known it 🙂
You are right that we can use other message types.
If you can re-read the blog, I have mentioned about using DISPLAY LIKE 'E' or 'W'.
I have mentioned that I came to know about this FM before I got to know other good MESSAGE options.
This FM can be used in various scenarios wherein you feel a PAI event needs to be triggered. When situation comes, you will understand it better.
Hope you got it 🙂
Regards.
Thanks a lot Arun.
Keep going will check your upcoming blogs tooooooooooo 🙂
Cheers,
Krishna Chaitanya.
Cheers dude! 🙂
Dear Arun,
Congrats on your first blog and thanks for sharing this wonderful FM.
But I'm still intrigued as to how this FM could be useful in cases where we need to trigger an error message since triggering the error message would stop the processing and it won't move to the next block(which is where as I understand we are expected to call this FM, right?). So the screen fields would still be not ready for input(even if you press 'Enter' the screen field would still be not ready for input, unless you are raising the error inside a field statement module). I don't really get that part of your blog - as to how the user could press enter and make the fields ready for input again in case of an error message, with or without this FM.
Could you clarify the context where you were able to make use of this FM?
Thanks a lot
Cheers
Mahesh
Hi Mahesh.
This FM is not particularly useful for the case you had asked/(mis)understood 🙂
For displaying an error message, the best option is
MESSAGE 'Text' TYPE 'S' DISPLAY LIKE 'E'.
leave to screen sy-dynnr.
I just meant to say I came across this FM when I was searching for some way to automate the event of user pressing ENTER key.
One scenario I will mention here where I had used this FM:
* In a module pool screen, I have a field for which i have given search help using POV module.
* In that module, on user selection on some data, I have called this FM to execute with the selected data. If I had not used this FM, user has to press EXECUTE button to proceed further.
Regards.
gud one K.Arun Prabhu
Keep sharing ur knowledge..thank u. 🙂
Hi Arun,
Very interesting info, great job in sharing the same.
Thanks,
Anju
Useful information
hi,,, thanks for sharing ...
You solved one of my issue.
Interesting Info. Thanks for sharing .
Useful info. Thanks for sharing..
a new thing which we came across...keep discovering new thing....!!
Useful one.. thanks for sharing 🙂
Thanks for sharing like this.I hope it will helps most of the ABAPer's who has started their carrier in SAP ABAP, off course some of the experts also 😆 .
Keep sharing Ur knowledge..