/*   Test for expected output from bcp -                   */
/*   If not found, set a return code of 12                 */
                                                                                
trace o
parse arg indd
if indd = "" then
  do
  say 'no input dataset specified for bcperrck exec'
  exit 4
  end
rc=0; brc=12;
do forever
  line = LINEIN(indd)        /* get line of datset */
  if line=="" & lines(indd) = 0
  then                            /*  means eof        */
     do                                                                         
     say 'End of file reached.'                                                 
     leave
     end                                                                        
  else
     do                                                                         
       say line
       if pos('rows copied',line) > 0 then
         do                                                                     
           parse var line rowsin .
           if rowsin >= 0 then
              brc = 0
         end                                                                    
     end                                                                        
end                                                                             
                                                                                
call LINEOUT indd                   /* close  file           */
                                                                                
if brc /= 0 then
 say '****ERROR****  bcp not completed correctly.'

exit brc                                                                        
                                                                                
                                                                                
