05-25-2006 11:30 AM
Hi all,
I have a variable whose datatype is N and the value is
000150000
I want to convert this as a currency like
1,50,000.00
Regards,
sinthu
05-25-2006 11:31 AM
Hii
Use command PACK and UNPACK
or
DATA: c LIKE bseg-dmbtr ," currency field
n(13) TYPE n VALUE '1234.56'.
<b>WRITE n TO c.</b>
WRITE:/ C .
THIS WILL CHANGE NUMERICAL TO CURRENCY FIELD
Reward points if helpful
Regards
Naresh
05-25-2006 11:34 AM
05-25-2006 11:35 AM
Try this..
data: n(10) type n value '1123456'.
data: p type p decimals 2.
p = n.
05-25-2006 11:38 AM
05-25-2006 11:43 AM
I want to convert these inside my sapscript. how can i dot that?
Any help?
05-25-2006 11:55 AM
hi
u can write a perform ..endperform inside ur script to this work
/: perform get_currency in program zxyz using STR
CHANGING CURRENCY
/: ENDPERFORM
FORM get_Currency TABLES ITAB STRUCTURE ITCSY
OTAB STRUCTURE ITCSY.
DATA: V_STR TYPE STRING,
V_CURR TYPE BETRG.
READ TABLE ITAB WITH KEY NAME = 'STR'.
V_STR = ITAB-VALUE.
CALL FUNCTION HRCM_STRING_TO_AMOUNT_CONVERT
IMPORTING
VALUE(STRING) = V_STR
VALUE(DECIMAL_SEPARATOR) OPTIONAL
VALUE(THOUSANDS_SEPARATOR) OPTIONAL
VALUE(WAERS) DEFAULT SPACE
EXPORTING
VALUE (BETRG) = V_CURR
EXCEPTIONS
CONVERT_ERROR
READ TABLE OTAB WITH KEY NAME = 'CURRENCY'.
OTAB-VALUE = V_CURR.
APPEND OTAB.
ENDFORM.
Message was edited by: Ganesh Mynampati
05-25-2006 12:00 PM
05-25-2006 12:01 PM
Hii
u can write it using perform ..endperform
DATA : c1 TYPE n, c2 TYPE n, res TYPE c.
c1 = 1000.
data: subroutinename(3) VALUE 'convert'.
PERFORM (subroutinename) IN PROGRAM Y_JJTEST1USING c1 CHANGING res.
write c1 to res .
WRITE:/ res.
*&----
*
*& Form convert
*&----
*
text
*----
*
form convert using p_c1 changing value(p_res).
p_res = p_c1
endform. " convert
05-30-2006 6:07 PM
Hi
Define any currency variable.
data: dmbtr like bkpf-dmbtr.
data: w_dmbtr(16)
w_usd = 'USD'.
move value(00015) to dmbtr.
Write dmbtr to w_dmbtr currency W_USD.
Hope this might help.
Thanks
Niranajn