Application Development 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: 

Get value into char from field-symbol (of type Decimal)

Former Member
0 Kudos

Hi all,

I've a problem in my report. I want to retrieve value from field-symbol but I don't manage.

My field-symbol is of type Decimal ('P') and I must retrieve this value in field (char255).


      ASSIGN COMPONENT ls_fieldcat-field OF STRUCTURE <fs_line> TO <fs_field>.
      ls_tab-field = ls_fieldcat-field.
      MOVE <fs_field> TO ls_tab-value.
        
      APPEND ls_exit TO t_exit.

If anybody have an idea.

Thanks and regards.

Romain L.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos


field-symbols: <fs_field> type any.   "<-- Make this type ANY

ASSIGN COMPONENT ls_fieldcat-field OF STRUCTURE <fs_line> TO <fs_field>.
      ls_tab-field = ls_fieldcat-field.
      MOVE <fs_field> TO ls_tab-value.
        
      APPEND ls_exit TO t_exit.

Regards,

Rich Heilman

5 REPLIES 5

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos


field-symbols: <fs_field> type any.   "<-- Make this type ANY

ASSIGN COMPONENT ls_fieldcat-field OF STRUCTURE <fs_line> TO <fs_field>.
      ls_tab-field = ls_fieldcat-field.
      MOVE <fs_field> TO ls_tab-value.
        
      APPEND ls_exit TO t_exit.

Regards,

Rich Heilman

MarcinPciak
Active Contributor
0 Kudos

or... using CASTING addition


field-symbols <fs_field> type char255.

ASSIGN COMPONENT ls_fieldcat-field OF STRUCTURE <fs_line> TO <fs_field> CASTING. "casting during assignment
ls_tab-field = ls_fieldcat-field.
MOVE <fs_field> TO ls_tab-value.
        
APPEND ls_exit TO t_exit.

This however might result in runtime error if types are incompatible. You have to try this out. The best would be using generic field symbols as suggested by Rich.

Regards

Marcin

Former Member
0 Kudos

Thanks for your answers,

I have declared <fs_field> of type ANY.

and ls_tab of type char 255. For NUMC, INT, CHAR it's work but not for DECIMAL.


ASSIGN COMPONENT ls_fieldcat-field OF STRUCTURE <fs_line> TO <fs_field>.
      ls_tab-field = ls_fieldcat-field. 
      MOVE <fs_field> TO ls_tab-value.     "<fs_field> =1 
      APPEND ls_tab TO t_exit.

In debug mode, I see that <fs_field> = 1.

The problem it's just when I do the move instruction. "ls_tab-value" don't change and keep 0.

If you have another idea..

Best Regards

Romain L.

0 Kudos

Use write instead move


write <fs_field> TO ls_tab-value.     

Regards

Marcin

0 Kudos

Try using this instead of MOVE

ASSIGN COMPONENT ls_fieldcat-field OF STRUCTURE <fs_line> TO <fs_field>.
      ls_tab-field = ls_fieldcat-field. 
      ls_tab-value = <fs_field>.
*      MOVE <fs_field> TO ls_tab-value.     "<fs_field> =1 
      APPEND ls_tab TO t_exit.

Regards,

Rich Heilman