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

CHECKING for currency format

Former Member
0 Likes
769

Hi,

i am checking the currency format amount.the rule is Right justify amount decimal point and 2 decimal places. Not to use commas or the $ sign.

for the above condition the code is:

data:val type string.

val = '123456789.00'.

if val co '.0123456789'.

shift val right deleting TRAILING space.

else.

if val cs ',' or val = '$'.

replace ',' with space into val.

replace '$' with space into val.

endif.

endif.

but iam getting '$' and ','. mark in o/p.

how can we check this condition.help me out from this issue.

Thanks

Message was edited by:

skk

2 REPLIES 2
Read only

Former Member
0 Likes
557

Try this.

[code]parameters : val(30) type c.

data : final(30) type c,

cnt type i,

v type c,

n type i.

cnt = strlen( val ).

do cnt times.

move val+n(1) to v.

if v ca '.0123456789'. "Bring in the values

move v to final+n(1).

*elseif v = ',' or v = '$'. "<---no need of this

*continue. "<----no need

endif.

n = n + 1.

enddo.

condense final no-gaps.

write:/ final .[/code]

regards,

vijay

Read only

Former Member
0 Likes
557

I believe the answer given by vijay is quite enough to solve the issue. There are other methods also for doing same using the String functionality in sync with the data type 'N' in which no commas or sign will be used. You can use your existing code by just moving the value to N type of field at the end.

Hope this solves your issue.

Raj