2009 Jul 19 4:46 PM
Dear experts,
I have a problem with non-printable character and maybe Unicode.
************
SPLIT string AT CL_ABAP_CHAR_UTILITIES=>horizontal_tab INTO TABLE itabx.
LOOP AT itabx.
MOVE itabx TO iv_string.
TRANSLATE iv_string TO UPPER CASE.
LOOP AT idetails INTO wa_idetails.
IF wa_idetails-name CS iv_string.
APPEND wa_idetails TO idetails_new.
ELSE.
CONTINUE.
ENDIF.
ENDLOOP.
ENDLOOP.
************
In this code I'm comparing the values in two internal tables. If I'm comparing the value 'KOKRS' the hex value in variable iv_string is '004B004F004B0052005300A' and the value in wa_idetails is '004B004F004B00520053002' and some other '002' at the end (are the same - not relevant).
The problem is with the value '00A' at the end of the first variable - it should be a non-breakable space I guess. I tools like 'KOKRS ' (there is a space behind string kokrs). I need to delete this "space" from this varaible.
Any suggestion?
<<text removed>>
Thanks in advance.
Edited by: Matt on Jul 20, 2009 7:37 PM - Please read the Rules. Don't offer points.
2009 Jul 19 5:41 PM
first of all, you should not say "I will give rewards" as explained in forum rules of engagement. This is obvious you'll do so, otherwise you should not post in this forum.
About your question, I'd like to say "just remove the last character" (like using len = STRLEN( iv_string ) to determine length, then using SUBTRACT 1 FROM len, and iv_string = iv_string( len ), don't forget to check the empty string of course), but there is something strange in your hex code, why do you have only "00A" and "002", it should be "00A?" or "002?", could you please check that and tell us which hex value you have exactly.
2009 Jul 19 5:41 PM
first of all, you should not say "I will give rewards" as explained in forum rules of engagement. This is obvious you'll do so, otherwise you should not post in this forum.
About your question, I'd like to say "just remove the last character" (like using len = STRLEN( iv_string ) to determine length, then using SUBTRACT 1 FROM len, and iv_string = iv_string( len ), don't forget to check the empty string of course), but there is something strange in your hex code, why do you have only "00A" and "002", it should be "00A?" or "002?", could you please check that and tell us which hex value you have exactly.
2009 Jul 20 9:50 AM
Hello Sandra,
Thanks for the advice and training in SDN rules - I don't post too often and I'm quite new to ABAP.
Anyway I got the error message: "Unable to interpret "KOKRS " as a number." using your solution with SUBTRACT command.
btw: I have a char(30) variable iv_string which has a value KOKRS and its hex value (in the debugger) is: 004B004F004B0052005300A0002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020. The problem is that there is a space character (value 00A) after the KOKRS.
When I'm comparing this to variable wa_idetails-name, also char(30), which has value KOKRS, but its hex is: 004B004F004B005200530020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020..
The value 00A - the space, makes the result FALSE while comparing them. I see the hex value only in the debugger.
Thanks in advance,
Petr
2009 Jul 20 10:22 AM
you must declare LEN as a number : DATA len TYPE i. It will work.
Your mistake in the posts is that the character is 00A0 (non-break spacei in unicode), please stop using 00A (and it's not 002, it's 0020 ).
2009 Jul 20 2:25 PM
I've finally get to the right solution - I didn't use the solution with changing the length of the value until you pointed me to it. Thanks a lot.
pk