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

COMPARING AMOUNT WITH STRING

Former Member
0 Likes
1,391

Hi All,

I am having a string which contains a numeric value . I want to check whether that value is greater than 1000 or not.

Actully I am having a problem like in our server , whenever the amount value is in currency EURO, the ',' in the amount gets replaced by ' . ' and ' . ' gets replaced by ' , '. Now I am trying to replace that ' , ' by ' . ' and ' . ' by ' , ' .

I tried like this

IF STRING GE '1000'.

But its not working.

Now I have to check if the amount value is greater that 1000 or not .

Please suggest the way to do it.

Thanks a lot.

12 REPLIES 12
Read only

Former Member
0 Likes
1,332

Try

WRITE <source> TO <target> CURRENCY <Currency>.

reward points if helpful.

Read only

Former Member
0 Likes
1,332

Hi Rahul,

IF STRING GE '1000'. it is wrong statement,

Try this INT = STRLEN(<string name>).

IF INT > 1000.

-


ENDIF.

Hope this helps you, reply for queries, Shall post you the updates.

Regards.

Kumar. .

Read only

Former Member
0 Likes
1,332

Hi Rahul,

data: value type p.

write string to value.

if value > 1000.

****

endif.

hope this helps,

keerthi

Read only

Former Member
0 Likes
1,332

hi...

try this.

data: w_amt(4) type n.

w_amt = string. * which is havng amt..

(numc will not take characters )

now..compare

if w_amt > 1000.

endif.

then it works...

Read only

0 Likes
1,332

Hi All,

Thanks for all your replies but nothing is working , I am posting the code now

Please tell what can be done to remove the error.

The code which is giving error is in bold.

FORM zfun_con18 TABLES in_tab STRUCTURE itcsy

output_tab STRUCTURE itcsy.

DATA : sub1 TYPE string,

sub2 TYPE ebelp,

sub3 TYPE ebeln,

amount4 TYPE netpr.

DATA : it_ekko LIKE ekko.

DATA : curr TYPE string.

DATA: value type n.

READ TABLE in_tab WITH KEY 'EKKO-EBELN'.

sub3 = in_tab-value.

SELECT SINGLE * FROM ekko INTO it_ekko WHERE ebeln = sub3.

READ TABLE in_tab WITH KEY 'EKPO-NETPR'.

sub1 = in_tab-value .

WRITE sub1 TO value.

<b>IF it_ekko-waers EQ 'EUR'.

IF value GT 1000.

REPLACE ',' IN sub1 WITH '.' .

REPLACE '.' IN sub1 WITH ',' .

CONDENSE sub1.

else.

replace ',' in sub1 with '.' .

CONDENSE sub1.</b>

ENDIF.

ENDIF.

Read only

0 Likes
1,332

If you are checking PO Item price is greater than 1000 or not, you can do it directly. Why do you need to convert it into string?

Read only

0 Likes
1,332

Coz I am passing the values from the script to the program and I dont think we can compare the values passed from the script to the program .

Pls correct if I am wrong.

Thanks

Read only

0 Likes
1,332

I am not clear with your requirement. We always extract values in driver program and pass these values to script to display in the layout.

What is your requirement?

BTW REPLACE syntax is

REPLACE ',' WITH '.' INTO sub1. instead of REPLACE ',' IN sub1 WITH '.' .

Message was edited by:

Ashish Gundawar

Read only

0 Likes
1,332

Hi,

use value type p instead of n.

regards,

keerthi

Read only

0 Likes
1,332

Actully my requirement is to pass the amount value to the program from the script , check whether this value is greater than 1000, if yes then replace , with . and . with , otherwise keep the value as it is.

Read only

0 Likes
1,332

BTW REPLACE syntax is

REPLACE ',' WITH '.' INTO sub1. instead of REPLACE ',' IN sub1 WITH '.' .

Read only

Former Member
0 Likes
1,332

just check this code

data : text(10) type c value '1,000,200'.

replace all occurrences of ',' in text with ''.

if text gt '1000000'.

write : / 'hi'.

endif.

regards

shiba dutta