Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem with data type Xstring

Former Member
0 Likes
1,442

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.

     
    

6 REPLIES 6
Read only

venkat_aileni
Contributor
0 Likes
1,245

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

Read only

0 Likes
1,245

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'.

Read only

0 Likes
1,245
Read only

0 Likes
1,245

128 is hex ? are u sure ? coz i dont think hex has consists of a 3 digit number.

Read only

Former Member
0 Likes
1,245

Hi

I solved my self....Thnx

Read only

0 Likes
1,245

Paste your solution. It will be helpful for others.