select
tsk_enableenhancedplanning enableenhancedplanning,
TSK_PERSONS personsreq,
TSK_HOURS taskhours,
tsk_persons pplreq,
tsk_trade trade,
tsk_hours esthrs,
tsk_uom taskuom,
TSK_PRICE totalprice,
tsk_rpc reasonforrepair,
tsk_wap workaccomplished,
tsk_tpf techpartfailure,
tsk_manufact manufacturer,
tsk_syslevel syslevel,
tsk_asmlevel asslevel,
tsk_complevel complevel,
tsk_matlist matlist,
(select max(mtl_revision) from r5matlists where mtl_code = tsk_matlist AND mtl_revrstatus = 'A') matlrevision,
tsk_complocation componentlocation,
tsk_code task,
tsk_desc taskdesc,
tsk_org taskorganization,
TSK_CLASS taskclass,
TSK_REVISION taskrev
from r5tasks t, r5userorganization u
where t.tsk_revrstatus = 'A'
and  t.tsk_org = u.uog_org
and u.uog_user = <parameter.r5user>
and  ( u.uog_common = '+' or u.uog_org =  <control.org> )
and coalesce(t.tsk_notused, '-') <> '+'
and (coalesce( <param.isolationmethodall> , 'false') =  'true' or coalesce(t.tsk_isolationmethod, '-') <> '+' )
and (coalesce( <param.excludemultipletrades> , 'false') = 'false' or coalesce(t.tsk_multipletrades, '-') = '-')
and (coalesce( <param.excludejobplanning> , 'false') = 'false' or t.tsk_planninglevel = 'TP')
and (coalesce( <param.excludecasemanagement> , 'false') = 'false' or coalesce(t.tsk_casemanagementchecklist, '-') = '+')
and (coalesce( <param.excludenonconformity> , 'false') = 'false' or coalesce(t.tsk_nonconformitychecklist, '-') = '+')
