0

I want to remove decimal numbers to the filed (Total) of Business partner aging (Summary report) in crystal report

I tried to edit the formula but there is no luck, I want to have only two decimal numbers

Below is the codes

local stringvar amountstring;
if {PLD__ITEMS.F_119}='' then ' ' else 
(
    amountstring:={PLD__ITEMS.F_119};
    amountstring := replace(amountstring, "(", "-");
    amountstring := replace(amountstring, ")", "");
    amountstring := replace(amountstring, ")", "");
)

enter image description here

I need only two decimal numbers

Please anyone can help me

enter image description here

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Schadro
  • 63
  • 6

1 Answers1

1

Add one more line: amountstring := ToText(cCur(amountstring),2,",");

2nd argument controls number of decimals. 3rd argument controls thousand separator.

MilletSoftware
  • 3,521
  • 2
  • 12
  • 15
  • I tried to add that line but I got error message, the string is non-numeric. Please see the second picture – Schadro Apr 27 '20 at 12:43
  • Use IF THEN logic with isnumeric() function to apply the logic only to content that contains a number. – MilletSoftware Apr 27 '20 at 12:51
  • I used the logic of If isnumeric(amountstring) then, but it dislays nothing – Schadro Apr 27 '20 at 12:56
  • Right, that's because it's not numeric, most likely because of the currency symbol ("USD" or "RWF")? You're going to need to split out the currency symbol to isolate the number. Check out this link on how to split the string: https://stackoverflow.com/questions/13410798/how-to-split-a-string-and-make-an-array-of-integers-in-crystal-report – Overhed Apr 27 '20 at 15:42
  • Splitting the string to remove the non-numeric data is an option if there are only a small number of distinct currency symbols. If you have more than 2 or 3 different possible values for the currency symbol you may need to work with whomever handles you database design about splitting the data into two columns in the database. Otherwise your formula is going to become very complex and difficult to manage. – R. McMillan Apr 28 '20 at 15:01
  • I have to try to split the string into two columns in order to see if I can remove that decimal numbers. Currencies are only two – Schadro Apr 28 '20 at 21:09