MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

exception handling & structures PL1

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
nagasadhu
Beginner


Joined: 08 Jul 2006
Posts: 17
Topics: 6

PostPosted: Tue Jan 16, 2007 12:24 pm    Post subject: exception handling & structures PL1 Reply with quote

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
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 315
Topics: 49
Location: Germany

PostPosted: Wed Jan 17, 2007 3:47 am    Post subject: Reply with quote

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
View user's profile Send private message
nagasadhu
Beginner


Joined: 08 Jul 2006
Posts: 17
Topics: 6

PostPosted: Fri Jan 26, 2007 11:14 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group