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
1,018

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

9 REPLIES 9
Read only

Former Member
0 Likes
979

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

Read only

Former Member
0 Likes
979

Use the FM:

HRCM_STRING_TO_AMOUNT_CONVERT

Regards,

Ravi

Read only

Former Member
0 Likes
979

Try this..

data: n(10) type n value '1123456'.

data: p type p decimals 2.

p = n.

Read only

rahulkavuri
Active Contributor
0 Likes
979

Please refer the above link and award points if found helpful

Read only

0 Likes
979

I want to convert these inside my sapscript. how can i dot that?

Any help?

Read only

Former Member
0 Likes
979

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

Read only

rahulkavuri
Active Contributor
0 Likes
979

U can use the code in the perform statements like the above link

Read only

Former Member
0 Likes
979

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

Read only

Former Member
0 Likes
979

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