Page 1 of 1

EBCDIC numeric check

Posted: Thu Feb 05, 2009 11:28 am
by infranik
Is there any way we can check if a particular EBCDIC field is numeric ?
I am reading an ebcdic file in a parallel job and reading the field as char because I need to do the numeric check.
I tried the NUM() and ISVALID(int32,)functions but its not returning true even if its numeric value in the field.

has anyone faced such a scenario?

Posted: Thu Feb 05, 2009 12:06 pm
by chulett
Those functions are expecting ASCII data, AFAIK, so you'd need to convert the field to use them. These aren't packed fields, are they?

Posted: Thu Feb 05, 2009 2:39 pm
by infranik
thanks chulett,
they are packed fields i am trying to check if numeric.
can we use the NUM () function on packed field? my data is being read and shown properly when i say 'view data' .
(i have set file properties as EBCDIC and binary and packed=yes.)

Posted: Thu Feb 05, 2009 2:59 pm
by chulett
Once they're "unpacked" then sure, those functions should work fine.

Posted: Thu Feb 05, 2009 3:15 pm
by infranik
perfectly right that the function should work on the unpacked data (thats what i have got in my plate so far) but can we do those validations or checking on an unpacked EBCDIC data?

Posted: Thu Feb 05, 2009 3:20 pm
by chulett
Assuming that last "unpacked" should say "packed"... no, not as far as I know. Happy for someone to prove me wrong, however.

Posted: Thu Feb 05, 2009 4:41 pm
by ray.wurlod
Not possible (except in original COBOL application, of course) without unpacking.

Well, that's not entirely true, but it would need to be a custom routine to examine each possible bit pattern of each pair of bytes (allowing for byte order of the hardware, of course), which would probably be slower than unpacking.

Posted: Fri Feb 06, 2009 8:20 am
by infranik
Thanks guys..
Ray- I had a similar suggestion from a collegue telling me to maybe check the last bit of the packed field to compare if that is numeric.
A COBOL program to do the unpacking would take a long time (because of the size of the data) and consume resources on the mainframe.
I am trying a workaround for this and will update this post as soon as i find something worthwhile. maybe otherwise the business would have to live by the fact that this is a suspected technical limitation.

Posted: Fri Feb 06, 2009 8:56 am
by chulett
Why a mainframe COBOL program, do you not need to unpack these fields regardless in your job? The job is doing that automatically when the file is read in, as you noted, so I'm honestly curious - why the need to check anything while it's still packed? :?

Posted: Tue Mar 17, 2009 2:35 pm
by infranik
We found a workaround for this issue.
Read the EBCDIC file in a SEQ file Stage allowing all Nulls(i.e.Nullable=Yes on all fields) .
the non numeric fields are implicitly replaced by a NULL value/s (High Values \xFF in our case) and we eliminate the need for checking if data is numeric - inside the DS job. DS also reads all the records in the file without dropping any.
Please PM me if anyone needs a further explanation.

regards,
Nikhil.