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

Misunderstanding as work ASSIGN statement

Former Member
0 Likes
738

Hello every body. I work with this statement seldom and it is not problem. But I try execute next snip of code for study aim.


REPORT  ztest.

TYPES float TYPE p LENGTH 6 DECIMALS 0.

DATA a TYPE c LENGTH 1000.

DATA b TYPE float.

FIELD-SYMBOLS <value> TYPE x.

FIELD-SYMBOLS <value_new>.

ASSIGN a(6) TO <value> CASTING.

b = 1200.

<value> = b.

ASSIGN a(6) TO <value> CASTING.

ASSIGN <value> TO <value_new> CASTING DECIMALS 0.

WRITE <value_new>.

On screen out value  '4;' , but I wait 1200.  Pls, explain me this answer.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
703

Hi Ivan

Change your declaration statement for <value> to be as follows and you problem will be solved :

FIELD-SYMBOLS <value> TYPE float.

Hello every body. I work with this statement seldom and it is not problem. But I try execute next snip of code for study aim.


REPORT  ztest.

TYPES float TYPE p LENGTH 6 DECIMALS 0.

DATA a TYPE c LENGTH 1000.

DATA b TYPE float.

FIELD-SYMBOLS <value> TYPE x.

FIELD-SYMBOLS <value_new>.

ASSIGN a(6) TO <value> CASTING.

b = 1200.

<value> = b.

ASSIGN a(6) TO <value> CASTING.

ASSIGN <value> TO <value_new> CASTING DECIMALS 0.

WRITE <value_new>.

On screen out value  '4;' , but I wait 1200.  Pls, explain me this answer.

3 REPLIES 3
Read only

Former Member
0 Likes
704

Hi Ivan

Change your declaration statement for <value> to be as follows and you problem will be solved :

FIELD-SYMBOLS <value> TYPE float.

Read only

0 Likes
703

Thanks for your answer and correct solution, but why my example don't work. I my mind program do next: 0x0000000004B0(hex code of 1200) save in char area, and after that do back transform to dec value. Where am I mistake?

Read only

0 Likes
703

I seems understand. Assignment statement doesn't do any transformation. It is only reflect byte sequence to field symbol. Abap inside hex code for value 1200 - 00000001200C, not 0000000004B0.