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

Unicode error: x and y are not mutually convertible in unicode program

Former Member
0 Likes
4,412

Hi Experts,

I have declared as follows:

->DATA: BEGIN OF ACTIVITY,
RF_NUMBER LIKE ZUIHNVLB-RF_NUMBER,
SPACE1(3) TYPE C VALUE ' ',
CREATE_DT LIKE ZUIHNVLB-CREATE_DT,
SPACE2(3) TYPE C VALUE ' ',
CREATE_TM LIKE ZUIHNVLB-CREATE_TM,
SPACE3(3) TYPE C VALUE ' ',
ELPSD_TM LIKE ZUIHNVLB-ELPSD_TM,
SPACE4(3) TYPE C VALUE ' ',
CREATE_ID LIKE ZUIHNVLB-CREATE_ID,
CHANGE_ID LIKE ZUIHNVLB-CHANGE_ID,
END OF ACTIVITY.

->DATA: DESCRIPTION LIKE ZUWB01-WB_DESC.

->LOOP AT RF_TABLE.
ACTIVITY-RF_NUMBER = RF_TABLE-RF_NUMBER.
ACTIVITY-CREATE_DT = RF_TABLE-CREATE_DT.
ACTIVITY-CREATE_TM = RF_TABLE-CREATE_TM.
ACTIVITY-ELPSD_TM = RF_TABLE-ELPSD_TM.
ACTIVITY-CREATE_ID = RF_TABLE-CREATE_ID.
ACTIVITY-CHANGE_ID = RF_TABLE-CHANGE_ID.

MOVE ACTIVITY TO DESCRIPTION. ----->Here iam moving
MOVE RF_TABLE-RF_NUMBER TO KEYINFO.
MOVE ' ' TO DISPLAY_FM.
MOVE VB_OBEX TO EXECUTE_FM.
MOVE INDICATOR_ON TO CHANGE_FLAG.
MOVE INDICATOR_ON TO CREATE_FLAG.

INCLUDE ZUIN0138.
ADD 1 TO SEQ.
APPEND LEVEL_TABLE.
ENDLOOP.

ERROR: "Description" & "Activity" are not mutually convertible in Unicode program.

Please suggest what to do, a fast response would be appreciated.

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
3,995

"One field in ACTIVITY is a decimal type". Yeah - that's why you can't do a straight move. You need to get the decimals into a character format. For that use WRITE ... TO...

Let's say that field is called "AMOUNT".

Create a new structure, ACTIVITY_CHAR with the same field names as ACTIVITY, except for AMOUNT, which you call AMOUNT_CHAR (Type C length 17... or whatever).

MOVE-CORRESPONDING activity TO activity_char.
WRITE activity-amount TO activity_char-amount_char NO-GROUPING RIGHT-JUSTIFIED.
description = activity_char.

Hi Experts,

I have declared as follows:

->DATA: BEGIN OF ACTIVITY,
RF_NUMBER LIKE ZUIHNVLB-RF_NUMBER,
SPACE1(3) TYPE C VALUE ' ',
CREATE_DT LIKE ZUIHNVLB-CREATE_DT,
SPACE2(3) TYPE C VALUE ' ',
CREATE_TM LIKE ZUIHNVLB-CREATE_TM,
SPACE3(3) TYPE C VALUE ' ',
ELPSD_TM LIKE ZUIHNVLB-ELPSD_TM,
SPACE4(3) TYPE C VALUE ' ',
CREATE_ID LIKE ZUIHNVLB-CREATE_ID,
CHANGE_ID LIKE ZUIHNVLB-CHANGE_ID,
END OF ACTIVITY.

->DATA: DESCRIPTION LIKE ZUWB01-WB_DESC.

->LOOP AT RF_TABLE.
ACTIVITY-RF_NUMBER = RF_TABLE-RF_NUMBER.
ACTIVITY-CREATE_DT = RF_TABLE-CREATE_DT.
ACTIVITY-CREATE_TM = RF_TABLE-CREATE_TM.
ACTIVITY-ELPSD_TM = RF_TABLE-ELPSD_TM.
ACTIVITY-CREATE_ID = RF_TABLE-CREATE_ID.
ACTIVITY-CHANGE_ID = RF_TABLE-CHANGE_ID.

