/*   Test for any errors from the sybase processing        */                   
/*   If there is any, set a return code of 12              */                   
                                                                                
trace o
parse arg indd
if indd = "" then
  do
  say '*rex*no input dataset specified for syberrck exec'
  exit 4
  end
rc=0; brc=0;                                                                    
do forever
  line = LINEIN(indd)        /* get line of datset */
  if line=="" & lines(indd) = 0
  then                            /* ret code 2 means eof        */
     do                                                                         
     say '*rex*End of file reached for' indd
     leave
     end                                                                        
  else
     do                                                                         
       say line
       if pos('****ERROR****',line) > 0 ,
        | pos('Operating-system error',line) > 0 ,    
        | pos('aborted on duplicate key',line) > 0 then
         do                                                                     
           brc = 12                                                             
           say '*rex*Error indicator detected in file 'indd'.'
         end
     end                                                                        
end                                                                             
                                                                                
call LINEOUT indd                   /* close  file           */
                                                                                
exit brc                                                                        
                                                                                
                                                                                
