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: 

string value to be displayed in number format

Former Member
0 Kudos
111

Hi All,

I am facing one problem when i am displaying a negative number in output.I have a number 123,567,90.89-.They want the sign should be on left-side.I did that shifting the sign to left by passing that value into one string type variable.But when i copied the value into string symbol ',' is ommiting and the value is getting stored as '12356790.89-',But i have to display the value in such a way that sign should be in left-side and it should be in number format.i.e,

-123,567,90.89.

Please give me a solution to resolve this problem..

With Regards,

R.P.Sastry

1 ACCEPTED SOLUTION

Former Member
0 Kudos
53

try this...

DATA: amount(16) TYPE P DECIMALS 3 VALUE '345435455.45-',

c_amount(16).

WRITE amount TO c_amount NO-SIGN.

IF amount < 0.

CONCATENATE '-'

c_amount

INTO c_amount.

CONDENSE c_amount NO-GAPS.

ENDIF.

WRITE c_amount.

4 REPLIES 4

Former Member
0 Kudos
53

after moving the data into string you need to put the ',' manually into the string

Former Member
0 Kudos
54

try this...

DATA: amount(16) TYPE P DECIMALS 3 VALUE '345435455.45-',

c_amount(16).

WRITE amount TO c_amount NO-SIGN.

IF amount < 0.

CONCATENATE '-'

c_amount

INTO c_amount.

CONDENSE c_amount NO-GAPS.

ENDIF.

WRITE c_amount.

Former Member
0 Kudos
53

Hello,

You can try:

G_NUM_TEMP TYPE P DECIMALS 2

G_S_IMP_MOM TYPE /GEX/255 --> CHAR of 255

G_NUM_TEMP contains: 123,567,90.89-

WRITE G_NUM_TEMP TO G_S_IMP_MOM LEFT-JUSTIFIED.

"LEFT-JUSTIFIED is for respecting the final - and doing the write correctly.

"NO GROUPING is used to avoid the separation for thousands, so here it is no used.

In G_S_IMP_MOM string you should have the value separated correctly, then do the process to have the - sign at the beginning of the string.

I hope it will help you.

former_member402443
Contributor
0 Kudos
53

Hi Parayya,

Check this function module. It gives u some help.

CLOI_PUT_SIGN_IN_FRONT

Regards

Manoj Kumar