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

type incompatibility between two structures in data type

SwarnaliBasu
Participant
0 Likes
1,060

hi

I have two structures, x_autwr and y_autwr, here the problem is data type of x_autwr is CURR ,15 and y_autwr is DEC, 23.

now when I write

x_autwr = y_autwr it gives an errornous data, for eg if the value of Y-autwr is 2000.0000, it transforms to x_autwr and makes it 200000.00,

PLease note that I cannot change the data type as its from standard, but I have tried taking to local variables of type i, c , or decimal of type 2,or divide by 100, but still no logic works.

Please help.

10 REPLIES 10
Read only

Former Member
0 Likes
1,001

Hey ,

there is a mismatch in your query , once u say they are structures , and next u r saying there data types. Please correct the question.

what do you need to achieve please specify that. that is the what format the value you expect in x_autwr , specify that .

So that I can help you.

Regards,

Uma Dave

Read only

0 Likes
1,001

I want to convert a variable(y_autwr) of data type decimal, 23 to a variable (x-autwr)of currency,15.

the e.g in my scenario is when

x_autwr = y_autwr, then it should take the correct value, so if y_autwr = 2000 then x_autwr shouldnt be any other value than 2000.

Please note these are just example, so please go by the content.

Read only

0 Likes
1,001

Hey u can do that

by maing use of a intermediate variable of type string.

str_temp type string.

str_temp = y_str.

x_str = str_temp.

Hope this will resolve your problem.

Regards,

Uma Dave

Read only

0 Likes
1,001

No

it doesnt solve my problem, as I said earlier I have use of local variables of type C, D, String. Nothing works.

for everything it gives error data with wrong decimal point.


l_amount_in type string,"p DECIMALS 2,
        l_amount_out TYPE string

l_amount_in = ccaut_save-autwv.
l_amount_out = ccaut_out-autwr.

 xfplt-autwv = ccaut_save-autwv.
 xfplt-autwr = ccaut_out-autwr.
this value in XFPLT comes as 200000.00. when ccaut_save-autwv value is 2000.000

Read only

Former Member
0 Likes
1,001

Hi,

Use the local varibales and make use of offsets or use conversion so that source and destination length will be same.

Regards,

Pravin

Read only

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

I think this assignment is not correct. The CURR fields are always associated with a CUKY, do you have the currency key with you ?

If yes, then you can try this logic:

x_autwr = y_autwr.

DATA:
 l_corr_factor TYPE i,
 ls_bapi1090_1 TYPE bapi1090_1.
  CALL FUNCTION 'BAPI_CURRENCY_GETDECIMALS'
    EXPORTING
      currency          = v_waers "Your Currency key field
    IMPORTING
      currency_decimals = ls_bapi1090_1.

    l_corr_factor = 10 ** ( lf_bapi1090_1-curdecimals ).

x_autwr = x_autwr / l_corr_factor.

BR,

Suhas

Read only

former_member194416
Contributor
0 Likes
1,001

Hi,

This problem is because of the decimal places. Try using "write to" instead of '=' with decimals edition. Check how to use it from ABAP keyword documentation.

write y_autwr to x_autwr decimals 4.

should work.

Edited by: Gungor Ozcelebi on Jul 2, 2010 2:22 PM

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,001

Try FM like CURRENCY_AMOUNT_DISPLAY_TO_SAP (reverse by CURRENCY_AMOUNT_SAP_TO_DISPLAY)

Regards,

Raymond

Read only

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

Hello Raymond,

In either case we need to have the currency key defined. Correct ?

BTW i was wondering if we can use the

WRITE ... TO ... CURRENCY ...

option.

BR,

Suhas

Read only

0 Likes
1,001

Hi Suhas

Please help me, I tried your solution, one of the structure has currency field , another one doesnt.

if I try to equate them still it doesnt work,

What shall I do?