select 1006 as SOURCETYPE, SALESRETURNLINE.ITSID as SOURCEID, 1 as SOURCEOWNERTYPE, SALESRETURN.ITSID as SOURCEOWNERID, SALESRETURN.ITSDATE, THEREST
from SALESRETURNLINE
join SALESRETURN on SALESRETURN.ITSID = SALESRETURNLINE.ITSOWNER
where SALESRETURNLINE.REVERSEDID is null and THEREST>0 and INVITEM=:INVITEM and UNITOFMEASURE=:UNITOFMEASURE

