2015 Apr 13 9:46 AM
Hi Experts,
I am facing some problem while reading XML attachment in class CL_DOCUMENT_BCS.
While reading contents_hex values I am getting garbage values like '0000000000000' at end of string.
I tried to convert the xstring values to string
and those values became '################################' .
But couldn't remove same using all standard process.
like
1) REPLACE all occurrences of '##' IN:
lv_string WITH ' ' .
2) TRANSLATE lv_string using '## '.
However if I copy same string to normal SE38 editor and apply above mentioned approach it works.
I searched relevant issues posted but couldn't find concrete solution for same.
2015 Apr 13 3:05 PM
Hi Sandeep,
Try to use the method xstring_to_solix in CL_DOCUMENT_BCS to convert the xstring into string.Apply the replace occurance rule and try.
Regards,
Kannan
Hi Experts,
I am facing some problem while reading XML attachment in class CL_DOCUMENT_BCS.
While reading contents_hex values I am getting garbage values like '0000000000000' at end of string.
I tried to convert the xstring values to string
and those values became '################################' .
But couldn't remove same using all standard process.
like
1) REPLACE all occurrences of '##' IN:
lv_string WITH ' ' .
2) TRANSLATE lv_string using '## '.
However if I copy same string to normal SE38 editor and apply above mentioned approach it works.
I searched relevant issues posted but couldn't find concrete solution for same.
2015 Apr 13 10:08 AM
Hi Sandeep,
Since it is the end of string, new line or horizontal tab is appearing as '#' values. Try the below code and see if it helps,
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>CR_LF IN lv_string WITH space.
Regards,
~Athreya
2015 Apr 13 1:47 PM
Hi Athreya,
I have tried all below mentioned approach already.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN lv_string WITH space.
CONDENSE lv_string.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline IN lv_string WITH space.
CONDENSE lv_string.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN lv_string WITH space.
CONDENSE lv_string.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>vertical_tab IN lv_string WITH space.
CONDENSE lv_string.
none of them removed the garbage values.
Regards,
Sandeep
2015 Apr 13 3:05 PM
Hi Sandeep,
Try to use the method xstring_to_solix in CL_DOCUMENT_BCS to convert the xstring into string.Apply the replace occurance rule and try.
Regards,
Kannan
2015 Apr 14 9:41 AM
Hi Kannan,
Thnx for your reply.
But as I mentioned in my question I am getting this xstring by reading contents_hex values, which is a solix table only.
2015 Apr 14 9:48 AM
Go into debug and find out the hex values of the # characters.
2015 Apr 14 9:54 AM
Hi Mathew,
They are appearing as '0000000000000'. As I mentioned in my question.
Regards,
Sandeep
2015 Apr 14 10:24 AM
2015 Apr 14 3:24 PM
Thnx a lot Matthew. It worked. However I am still clueless why Replace of all occurrence didn't work.
2015 Apr 14 4:13 PM
Because when you type # in the abap editor, that is 0x23 which isn't the same as the null char, 0x00.
2015 Apr 14 4:43 PM
Hi,
I'm glad you got the solution already, but if the correct attachment size (not including the hex nulls padded to the last entry of solix_tab, in other words) is known, I'd use CL_BCS_CONVERT=>SOLIX_TO_XSTRING( ).
cheers
Jānis
2021 Apr 07 1:16 PM
Hi, maybe for someone will be interesting also this simple approach to remove this "garbage" character from string:
method remove_garbage_character.
data lv_white_characters type string.
lv_white_characters = cl_abap_char_utilities=>get_simple_spaces_for_cur_cp( ).
data: lv_lenght type i,
lv_i type i value 0.
lv_lenght = strlen( lv_white_characters ).
while lv_i < lv_lenght.
replace all occurrences of lv_white_characters+lv_i(1) in cv_string with ''.
lv_i = lv_i + 1.
endwhile.
endmethod.
CV_STRING is Changing parameter - TYPE String.
Enjoy, Z
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |