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: 

Remove negative sign

Former Member
0 Kudos

Hi Experts

I am getting a value in variable and that is negative. I am using

REPLACE ALL OCCURRENCES OF '-' IN abtmnt WITH ''. But I am getting an error which states that:

"OCCURRENCES OF '-' IN ABTMNT" is not expected.

Can anyone tell me the reason for this error.

Regards

Vishal

1 ACCEPTED SOLUTION

andreas_mann3
Active Contributor
0 Kudos

Hi,

use fm PREPARE_STRING

or

write f1 to f2 no-sign.

Message was edited by:

Andreas Mann

7 REPLIES 7

Former Member
0 Kudos

These <b>replace , translate , shift</b> all funcitons work for character type fields onli...

These wont work for fields other than character type fields..

Do one thing move that variable into a sufficient sized variable of type 'N', then u wont get any '-' sign there...!!

Try executing this sample code ,,,,,

data w_i type i value '-234'.

data w_n(4) type n.

move w_i to w_n.

write : / 'w_i', w_i, / 'w_n', w_n .

<b>****************************************

output : w_i -234

w_n 0234.

****************************************</b>

<b>reward points if it helps u...</b>

sai ramesh

andreas_mann3
Active Contributor
0 Kudos

Hi,

use fm PREPARE_STRING

or

write f1 to f2 no-sign.

Message was edited by:

Andreas Mann

0 Kudos

Hi Andreas

Thanks for your response.

I am using:

data: abtmnt like konv-kwert,

abtmnt1 like konv-kwert.

write abtmnt to abtmnt1 no-sign.

The value in abtmnt is 1078.37- but what I am getting in

abtmnt1 is 13037382>3.33

I will appreciate if can give some idea why this is happening.

Regards

Vishal

0 Kudos

Hi vishal,

just execute this and check.

data: abtmnt like konv-kwert,

abtmnt1 like konv-kwert.

select single kwert from konv into abtmnt where kwert < 0.

write abtmnt .

write abtmnt no-sign.

WHy are u using write abtmnt to abtmnt1. u can eliminate the sign by just using no-sign.

reward if it helps.

keerthi.

0 Kudos

Hi Keerthi

Keerthi, I am assigning this abtmnt somewhat like this:

wa_item-abt_per_unit = abtmnt no-sign.

but I am getting this error.

%CODE1 Incorrect arithmetic or bit expression: Instead of "NO-SIGN", an operator (+, -, *, /, ... or BIT-AND, BIT-XOR, BIT-OR) was expe

Can you suggest something on this.

Regards

Vishal

0 Kudos

you cannot use no sign while assigning a field , you can only use that with write statement

move the amount to one charater field and use this FM

use this FM CLOI_PUT_SIGN_IN_FRONT

Former Member
0 Kudos

use this

TRANSLATE  ABTMNT using '- '.

and if u want use REPLACE

REPLACE ALL OCCURRANCES OF '-' IN abtmnt WITH ' '.