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: 

How to Identify non-english characters in a Text

Former Member
0 Kudos

Hi Experts,

I have a text coming from KNA1-NAME1 which contains non-english characters / language at times. I want to identify them in my code so that I can skip them.

Can you please guide with some Command / FM that help to identify these non-english characters?

Regards,

Nirmal

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

By English Characters do you mean only Alphabets and numbers? In that case you do a check of

Contains only CO 'ABCDEFGH.......XYZ'. Similarly for small case 'abcde...xyz'.

Please let me know if this helps.

Regards,

Devendra

9 REPLIES 9

Former Member
0 Kudos

hi,

check the field SPRAS - which holds the language key.

0 Kudos

I have scenarios where SPRAS = EN but still NAME1 or other fields contain non-english characters. And when I try to print them on list output, they work fine.

But I don't want them to go to Output and hence identify them and skip them.

Regards,

Nirmal

Former Member
0 Kudos

DATA: A(50) TYPE C VALUE 'ASX@34',

B.

DO 50 TIMES VARYING B FROM A0(1) NEXT A1(1) RANGE A.

IF B NA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

MESSAGE 'Non english char found' TYPE 'I'.

EXIT.

ENDIF.

ENDDO.

Former Member
0 Kudos

Hi,

By English Characters do you mean only Alphabets and numbers? In that case you do a check of

Contains only CO 'ABCDEFGH.......XYZ'. Similarly for small case 'abcde...xyz'.

Please let me know if this helps.

Regards,

Devendra

0 Kudos

Hi,

I am fine with english characters A-Z, a-z or 0-9 or special characters. But it contains some chinese, japanes or non-english language characters which I dont want.

The logic explained by you above would expect me to list all the valid characters. Also it would be a performance constraint. Hence i wanted something as FM or standard procedure. Can we use ASCII somehow ?

Regards,

Nirmal

0 Kudos

I think comparing it with hex values (ASCII) will be bad option in Unicode system. You don't know it UTF-8, 16 or what else is used and if you try to compare it with hex character it may give unexpected results.

I think other option of CO is better in this case.

Regards,

Mohaiyuddin

0 Kudos

Hi Mohaiyuddin,

CO option is fine. But I have to check it for approx 4-5 fields in KNA1 with approx 50 chars each. And this then need to be applied for approx 1 million records. I am thus worried about performance.

Please guide.

Regards,

Nirmal Daswani

0 Kudos

you may check if this is helpful

Regards,

Mohaiyuddin

Former Member
0 Kudos

Hi,

Even if the variable holds other then english chars then you can check the variable cotains the english alphabets or not. for this you can try with SY-ABCDE contains the English alphabets,

Exanm If Variable CO sy-abcde.