DB2 statement to update a header file if no corresponding record exists
Not really but you can simplify your query like this (variable are not replaced 2x)

Exec SQL UPDATE  TC400F f1                     
         SET  (f1.T40STS, f1.T40OFL) = ('05', '1')             
         WHERE  (f1.T40SID, f1.T40PID) = (:K#T41SID, :K#T41PID) AND    
         NOT EXISTS
         (SELECT * FROM TC401F f2 WHERE (f1.T40SID, f1.T40PID)=(f2.T41SID, f2.T41PID));