Page 1 of 1

EZT - Data conversion from Alphanumeric to Packed decimal

PostPosted: Fri May 16, 2014 2:45 am
by Sandy
Hi,

New to EZT. Need help.

I have an input file that contains amount field from column 102 to 111 (i.e, alphanumeric 10). It can contain -ve values too.
It is variable length. For example it can contain '-500.00' or '1234567.00'.

The EZT pgm has to read this amount field from input file and move it to a packed decimal field AMT1 W 8 P 2.
I am using this packed decimal to update the amount field in a db2 table. The amount field in the table has its datatype defined as DECIMAL(15,2). Hence I need to define my AMT1 as W 8 P 2. Otherwise I am getting datatype error while updating it.

Please help!

Thanks,
Sandy

Re: EZT - Data conversion from Alphanumeric to Packed decima

PostPosted: Fri May 16, 2014 12:35 pm
by NicC
If all your easytrieve is doing is converting that one field then you would be better off using your sort product - but I will leave others to judge on that.

Re: EZT - Data conversion from Alphanumeric to Packed decima

PostPosted: Fri May 16, 2014 1:37 pm
by BillyBoyo
To convert that field in Easytrieve Plus, you'd need to write some code, a loop starting at the right, ignoring blanks. You'll have to transfer from first non-blank, byte at a time, ignoring ".", into a numeric (N) field that is redefined as A with the OCCURS. You need to make sure your receiving field starts are zero. When you arrive at a -, set a flag, if you find no sign, set the flag to something else.

Testing the flag, set you packed-decimal field to either the numeric field you've just populated or (0 - the numeric field you've just populated).

Or use SORT, which has SFF, a format for a Signed Free-Format field (which is what you have).