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

Get Language character from String

Former Member
0 Likes
1,475


hi All,

My requirment is to get character from String

for E.G.

   hithisistest_EN.Doc this is my text

   now i want to onaly EN in my result.

Also check whether this language is exist or not in system?

Thanks,

Mahipal

9 REPLIES 9
Read only

harshal_d
Explorer
0 Likes
1,233

Hi,

Is the format of text going to be same as you have mentioned in your example??

Read only

Former Member
0 Likes
1,233

Yes Every time

Read only

0 Likes
1,233

Try this.

lv_str = 'hithisistest_EN.Doc'

split lv_str at '_' into lv_str1 lv_str2.

split lv_str2 at '.' into lv_str1 lv_str2.

lv_str1 will contain 'EN'

Check it in T002 table.

Read only

Former Member
0 Likes
1,233

every time EN is not fixed but there should be any two character of language in SAP

Read only

0 Likes
1,233

As long as your text contains  '_' and '.' above code will work fine.

You can test it by replacing text with any value. Variable lv_str1 will contain text that follows '_' and precedes '.'.

Read only

Former Member
0 Likes
1,233

i am looking for any direct Keyword in ABAP which is giving expected Result

Read only

0 Likes
1,233

Mahipalsinh Parmar wrote:

i am looking for any direct Keyword in ABAP which is giving expected Result

Sometimes you just have to roll up your sleeves and write code.

Rob

Read only

Former Member
0 Likes
1,233

DATA: lo_matcher TYPE REF TO cl_abap_matcher,

       ls_result  TYPE match_result,

       lv_lang    TYPE sy-langu.

lo_matcher = cl_abap_matcher=>create(

   pattern = '\_([A-Z]{2})\.'

   text    = 'hithisistest_EN.Doc' ).

lo_matcher->find_next( ).

lv_lang = lo_matcher->get_submatch( 1 ).

WRITE lv_lang.

Read only

0 Likes
1,233

To complement the table with languages is the T002 but if you wanna know only languages installed (Founded in transaction SMLT), so you need check the T002C table and looking up rows with X value on LAINST field.