select 
o.obj_desc as assetdescription,
o.obj_code as assetid,
o.obj_org as assetorganization,
COALESCE(o.obj_lot, '*') as lotcode,
o.obj_serialno as serialnumber
FROM r5userorganization u,  r5objects o 
WHERE o.obj_part = <part_code> 
AND  o.obj_part_org = <part_org> 
AND o.obj_obrtype = 'A' 
AND  o.obj_rstatus = 'I' 
AND  o.obj_store IS NULL 
AND  u.uog_org = o.obj_org 
AND  u.uog_user = <parameter.r5user> AND (u.uog_common = '+' or u.uog_org = <control.org> ) 
AND (<param.bypassdeptsecurity> = 'true' 
   OR (<parameter.deptsec> ='OFF' 
     OR (obj_mrc IN
     ( SELECT dse_mrc FROM r5departmentsecurity
      WHERE dse_user =<parameter.r5user> AND dse_mrc = obj_mrc
      AND coalesce(dse_readonly, '-') = '-')
     )
  )
)  
