Skip to Content
author's profile photo Former Member
Former Member

How to read user - logon language (Urgent)

Hi All,

I have written the below code to display the language in english if it exists if not in french & so on, but i would like to know how i can read the language in which the user has logged on & use that as the first criteria.

Eg: S_SPRAS = User Logon language

SELECT SINGLE MAKTX FROM MAKT INTO Y_MAKTX

WHERE MATNR = MARC-MATNR

AND SPRAS IN (S_SPRAS,'EN','FR','IT',' ').

Hope my problem is clear, await inputs.

Vivek

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 12:07 PM

    Hi,

    Hope this works...

    First

    data: s_langu type sy-langu,

    y_maktx type makt-maktx,

    s_langu1(1) type c.

    s_langu = sy-langu.

    s_langu1 = sy-langu+(1).

    • say there is a desc in Italian. then y_maktx has a desc in italian.

    select single maktx from makt into y_maktx

    where matnr eq marc-matnr

    and spras eq s_langu1.

    *if there is no desc in italian.

    if y_maktx is initial.

    select single maktx from makt into y_maktx

    where matnr eq marc-matnr

    and spras eq 'E'

    or spras eq 'I'

    or spras eq 'F'.

    endif.

    This should work. Try out.

    reward points if helpful.

    Arul.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 03:22 AM

    Hi All

    Thanks for the inputs, but if i use SY-LANGU, it will pick up the default language which is set for the user.

    Eg: User 1 default lang - EN (i.e. SY-LANGU = EN)

    But if the user while logging into SAP chooses FR, the code will still read EN language description, as the system language is EN. What i wanted is if user logs in FR, the description should be FR.

    Hope i am able to put across my problem clearly.

    Await inputs.

    Vivek

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 02:14 AM

    SY-LANGU

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 07, 2008 at 02:39 AM

    SELECT SINGLE MAKTX FROM MAKT INTO Y_MAKTX

    WHERE MATNR = MARC-MATNR

    AND SPRAS EQ Sy-langu.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 09:59 AM

    It is not working. The moment i use IN syntax the output shows in EN which is the default language. But when i use EQ syntax & then logon in different language it reads the logon language.

    Is there any other way i can manage to resolve my problem?

    I want to read the description in the logon language first, if the mtl description is not maintained in the lang in which the user has logged on then check for the others.

    Await inputs.

    Vivek

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Let me try to explain the problem

      Mtl-A, has description in 3 languages. (En, Fr, It)

      Mtl-B, has description in 1 language only. (It)

      Mtl-C, has no description

      First i want to check for a given mtl if description exists in the user's logon lang, if it does not, then check if description is maintained in English, if not check in French, if not Italian.

      Eg1: User logs-in with En language,

      Then the description for mtl-A is displayed in english, for Mtl-b description is displayed in Italian (as only italian description is maintained) & for mtl-c no description is displayed as it is not maintained.

      Eg2: User logs-in with It language.

      Then description for Mtl-A & B is displayed in Italian & for mtl-c it is blank as no description exists

      But when i use the below code, the system by default picks up EN which is my default lang, even if i login in French or Italian lang, the description is shown in english only.

      SELECT SINGLE MAKTX FROM MAKT INTO Y_MAKTX

      WHERE MATNR = MARC-MATNR

      AND SPRAS IN (SY-LANGU, 'EN', 'FR', 'IT').

      Hope i was able to put across my problem clearly.

      Await inputs.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 01:50 AM

    Hi, Vivek.

    You can use SY-LANGU(SAP logon language key).

    Regards,

    feng.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 11:31 AM

    Hi Vivek,

    Use the following .

    SELECT SINGLE MAKTX FROM MAKT INTO Y_MAKTX

    WHERE MATNR = MARC-MATNR

    AND SPRAS = sy-langu.

    No ways.

    Regards

    Srimanta

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.