Skip to Content

How to handle null value in string and xstring?

Hi Guys,

I am facing problem with null values in string and it's hex code xstring. I have some data in one field with data type LCHR. This field contains data like :

"SAPMSDYP MBatch-Input ####%PC 60317081539#?"

I have one abap program. I am just appending this data to a string variable and then converting this string to xstring data. The length of the string is 53 and after conversion to xstring the length of xstring data is more then the string data. In string data wherever the "#" is there it is coming as "0000" in raw data(xstring). After this conversion i am just sending this data to my java program using http_client. At java side if the incoming data is having null value in-between data then this java program will reject this data. The main problem is i have to handle these null value in my abap program only.

At debugging time in variable details box also its hex value is showing as 0000 that is sap's default string to hex conversion. And if i move the mouse cursor on this variable then in hint box this single '#' is showing as 5 characters as CString.

For string to xstring conversion i am using the below code: CL_ABAP_CONV_OUT_CE=>create(

encoding = 'UTF-8'

endian = 'L' ).

conv->convert( EXPORTING data = text

IMPORTING buffer = buffer1 ).

Here i have to handle this null("#") value either in string data or in xstring data in ABAP program only. I don't know how to do this.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Oct 10, 2018 at 09:11 AM

    Why don't you handle the # sign with abap before sending it to your java application? You can build a construct with string functions.

    So you don't have to deal on the java-side:-)

    Here are some keywords to point you the correct documentation.

    String Functions, count, find, and match


    Add comment
    10|10000 characters needed characters exceeded

  • Oct 11, 2018 at 01:07 PM

    Hallo Ompal shekhawat,

    I think you have to check your XSTRING and if you found this 0x00, then you can remove it. By the way you may get this ### if there is new line 0x0a or break line 0x0D and you can remove them from your XSTRING.

    So, just these could help you

    Check if the string has 0x00 or 0x0a or 0x0D, then remove it.

    So, I would like you to read about these ASCII chart:

    common ascii codes to know

    Char  Dec  Oct  Hex   WhatAreThey
    (nul)   0 0000 0x00   Null 
    (ht)    9 0011 0x09   Horizontal Tab
    (nl)   10 0012 0x0a   New Line
    (vt)   11 0013 0x0b   Vertical Tab
    (cr)   13 0015 0x0d   Carriage Return
    (sp)   32 0040 0x20   Space

    For String, you can check this class


    Best regards

    Ebrahim Hatem

    abap1.jpg (156.8 kB)
    Add comment
    10|10000 characters needed characters exceeded

    • Hi Ebrahim Hatem,

      Thanks for the reply, I have tried all of the above solutions but nothing is working. In SAP GUI debugging window the hex value of # is showing as 0000 and in CString it shows as . I have tried all the above solution. Instead of this umlaut # if we have normal # then i am able to do any modification and for this normal # the SAP GUI will show the hex as 0023 which is correct. But this particular character is not normal #, only it looks like as #. Can you suggest me if it is null or anything other character. And this character is available in the table D345T and field is BLOCK(LCHR type).