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

Error while moving Data from <fs> to its corresponding Structure

Former Member
0 Likes
969

Hi Gurus,

I am getting a run time error (Operands are not Convertible) while executing the below statement:

MOVE <fs> TO ls_struc.

[ Over here: ls_struc is TYPE XYZ (a custom structure containg 7 fields, out of which one field is type Packed decimal, which is why I get a run time error) AND

<fs> is a field symbol which is containing the data for all fields in the structure XYZ ]

If I change the data type of packed decimal field in the structure: 'LS_STRUC' to 'char ' type, then the above query works.

Could anyone help in resolving this issue.

Thanks

Gaurav Verma

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
899

Hi Gverma09,

ABAP maintains certain rules for MOVE command. If you use variables (fields), it is checked at compile time if the MOVE is valid. Using field-symbols, this is checked at run time.

You can MOVE -> [Compatible Data Types |http://help.sap.com/abapdocu_702/en/abencompatibility.htm]

Regards,

Clemens

Hi Gurus,

I am getting a run time error (Operands are not Convertible) while executing the below statement:

MOVE <fs> TO ls_struc.

[ Over here: ls_struc is TYPE XYZ (a custom structure containg 7 fields, out of which one field is type Packed decimal, which is why I get a run time error) AND

<fs> is a field symbol which is containing the data for all fields in the structure XYZ ]

If I change the data type of packed decimal field in the structure: 'LS_STRUC' to 'char ' type, then the above query works.

Could anyone help in resolving this issue.

Thanks

Gaurav Verma

5 REPLIES 5
Read only

Clemenss
Active Contributor
0 Likes
900

Hi Gverma09,

ABAP maintains certain rules for MOVE command. If you use variables (fields), it is checked at compile time if the MOVE is valid. Using field-symbols, this is checked at run time.

You can MOVE -> [Compatible Data Types |http://help.sap.com/abapdocu_702/en/abencompatibility.htm]

Regards,

Clemens

Read only

Former Member
0 Likes
899

Thanks for your response.

This code snippet is part of a generic piece of code to read the BAPI extension Out Parameter and populate the values in the relevant structure field.

In the move statment:

MOVE <fs> TO ls_struc.

So 'Ls_struc' is the Changing Parameter in the Function Module Interface.

I defined its type as ANY/ left it blank; in either it does not work for one scenario - in which the Structure contains a field having packed decimal DATA TYPE.

And Eventually this changing parameter will hold the value of all the fields of the Structure.

P.S: <fs> and ls_struc in a way points to the same structure. Please let me know if there is any way to address this issue. Thanks.

Read only

Former Member
0 Likes
899

Thread Closed.

I could find the solution using the following Approach:

Replacing the MoVE statement by:

DATA linetype TYPE REF TO cl_abap_structdescr.

linetype ?= cl_abap_structdescr=>describe_by_name( im_stru_name ).

CREATE DATA e_dref TYPE HANDLE linetype.

GET REFERENCE OF <fs_struc_to> INTO e_dref.

And Later reading the Data in the following manner:

ASSIGN lv_dataref->* TO <fs>.

Thanks.

Read only

Clemenss
Active Contributor
0 Likes
899

Hi Gverma09,

Good!

you can do a bit simpler without structdescr and without handle:

CREATE DATA e_dref TYPE (im_stru_name).

or even

CREATE DATA e_dref like <fs>.

Access as you do now, eventually need second field-symbol.

ASSIGN lv_dataref->* TO <fs2>

The ABAP RTTS Run Time Type Services CL_ABAB_xyzDESCR are especially useful if you need to know all field properties of a structure or if you want to create structures and tables dynamically. In this case, CREATE DATA has the required features.

Regards,

Clemens

Read only

gabriel_pill-kahan
Active Participant
0 Likes
899

You probably should use MOVE-CORRESPONDING.