Application Development 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: 

convert to c

Former Member
0 Kudos

Hi,

How to convert QUAN and CURR types to C ...because i m using these values in concatenate statement..

Thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

u can use the standard function module to convert Quan to CURR... i think the FM is.. conv_quan_To_XXX

sap has provided many standard FM for conversions..

this may help you ...

9 REPLIES 9

Simha_
Employee
Employee
0 Kudos

Hi,

Just declare another variable of type c and same length as that of currency type.

Then u move this currency field to character variable.

Hope this helps..

Cheers,

Simha.

former_member181962
Active Contributor
0 Kudos

Use the write statement to move the conetents of these fields into a type c field of appropriAte length.

Regards,

ravi

Former Member
0 Kudos

Hi,

As Simha has already mentioned tht take a variable of type c and move contents of quantity to variable...

This will surely work...

Regards.

Seema.

Former Member
0 Kudos

Hi,

Use <b>Write</b> statement with its Option like currency to move contents to destination field of type c.

Regds,

Akshay

Former Member
0 Kudos

Hi,

You can do it using WRITE..TO or MOVE statement.

When to use which depends on your requirement.

This is what SAP Documentation says.

If the target field has type C, you must decide between MOVE and WRITE TO. The MOVE statement is intended for assignments within a program, and it generates a standard display that is compatible with the source type. This can be converted back into the original value using MOVE again, as long as it was not truncated in the assignment. For this reason, the period (.) is always used as the decimal sign, and dates cannot be converted, regardless of the user defaults.

You use the WRITE TO statement to generate a readable ('external') display for the value of the source field. The target field is usually displayed on a screen or in a list, after further processing if necessary. Unlike MOVE, WRITE TO has several formatting options, which, for some data types, are user-defined. A conversion exit may be called implicitly.

For More Info press F1 on <b>MOVE</b>

Consider this code.


REPORT zarun_2.


DATA  : quan      TYPE marc-bstrf,
        curr      TYPE marc-losfx,
*       Calculate the Length of the Table Field Initially referring the Dataelement
        cquan(17) TYPE c, "BSTRF	QUAN	13(Length)   +  3(No of Decimals) + Decimal point
        ccurr(14) TYPE c. "LOSFX	CURR	11(Length)   +  2(No of Decimals) + Decimal point


quan = '123456.564'.
curr = '123.50'.

WRITE : /'Before Conversion       ',
         'QUAN:', quan,
         'CURR:', curr.

MOVE quan TO cquan.
MOVE curr TO ccurr.
WRITE : /'Conversion using  MOVE  ',
         'QUAN:', cquan,
         'CURR:', ccurr.




WRITE quan TO cquan.
WRITE curr TO ccurr.
WRITE : /'Conversion using  WRITE ',
         'QUAN:', cquan,
         'CURR:', ccurr.

Regards,

Arun Sambargi.

0 Kudos

Its not working....

0 Kudos

Hi,

Can u specify how are you concatenating or wats the problem.

A sample code will be helpful .

Regards,

Arun S.

0 Kudos

Declare a variable of length xx type c. xx is the output length that is there in the attributes of the domain of the currency/quantity field that you are looking at.

Then do a WRITE mycurrency/quantityfield TO mycharvariable CURRENCY/UNIT yyy where yyy is the currency key or quantity unit of measurement depending on which one you are working with. It is important that you use this to get the right number of decimals. You can also use the option NO-GROUPING to eliminate the thousands separator.

Former Member
0 Kudos

u can use the standard function module to convert Quan to CURR... i think the FM is.. conv_quan_To_XXX

sap has provided many standard FM for conversions..

this may help you ...