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

ASSIGN_TYPE_CONFLICT runtime error

Former Member
0 Likes
1,433

Hi experts,

Please see the below code:

FIELD-SYMBOLS :

<fs_selval> TYPE c.

DATA:

l_selfld(40) TYPE c.

l_selfld = 'KOMG-VGPOS'.

ASSIGN (l_selfld) TO <fs_selval>.

On running, I got the above mentioned dump.

Questions:

1) VGPOS is of type NUMC, which caused the error. How can this compatibility issue be resolved?

2) Why is ASSIGN (l_selfld) used instead of ASSIGN l_selfld   {without the brackets}...?

Regards,

Peter

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,081

1) Declare field symbol as

FIELD-SYMBOLS :

<fs_selval> TYPE any.

2) Brackets denote the value of the variable. Without brackets it directly assigns the variable to field symbol. Try doing both and check the difference in debugger

4 REPLIES 4
Read only

Former Member
0 Likes
1,082

1) Declare field symbol as

FIELD-SYMBOLS :

<fs_selval> TYPE any.

2) Brackets denote the value of the variable. Without brackets it directly assigns the variable to field symbol. Try doing both and check the difference in debugger

Read only

0 Likes
1,081

Hi Chinmay,

Thanks for the response.

Why is it that TYPE ANY is not recommended way of declaring?

Also can we declare field symbol without giving any type?

Thanks again,

peter

Read only

0 Likes
1,081

Hi Peter,

Type Any is generic type which determine at runtime. In this case Type Any has little bit slow performance wise comparatively with typed statement.

But in case of dynamic programing we don't know the type at the time of declaration.

Kind Regards

Ravi Lanjewar

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,081

Hello Peter,

I don't agree with Chinmay's suggestion to use TYPE ANY - it's half correct!

In your case you know the type of the data object whose memory address you want to assign & so TYPE ANY is not required.

You can use the CASTING addition of the ASSIGN statement to make your code work:

DATA: gv_numc TYPE vgpos VALUE 1.

FIELD-SYMBOLS: <gv_char> TYPE c.

* Cast the numeric type to a character field
ASSIGN ('GV_NUMC') TO <gv_char> CASTING.
IF <gv_char> IS ASSIGNED.
  WRITE: 'Numeric Value:'   , 20 gv_numc,
       / 'Character Value:' , 20 <gv_char>.
ENDIF.

In an Unicode(UC) environment data objects of TYPE c, n, d, t are referred to as character-like data types. Each character in the data object is represented by 2 bytes (in UC systems the system code page is UTF-16 ) - hence you will not face any conversion issues when assigning the memory address.

Try CASTING non character-type data objects (TYPE p, i, f) to a character-type field symbol.

BR,

Suhas    

Message was edited by: Suhas Saha