MOVE ACTIVITY TO DESCRIPTION. ----->Here iam moving
MOVE RF_TABLE-RF_NUMBER TO KEYINFO.
MOVE ' ' TO DISPLAY_FM.
MOVE VB_OBEX TO EXECUTE_FM.
MOVE INDICATOR_ON TO CHANGE_FLAG.
MOVE INDICATOR_ON TO CREATE_FLAG.

INCLUDE ZUIN0138.
ADD 1 TO SEQ.
APPEND LEVEL_TABLE.
ENDLOOP.

ERROR: "Description" & "Activity" are not mutually convertible in Unicode program.

Please suggest what to do, a fast response would be appreciated.

14 REPLIES 14
Read only

RaymondGiuseppi
Active Contributor
3,995

Welcome to Unicode world...

  • First check every field is correcly defined (no packed subfield to character subfield or so)
  • Then if some fields are not character type, look at online documentation on ASSIGN CASTING option (or use provided tools such as CL_ABAP_CONTAINER_UTILITIES, actually read the code of this class for some hints)
Read only

0 Likes
3,995

fields are correctly defined and I cannot change it as it may be used anywhere else.

When using:

call method cl_abap_container_utilities=>read_container_c

exporting

im_container = activity

importing

ex_value = description

exceptions

illegal_parameter_type = 1

others = 2.

it gives error as: "Activity" is not type-compatible with formal parameter "Im_container"

but if I pass any particular field like, activity-rf_number in "Im_conatiner" parameter then its not showing error. But I need all contents of Activity. Please guide for he same.

Read only

0 Likes
3,995

Try to define a temporary field, 'the container', a character type wide enough , try type STRING. Read source structure into this container and then fill target structure from this container.

Read only

Former Member
0 Likes
3,995

Hi Experts,

I would like to mention that :

ELPSD_TM LIKE ZUIHNVLB-ELPSD_TM,

field in ACTIVITY is decimal type.

While Description's field: ZUWB01-WB_DESC is char type.

Read only

3,995

Moving a packed field to character may give unpredictable results (garbage characters)

Read only

0 Likes
3,995

Hi Raymond,

Yes that's what I am getting when using

"cl_abap_container_utilities=>fill_container_c". How can I get non-garbage values please suggest.

Thanks.

Read only

3,995

So MOVE of structure is not a good idea, use some CORRESPONDING statement or even loop on fields indiviaually. (Also it should not work even if not Unicode...)

Read only

monalisa_biswal
Contributor
3,995

If the structure contains non-character type field, it will lead to mutually unconvertible error in unicode system. You can use following code to move data from structure to string .

CALL METHOD cl_abap_container_utilities=>fill_container_c
  EXPORTING
    im_value               = activity
  IMPORTING
    ex_container           = description
  EXCEPTIONS
    illegal_parameter_type = 1
    OTHERS                 = 2.


Read only

0 Likes
3,995

Hi Monalisa,

I tried your suggestion but the value in 'description' is not coming correct. The decimals value are coming like '#########'. Any suggestion on this like how can I get exact values from activity into description?

Read only

DoanManhQuynh
Active Contributor
3,995

Unicode system dont accept that kind of move thats why you have error. Solution is depend on what you want to do.

in your code, i see that you move data from a table to ACTIVITY structure which have all the fields as character type. If data in activity already correct,i think it quite simple by just CONCATENATE all the activity fields into description....

Read only

0 Likes
3,995

Hi Quynh,

Iam moving data from ACTIVITY to DESCRIPTION. One field in ACTIVITY is a decimal type.

Read only

3,995

So you may have to use RTTS to check the field type....you may find solution from bellow thread, i dont have time right now to check the solution:

https://archive.sap.com/discussions/thread/1136219

Read only

matt
Active Contributor
3,996

"One field in ACTIVITY is a decimal type". Yeah - that's why you can't do a straight move. You need to get the decimals into a character format. For that use WRITE ... TO...

Let's say that field is called "AMOUNT".

Create a new structure, ACTIVITY_CHAR with the same field names as ACTIVITY, except for AMOUNT, which you call AMOUNT_CHAR (Type C length 17... or whatever).

MOVE-CORRESPONDING activity TO activity_char.
WRITE activity-amount TO activity_char-amount_char NO-GROUPING RIGHT-JUSTIFIED.
description = activity_char.
Read only

matt
Active Contributor
0 Likes
3,995

Should be left-justified.