Application Development 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: 

Detecting language of a string

Former Member
0 Kudos

Hi friends,

Need your help, there is one urgent requirement.

I have to treat a field in two different ways.

If string (content of field) is in English language, then i have to concatenate it in one way.

But if it's in Chinese then i have to concatenate it in another way.

Do we have any function module to detect the language or any SYST field for the same.

Help will be greatly appreciated. Thanks!!!!

1 ACCEPTED SOLUTION

former_member201275
Active Contributor
0 Kudos

If it is definetly either English or Chinese then it is simple i.e.:

DATA: text(20) VALUE 'Testing'.
START-OF-SELECTION.
  IF text CA sy-abcde.
    "CONCATENATE FIRST_WAY.
  ELSE.
    "CONCATENATE SECOND_WAY.
  ENDIF.

But if you could possibly have other languages then of course this wouldn't work.

Hope this helps.

15 REPLIES 15

JuanCarlosDelga
Contributor
0 Kudos

Hi Kulprakash,

can you use the system field sy-langu?

Regards.

JCD

0 Kudos

Value to that field will come from a table (also field is free flow means it is accepting value in any language.), and SY-LANGU will consider sap log on language.

So, its not working

0 Kudos

Hi,

Is it a standard table?

Regards,

Suman

0 Kudos

Yes it is REGUH.

PFB the screenshot along with field.

0 Kudos

KP,

REGUH means you are dealing with F110 Payment Run data.

Get the Vendor or Customr Code of that Invoice.

Based on the Vendor or Customer Code find out which country he belongs to using LFA1 or KNA1 tables.

Then based on that Country Code you proceed with your validation.

Will that suffice ?

Let's see what experts say.

K.Kiran.

Message was edited by: Kiran K

0 Kudos

Sorry, Table name is LFBK

former_member202771
Contributor
0 Kudos

Hi KP,

If string CS 'enter_all_chinese_characters_here'.    " something like 'AaBb...Zz'

Concatinate name2 name1 name3 to name.          "chinese format

else.

Concatinate name1 name2 name3 to name.

endif.

Thanks,

Anil

0 Kudos

Good luck hardcoding thousands of characters. I would not recommend this

And operator should be CA not CS in this use...

-- Tomas --

raymond_giuseppi
Active Contributor
0 Kudos

Try to identify a character in Unicode Chinese specific ranges (Actually CJK ranges for China, Japan and Korea)

BlockRange
CJK Unified Ideographs4E00-9FFF
CJK Unified Ideographs Extension A3400-4DFF

CJK Unified Ideographs Extension B

20000-2A6DF

CJK Compatibility Ideographs

F900-FAFF

CJK Compatibility Ideographs Supplement

2F800-2FA1F

Regards,

Raymond

Former Member
0 Kudos


Hi Kulprakash Sharma,

Please use the field BANKS( Bank Country) to check the language.

IF BANKS = 'CN' " Chinese

CONCATENATE  INTO STRING1....................

ELSE

CONCATENATE  INTO STRING2

ENDIF.

Regards,

Pravin

0 Kudos

Hi Pravin,

I checked the table, there are entries where BANKS = 'CN' but beneficiary name is maintained in English.

So, its not working.

Thanks!!

former_member201275
Active Contributor
0 Kudos

If it is definetly either English or Chinese then it is simple i.e.:

DATA: text(20) VALUE 'Testing'.
START-OF-SELECTION.
  IF text CA sy-abcde.
    "CONCATENATE FIRST_WAY.
  ELSE.
    "CONCATENATE SECOND_WAY.
  ENDIF.

But if you could possibly have other languages then of course this wouldn't work.

Hope this helps.

0 Kudos

For now, I am going with this solution but inconsistencies will come for sure in future.

Thanks!!

former_member184569
Active Contributor
0 Kudos

Well if its only English and Chinese that needs to be checked, then you can check, if its English and in the else condition concatenate the

if string CO sy-abcde.

*concatenate as in English.

else.

*concatenate as in Chinese.

endif.

0 Kudos

I think way suggested by