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

convert char to ascii code and vice versa

HI

Is there any function module to convert char to ascii code and vice versa.

Thanks in advance

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Jun 20, 2006 at 05:38 AM

    hi mohan,

    i dont think you have one.

    but the below fm will convert the sapscript format to ascii and vice versa..

    <b>CONVERT_ASCII_TO_ITF Text Conversion ASCII to ITF (SAPscript Format)

    CONVERT_ITF_TO_ASCII Text Conversion ITF (SAPscript Format) to ASCII</b>

    Cheers,

    Abdul

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 20, 2006 at 05:35 AM

    hi Mohan,

    check the following Links

    ascii-code-for-a-character

    unicode-and-ascii-to-char

    If your problem solved then close this thread and mark useful answers

    regards

    Aashish Garg

    Message was edited by: aashish garg

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 20, 2006 at 05:36 AM

    Hi Mohan,

    Check the FM 'URL_ASCII_CODE_GET' for converting char to ascii code.

    For converting ASCII to char

    If you are R3 4.7 and above, try this one

    cl_abap_conv_in_ce=>uccp( 'XXXX' ).

    • XXXX is the ASCII code in hex code.

    • return value is the char you expected

    Regards,

    Mukesh Kumar

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 20, 2006 at 08:22 AM

    Hi,

    be careful if you have unicode running in your system. URL_ASCII_CODE_GET is platform-dependent so it will return the internal HERX representation of the character in your system - which is hopefully and in most cases ASCII.

    Under unicode, we use double-byte characters here. I tried this function and the result CHAR_CODE is '00' regardless what character I specify for TRANS_CHAR. But the coding is so simple I corrected resultig in this sample code:

    [P]

    • convert p_form to ASCII (internal) representation

    DATA:

    l_ofs TYPE syfdpos,

    l_len TYPE sy-linsz,

    l_ascii TYPE i.

    FIELD-SYMBOLS:

    <x> TYPE x.

    l_len = STRLEN( p_ascii ).

    DO l_len TIMES.

    l_ofs = sy-index - 1.

    ASSIGN p_ascii+l_ofs(1) TO <x> CASTING.

    l_ascii = <x>.

    WRITE: l_ascii.

    ENDDO.

    [/P]

    Here, for each character of string p_ascii, the internal (ASCII) representation is determined and written to the output list.

    Regards,

    Clemens

    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.