where
sodt.GoodID ='$GoodID'
and Sohd.Docustatus <> 'Y'
and sohd.docutype=104
and sohd.Multicurrency='N'
and sohd.clearso='N'
and sohd.onhold='N'
and remaqty > 0
and ((sohd.brchid = :an_brchid) or (:an_brchid=0))
Arguments : an_brchid
Select pohd.docuno,
pohd.poid,
pohd.docudate,
pohd.shipdate,
podt.listno,
podt.goodname,
podt.goodprice2,
podt.appvqty2,
podt.goodremaqty2,
(podt.appvqty2 - podt.goodremaqty2)goodqtysvt , /*???????????????*/
emvendor.vendorcode,
( case EMVendor.Vendortitle
when '' then isnull(EMVendor.Vendorname,'')
when null then isnull(EMVendor.Vendorname,'')
else EMVendor.Vendortitle+' '+isnull(EMVendor.Vendorname,'')
end )Vendorname ,
isnull(emvendor.vendornameeng,'')vendornameeng,
emdept.deptcode,
emgood.goodcode,
emgood.goodnameeng1,
emgoodunit.goodunitname,
emgoodunit.goodunitnameeng,
(select emgoodmultiunit.goodunitrate from emgoodmultiunit where (emgood.goodid = emgoodmultiunit.goodid)
and (emgoodmultiunit.goodunitid = PODT.GoodUnitID2))goodunitrate
from pohd left outer join podt on pohd.poid = podt.poid
left outer join emvendor on pohd.vendorid = emvendor.vendorid
left outer join emdept on pohd.deptid =emdept.deptid
left outer join EMgoodunit on (podt.goodunitid2 = EMgoodunit.goodunitid)
left outer join emgood on (podt.goodid = emgood.goodid)
where pohd.docutype = 305
and pohd.appvflag ='2'
/*and pohd.MultiCurr = 'N'*/
and podt.appvflag = '2'
and pohd.docustatus <> 'Y'
and podt.completeflag <> 'Y'
and pohd.cancelflag = 'N'
and pohd.onhold = 'N'
and ((POHD.brchid =:an_brchid) or (:an_brchid= 0 ))