View previous topic :: View next topic |
Author |
Message |
nagasadhu Beginner
Joined: 08 Jul 2006 Posts: 17 Topics: 6
|
Posted: Tue Jan 16, 2007 12:24 pm Post subject: exception handling & structures PL1 |
|
|
Hi
I have a PL1 structure of LRECL=4050, with a combination Bin fixed, Dec fixed, Char and Bit values. I need to check the physical integrity of the data before processing.(i.e) BIN & DEC values contain numeric data, Bits contain 1 or 0, Char contains only displayable characters.
If the record contains junk, it is not necessary to locate the error but simply write to error.
My initial idea was this
Code: | DCL STR_INP CHAR(4050) BASED(INP_PTR);
DCL INP_PTR POINTER;
DCL 01 STRUC_INP BASED(INP_PTR),
02 ...........;
DCL DUMMY_STRUC LIKE STR_INP ;
ON COVERSION <WRITE TO ERROR>; GOTO READ_AGAIN ;
ON ENDFILE GOTO ENDPGM;
READ_AGAIN:
READ FILE(INPUT_FILE) SET(INP_PTR);
DUMMY_STRUC = STRUC_INP ;
<WRITE TO OUTPUT>
GOTO READ_AGAIN ;
ENDPGM: |
But this code works fine(RC=0) though a decimal value in the input to STRUC_INP was junked. A PUT SKIP of the junked decimal value triggered a 'DATA EXCEPTION'.
Is there a simple way to go about the whole thing?
Thanks for your time
PS: Why does the stucture assignment not trigger the data exception? Am I missing something in the understanding of stuctures in PL1? |
|
Back to top |
|
|
bauer Intermediate
Joined: 10 Oct 2003 Posts: 315 Topics: 49 Location: Germany
|
Posted: Wed Jan 17, 2007 3:47 am Post subject: |
|
|
nagasadhu,
the assignment DUMMY_STRUC = STRUC_INP moves only 4050 byte from one storage area to another storage area. It doesn't matter which datatypes are involved in the structure. So, this solution doesn't work as you mentioned already.
To get an excpetion if an (numeric) field in structure STRUC_INP is not numeric (for example) just access the field.
So code IF STRUC_INP.MyNumricField < 0 THEN DoNothingWithSense.
If MyNumericField is numeric nothing happens, if MyNumericField is not numeric you get the desired exception.
regards,
bauer |
|
Back to top |
|
|
nagasadhu Beginner
Joined: 08 Jul 2006 Posts: 17 Topics: 6
|
Posted: Fri Jan 26, 2007 11:14 am Post subject: |
|
|
Thanks a lot for your reply.
I want to handle the 'DATA EXCEPTION' condition. i.e write record to error and read the next record.
Something similar to 'ON CONVERSION'. But the program abends on encountering error.
Is it possible to handle this condition?
Regards |
|
Back to top |
|
|
|
|