2013 Nov 16 3:51 PM
Hi
I have facing an issue when assigning string to X-String.
DATA : lv_string TYPE string,
lv_xstring type xstring.
lv_string = '128'.
lv_xstring = lv_string.
Lv_xstring value is getting changed to '1280' , Additionally zero is getting added , I have tried with many solutions.
How to avoid adding additional zero to lv_xstring fired.
But still facing the same issue.
2013 Nov 16 4:33 PM
Hi-
What's your exact requirement? Why are you directly converting a variable from string to xstring, please use standard FM's like : 'SCMS_STRING_TO_XSTRING' or 'HR_KR_STRING_TO_XSTRING'.
Also have you observed below things like:
*If your string starts with with a character value after this step lv_xstring = lv_string, lv_xstring will hold nothing means space.
*Also say lv_string = 128 after moving to lv_xstring it will hold 1280 as you said.
*Also say lv_string = 128xyzzzz after moving to lv_xstring even this will hold 1280.
-Venkat
2013 Nov 16 4:39 PM
Hi Venkat ,
My requirement is to convert the input value to Binary , Here the Input is Hexa value.
Please see the below code , when I assign value to lv_xstring
lv_text is string.
lv_text = '128'. " This input is dynamic , User can give in selection screen.
CLEAR lv_text.
** calculate length
lv_length = XSTRLEN( lv_xstring ) * 8.
WHILE sy-index <= lv_length.
GET BIT sy-index OF lv_xstring INTO lv_value.
MOVE lv_value TO lv_input.
CONCATENATE lv_text lv_input INTO lv_text.
ENDWHILE.
** delete leading zeros
SHIFT lv_text LEFT DELETING LEADING '0'.
2013 Nov 16 6:52 PM
Hi Nagesh,
See if this helps -
http://saptib.blogspot.in/2008/07/translate-hexadecimal-to-binary-to.html.
BR.
2013 Nov 16 7:20 PM
128 is hex ? are u sure ? coz i dont think hex has consists of a 3 digit number.
2013 Nov 17 6:22 AM
2013 Nov 17 7:27 AM