I am learning how to best read numeric data exported from other software such as Excel. For example:
Case 1: $00016.45
Case 2: $-123.56
Case 3:- $111.44
Case4: $ 12.13
Case5: $ -18.19
In all cases, a dollar sign (currency) and a decimal point (say ".") must exist in the input.
My question is, is there a way, without coding algorithms to handle any of the above formats in an input record?
What PIC would that be? It is still OK if I had to pad the number with leading zeros if this would solve any of the cases.
What about handling just the explicit decimal point wihtout the currency sign (say 12.34) without defining :
01 Rec.
02 fld.
03 fld1 pic 99.
03 f pic x
03 fld2 pic 99.
The question is about standard COBOL in general.
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am learning how to best read numeric data exported from other software such as Excel. For example:
Case 1: $00016.45
Case 2: $-123.56
Case 3:- $111.44
Case4: $ 12.13
Case5: $ -18.19
In all cases, a dollar sign (currency) and a decimal point (say ".") must exist in the input.
My question is, is there a way, without coding algorithms to handle any of the above formats in an input record?
What PIC would that be? It is still OK if I had to pad the number with leading zeros if this would solve any of the cases.
What about handling just the explicit decimal point wihtout the currency sign (say 12.34) without defining :
01 Rec.
02 fld.
03 fld1 pic 99.
03 f pic x
03 fld2 pic 99.
The question is about standard COBOL in general.
Thank you.
Because of the
-not being in the same place in your examples I'd likely do the following:first: validate the dollar sign, if needed (check that you have exactly one
$and before either nothing or a +/-)Then for portable COBOL:
and for COBOL 202x or GnuCOBOL:
Thank you for the immediate and accurate response.
You are superb indeed.
Stay safe.