2011 Jul 21 9:18 PM
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
2011 Jul 21 10:56 PM
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
2011 Jul 21 10:56 PM
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
2011 Jul 22 12:16 AM
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.
2011 Jul 22 2:52 AM
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.
2011 Jul 22 6:45 PM
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
2011 Jul 21 11:38 PM