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: 

Conversion

Former Member
0 Kudos

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

Former Member
0 Kudos

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

former_member181962
Active Contributor
0 Kudos

Use the FM:

HRCM_STRING_TO_AMOUNT_CONVERT

Regards,

Ravi

Former Member
0 Kudos

Try this..

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

data: p type p decimals 2.

p = n.

rahulkavuri
Active Contributor
0 Kudos

Please refer the above link and award points if found helpful

0 Kudos

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

Any help?

Former Member
0 Kudos

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

rahulkavuri
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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