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

find double byte char in string

former_member220801
Participant
0 Likes
1,302

I have a string with both english and chinese character. Is there any method to extract only chinese character (should be dobule-byte, right?) from the string?

Thanks!

I have a string with both english and chinese character. Is there any method to extract only chinese character (should be dobule-byte, right?) from the string?

Thanks!

3 REPLIES 3
Read only

athavanraja
Active Contributor
0 Likes
875

check this link.

http://help.sap.com/saphelp_nw2004s/helpdata/en/79/c55479b3dc11d5993800508b6b8b11/content.htm

i guess you need to use CHARLEN and findout

Raja

Read only

0 Likes
875

I have read the char one by one and find the charlen...buth both chinese and english char return charlen = 1

Read only

0 Likes
875

Hi,

This may be a little late but here you go anyway:

Check this out:

The path for the entire structure to get the sample code is:

Program HTWCTXM0 > Include PCTXMTWS > etc etc

Check out include PCTXMTWS

There is a Form called get_addr

Inside this Form there's a FM HR_TW_ADDRESS.

This FM gets the IT0006 address details and somewhere down the liine runs a check to see if the "Full Address" has every character in double byte.

The "TW" part of it is Taiwan, (the address data needs to be in double byte chinese, so this FM runs the check on it)

In this FM it calls a form called chk_fulltyp.

In here it loops through each character of the given string and checks if the character is a double byte:

The section of code that does this:

 WHEN 2.
        dft_cnt = 0.
        tot_len = strlen( org_str ).
        while dft_cnt < tot_len.
          char = org_str+dft_cnt(1).
          point = cl_abap_conv_out_ce=>uccp( char ).
          if point <= last_ascii_zf.
            retcode = '1'.
            IF TYPE EQ 'A'.
              RAISE CONTAIN_NO_FULL_TYPE.
            ENDIF.
            dft_cnt = tot_len.              " FOR EXIT WHILE
          endif.
          dft_cnt = dft_cnt + 1.
        endwhile.

you could debug the variable "point" and see the double byte equivalent value for the current character in the string...

...and progress from there.

I do not know fully what cl_abap_conv_out_ce=>uccp does but it seems to return the double byte equivalent value. Please correct me if I am wrong on this.