select e.evt_code as parentwo,
    e.evt_desc as parentwodesc
    FROM   r5events e 
    WHERE  e.evt_rstatus = 'R' AND e.evt_jobtype not in 
    (select uco_code from r5ucodes where uco_rcode ='MEC' and uco_rentity ='JBTP') AND e.evt_org = <control.org> AND  ( <param.eventno> IS NULL OR <param.pagemode> = 'display' OR   ( e.evt_code NOT IN  ( <param.eventno>)   AND  ( e.evt_rtype = 'PPM'   OR     EXISTS (SELECT 1 FROM r5events c WHERE  c.evt_code = <param.eventno> AND c.evt_rtype = 'JOB' AND e.evt_rtype =c.evt_rtype)))) AND  ( <param.bypassdeptsecurity> = 'true'  OR   (<parameter.deptsec> = 'OFF'   OR   (evt_mrc IN (SELECT dse_mrc FROM r5departmentsecurity            WHERE  
    dse_user = <parameter.r5user> AND dse_mrc = evt_mrc AND coalesce(dse_readonly, '-') = '-'))))