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

Conversion

Former Member
0 Likes
666

Hi,

How to convert char type to currency field type to printing in the form with comma's in 100th place etc.

regards,

Ram

5 REPLIES 5
Read only

Former Member
0 Likes
610

use function strlen and offset

data str type string.

str = '123456'.

len = strlen(str).

or try CHAR_FLTP_CONVERSION fm

Read only

0 Likes
610

data str type string.

data len type i.

data pos type i.

data ch type c.

data curr type string.

data val type i.

str = '123456'.

len = strlen(str).

pos =1.

do len times.

ch = str( len - pos + 1 ).

val = pos / 3.

if val = 0..

concatenate ch ',' curr into curr.

else

concatenate ch curr into curr.

endif.

pos = pos + 1.

enddo.

write curr.

reward appriciated if info provided above worthy

Read only

0 Likes
610

Hi,

I did SAP Script for getting customer balance statement from f.27. Everything went well with only one problem. I am calculating the Total due on some date. the currency i converted into number with decimal places of 2 & calculated. I want this field when it prints in the script it should print with comma as currency field but here for me it is printing as number only without commas only decimal places.

for example the field x = 31145.00 I got from print program it is printing the same way. I want it printed as 31,145.00. How can solve this problem from number with decimal place to currency field in script it has to print. Kindly help me out.

In form i wrote da code as

Perform GET_CURR in program zfir0007.

USING &RF140-SALDO&

USING &RF140-WAERS&

changing &msaldo&

endperform.

Total Due : &msaldo&.

But it is just printing as number like 31145.00. I want the number field to be converted into currency field & to be printed in my form like 31,145.00.

Kindly help me out.

Regards,

Ram

Read only

Former Member
0 Likes
610

hi,

this sample on currency conversion might help u.

DATA: gd_fcurr TYPE tcurr-fcurr,

gd_tcurr TYPE tcurr-tcurr,

gd_date TYPE sy-datum,

gd_value TYPE i.

gd_fcurr = 'EUR'.

gd_tcurr = 'GBP'.

gd_date = sy-datum.

gd_value = 10.

PERFORM currency_conversion USING gd_fcurr

gd_tcurr

gd_date

CHANGING gd_value.

  • Convert value to Currency value

&----


*& Form currency_conversion

&----


  • text

----


  • -->P_GD_FCURR text

  • -->P_GD_TCURR text

  • -->P_GD_DATE text

  • <--P_GD_VALUE text

----


FORM currency_conversion USING p_fcurr

p_tcurr

p_date

CHANGING p_value.

DATA: t_er TYPE tcurr-ukurs,

t_ff TYPE tcurr-ffact,

t_lf TYPE tcurr-tfact,

t_vfd TYPE datum,

ld_erate(12) TYPE c.

CALL FUNCTION 'READ_EXCHANGE_RATE'

EXPORTING

  • CLIENT = SY-MANDT

date = p_date

foreign_currency = p_fcurr

local_currency = p_tcurr

TYPE_OF_RATE = 'M'

  • EXACT_DATE = ' '

IMPORTING

exchange_rate = t_er

foreign_factor = t_ff

local_factor = t_lf

valid_from_date = t_vfd

  • DERIVED_RATE_TYPE =

  • FIXED_RATE =

  • OLDEST_RATE_FROM =

EXCEPTIONS

no_rate_found = 1

no_factors_found = 2

no_spread_found = 3

derived_2_times = 4

overflow = 5

zero_rate = 6

OTHERS = 7

.

IF sy-subrc EQ 0.

ld_erate = t_er / ( t_ff / t_lf ).

p_value = p_value * ld_erate.

ENDIF.

ENDFORM. " currency_conversion

See the below link for explanation and a Program

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/fmCurrencyConversion&

reward if found useful,

cheers,

nithin

Read only

0 Likes
610

????? what does this code do

please read the question again