Skip to Content
Author's profile photo K.Arun Prabhu

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

Assigned tags

      41 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Preetam Kajal Rout
      Preetam Kajal Rout

      @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'.

      Author's profile photo K.Arun Prabhu
      K.Arun Prabhu
      Blog Post Author

      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.

      Author's profile photo Preetam Kajal Rout
      Preetam Kajal Rout

      Thanks for the precise reply. 🙂

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo D. Floor
      D. Floor

      This is one to keep in mind, when I find myself in times of trouble 🙂

      Author's profile photo Former Member
      Former Member

      Hi

      thanks  for  the solution .

      Author's profile photo Ramesh .
      Ramesh .

      Hi Prabhu,

      Thanks for sharing this function module.....

      Author's profile photo Shankarnarayan K
      Shankarnarayan K

      Hi Prabhu,

      Interesting FM 🙂 . There are many such interesting FMs. Check TH_POPUP for one.

      BR,

      Shankar.

      Author's profile photo Former Member
      Former Member

      Informative...Many Thanks for the share.

      Best Regards,

      Naresh K.

      Author's profile photo Former Member
      Former Member

      Good Information

      Author's profile photo Former Member
      Former Member

      Hi K.Arun Prabhu,

      The FM you have mentioned is new for me and it is very helpful. Thanks a lot sharing the information.


      Author's profile photo K.Arun Prabhu
      K.Arun Prabhu
      Blog Post Author

      Cheers dude! 🙂

      Author's profile photo Former Member
      Former Member

      Hey Its awesom..........Its nice and please try to share such useful things because without knowledge sharing we cant survive.

      Author's profile photo K.Arun Prabhu
      K.Arun Prabhu
      Blog Post Author

      Thanks a lot Alenlee James 🙂

      Author's profile photo Former Member
      Former Member

      HI Arun,

      Good blog 🙂 🙂 , Thanks For Sharing 😉 😉 .

      Regards,
      Grii

      Author's profile photo K.Arun Prabhu
      K.Arun Prabhu
      Blog Post Author

      Thanks a lot Giri Peram 🙂

      Author's profile photo Former Member
      Former Member

      Great Job 🙂
      Thanks for sharing 🙂

      Cheers,

      Akberhusain

      Author's profile photo Former Member
      Former Member

      Hi,

      interesting and useful.

      Thanks for sharing

      Cheers

      Ivan

      Author's profile photo Former Member
      Former Member

      Nice information Arun.

      Keep sharing.

      Cheers

      PS

      Author's profile photo Shakeeluddin Khaja
      Shakeeluddin Khaja

      Thanks for sharing. useful FM.

      Author's profile photo Ajay Bose
      Ajay Bose

      Hi Arun,

      The information is interesting and useful.

      Thanks for sharing

      Thanks,

      Ajay Bose

      Author's profile photo Former Member
      Former Member

      Came across something really handy. Thanks for sharing 🙂

      Cheers

      Author's profile photo Modadugu Hemanth Kumar
      Modadugu Hemanth Kumar

      Intresting Article and really handy.

      Author's profile photo rajesh bethamcharla
      rajesh bethamcharla

      Gud Article...i tried this one..really helpful. Thank u.

      Author's profile photo Former Member
      Former Member

      Informative Article. 🙂

      Author's profile photo Former Member
      Former Member

      Nice..Keep posting

      Author's profile photo Krishna Chaitanya
      Krishna Chaitanya

      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.

      Author's profile photo K.Arun Prabhu
      K.Arun Prabhu
      Blog Post Author

      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.

      Author's profile photo Krishna Chaitanya
      Krishna Chaitanya

      Thanks a lot Arun.

      Keep going will check your upcoming blogs tooooooooooo  🙂

      Cheers,

      Krishna Chaitanya.

      Author's profile photo K.Arun Prabhu
      K.Arun Prabhu
      Blog Post Author

      Cheers dude! 🙂

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo K.Arun Prabhu
      K.Arun Prabhu
      Blog Post Author

      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.

      Author's profile photo Former Member
      Former Member

      gud one K.Arun Prabhu

      Keep sharing ur knowledge..thank u. 🙂

      Author's profile photo anju e v
      anju e v

      Hi Arun,

      Very interesting info, great job in sharing the same.

      Thanks,

      Anju

      Author's profile photo Former Member
      Former Member

      Useful information

      Author's profile photo Former Member
      Former Member

      hi,,, thanks for sharing ...

      You solved one of my issue.

      Author's profile photo Former Member
      Former Member

      Interesting Info. Thanks for sharing .

      Author's profile photo Shakeeluddin Khaja
      Shakeeluddin Khaja

      Useful info. Thanks for sharing..

      Author's profile photo Former Member
      Former Member

      a new thing which we came across...keep discovering new thing....!!

      Author's profile photo Former Member
      Former Member

      Useful one.. thanks for sharing 🙂

      Author's profile photo Dinesh K
      Dinesh K

      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..