Skip to Content

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

To report this post you need to login first.

41 Comments

You must be Logged on to comment or reply to a post.

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

    (0) 
    1. K.Arun Prabhu 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.

      (0) 
  2. Shreya Tagra

    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

    (0) 
  3. 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.

    (0) 
    1. K.Arun Prabhu 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.

      (0) 
  4. Mahesh Madhavan

    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

    (0) 
    1. K.Arun Prabhu 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.

      (0) 
  5. 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..

    (0) 

Leave a Reply