SELECT a31.*,
       ifnull(a00.p19, '') as vp00, 
       ifnull(i21.p00, '') as vp01, 
       ifnull(i46.p02, '') as vp02, 
       ifnull(i49.p02, '') as vp03, 
       ifnull(i00.name, '') as vp04 
FROM a31
LEFT JOIN a00 ON a00.nr01=a31.p00
LEFT JOIN i21 ON i21.nr01=a31.p01
LEFT JOIN i46 ON i46.p01=a31.p02
LEFT JOIN i49 ON i49.p01=a31.p03
LEFT JOIN i00 ON i00.pno=a31.p04
WHERE a31.p00={np_pel}
   && a31.p06>=cast('{odbcdtos(nt_dt1)}' as date) 
   && a31.p06<=cast('{odbcdtos(nt_dt2)}' as date);