Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Use User Language for MESSAGE statement

Former Member
0 Likes
5,108

Well Folks,

I have a requirement to display error messages in SAP (both custom and standard) in the user's communication language (System>User Profile>Own Data>Communication>Language) rather than the logon language.

I'm hoping to achieve this by modifying the SAP standard code (possibly a macro) that does the SELECT from T100. Does anyone know where this SELECT statement on T100 is performed when a message is triggered like:

MESSAGE ID mid TYPE mtype NUMBER num.

Or, failing that, does anyone else have any ideas about how I might achieve my goal?

Any help is much appreciated, thanks!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,540

So here is my solution, it's not ideal and it's not correct but it meets the requirement and I didn't need to register an object key from SAP.

In implicit enhancement on include LSHL2F01, start of routine "form doku_anzeigen using exit_flg."

CLEAR: lv_addrnumber, lv_langu.

SELECT SINGLE addrnumber

   FROM usr21

   INTO lv_addrnumber

   WHERE bname = sy-uname.

SELECT SINGLE langu

   FROM adrc

   INTO lv_langu

   WHERE addrnumber = lv_addrnumber.

SELECT SINGLE sprsl text

   FROM t100

   INTO (help_info-spras, help_info-message)

   WHERE sprsl = lv_langu

   AND arbgb = help_info-messageid

   AND msgnr = help_info-messagenr.

IF sy-subrc = 0.

   "Display Message in Communication Language

ELSE.

   "Use system logon language, variables have not been changed

ENDIF.

Now, when the user get's the error message, it'll be in the system logon language initially, but then they can click on it and it will display the popup window (even if there is no longtext for the message) in their communication language.

12 REPLIES 12
Read only

Sougata
Active Contributor
0 Likes
2,540

Colm Gavin wrote:

I'm hoping to achieve this by modifying the SAP standard code (possibly a macro) that does the SELECT from T100.

Please do not do that.

Colm Gavin wrote:

Or, failing that, does anyone else have any ideas about how I might achieve my goal?

You could build a wrapper Method (and/or a custom message framework) to control the message language for your custom applications but for SAP standard messages it will not be possible to control this behaviour as it will always display messages as per the logon language.

If the user wants to see the SAP standard messages in their preferred language, he/she must login to the system in their preferred language.

Also, the intention of  language field in System>User Profile>Own Data>Communication>Language is completely different from what you are trying to achieve.

Cheers,

Sougata.

Read only

Former Member
0 Likes
2,540

Sougata Chatterjee wrote:

Colm Gavin wrote:

I'm hoping to achieve this by modifying the SAP standard code (possibly a macro) that does the SELECT from T100.

Please do not do that.

I agree 100%, couldn't agree more with you, but we all have bosses, and this is a decision that has been made at a very high level and therefore unless I can use some sort of user-exit on the MESSAGE command, this is what I'll have to do.

Also, the intention of  language field in System>User Profile>Own Data>Communication>Language is completely different from what you are trying to achieve.

Again, I agree but it is a field we can exploit and therefore we will try to use it.

You could build a wrapper Method (and/or a custom message framework) to control the message language for your custom applications but for SAP standard messages it will not be possible to control this behaviour as it will always display messages as per the logon language.

When you say a custom message framework, are you suggesting that we use some sort of FM that handles our requirement and then instead of using MESSAGE we would CALL this function and let it handle the message?

Read only

matt
Active Contributor
0 Likes
2,540

Colm Gavin wrote:

I agree 100%, couldn't agree more with you, but we all have bosses, and this is a decision that has been made at a very high level and therefore unless I can use some sort of user-exit on the MESSAGE command, this is what I'll have to do.

If your customer/client wants to hack their system to this extent of course they're free to. But it almost certainly will violate their support contract with SAP. I'm reminded of the very high level boss who insisted he fly from Geneva to London - when London airspace was closed down due to the Icelandic volcano... just because you're high level doesn't mean the requirement is possible.

I did a trace on a MESSAGE. If you try to drill down to the source code on the T100 select, you get "Cannot display source code - no program name in trace record". I've also run system debugging on it. My conclusion is that MESSAGE is part of the Kernel.

Ergo - the requirement is not achievable from the customer end. A few possibilities.

1. Get the very high level manager to chat with a very high level SAP executive (perhaps when they play golf together) and see if the requirement can be met from SAP's side.

2. Ask for tenders for alternative software that it is capable of meeting such a business critical requirement.

Read only

Former Member
0 Likes
2,540

Ha very good! I wish it were that simple but your input was valuable none-the-less.

The trace was a very good idea but as I feared, the code was going to be un-modifiable.

However, the requirement (displaying MESSAGEs in communication language rather than logon language) doesn't go away so I'll need to rattle my brain a bit more. Thanks for the input!

Read only

matt
Active Contributor
0 Likes
2,540

One of my clients had the same requirement. Eventually sanity reigned. I've been working on deep technical SAP stuff for over 15 years - I'll be extremely surprised if a way to meet this requirement is found.

It will require a kernel change. Only SAP can do that.

Read only

former_member202771
Contributor
0 Likes
2,540

This message was moderated.

Read only

0 Likes
2,540

Thanks Anil but that will only work if the user's logon language is set to the language they speak.

Read only

Former Member
0 Likes
2,540

What I am trying to say is that somewhere in the SAP code, there must be a SELECT from the T100 table using SY-LANGU, I would love to know where that is but I understand it is nestled deep in the SAP code and possibly even in some sort of system command. I was hoping it was in a macro but it is not.

Read only

0 Likes
2,540

Hi,

You can change SY-LANGU using SET LOCALE LANGUAGE, but this will not affect the MESSAGE command.

http://help.sap.com/abapdocu_702/en/abapmessage.htm

Notes

Setting the text environment by means of the SET LOCALE statement has no effect on the language in which the message is displayed

Colm Gavin wrote:

(...) are you suggesting that we use some sort of FM that handles our requirement and then instead of using MESSAGE we would CALL this function and let it handle the message?

Looks like a FM does not help your requirement, but there is a FM called MESSAGE_PREPARE which has a parameter LANGUAGE

Regards,

Paulo.

Read only

Former Member
0 Likes
2,541

So here is my solution, it's not ideal and it's not correct but it meets the requirement and I didn't need to register an object key from SAP.

In implicit enhancement on include LSHL2F01, start of routine "form doku_anzeigen using exit_flg."

CLEAR: lv_addrnumber, lv_langu.

SELECT SINGLE addrnumber

   FROM usr21

   INTO lv_addrnumber

   WHERE bname = sy-uname.

SELECT SINGLE langu

   FROM adrc

   INTO lv_langu

   WHERE addrnumber = lv_addrnumber.

SELECT SINGLE sprsl text

   FROM t100

   INTO (help_info-spras, help_info-message)

   WHERE sprsl = lv_langu

   AND arbgb = help_info-messageid

   AND msgnr = help_info-messagenr.

IF sy-subrc = 0.

   "Display Message in Communication Language

ELSE.

   "Use system logon language, variables have not been changed

ENDIF.

Now, when the user get's the error message, it'll be in the system logon language initially, but then they can click on it and it will display the popup window (even if there is no longtext for the message) in their communication language.

Read only

matt
Active Contributor
0 Likes
2,540

In my view, it's a reasonable solution. However, I would encapsulate it in a static method of a class (or a function module). That way you can be sure of no naming collisions with variables.

I'd also use an inner join for the select, instead of three selects.

Read only

0 Likes
2,540

Good tips, will do that. Thanks!