SQL_Seri/Lot Fiili Stok Sorgusu
SELECT IT.CODE MalzemeKodu, CASE WHEN IT.CARDTYPE = 1 THEN 'Ticari Mal ' WHEN IT.CARDTYPE = 2 THEN 'Karma Koli' WHEN IT.CARDTYPE = 3 THEN 'Depozitolu Mal' WHEN IT.CARDTYPE = 4 THEN 'Sabit Kıymet' WHEN IT.CARDTYPE = 10 THEN 'Ham Madde' WHEN IT.CARDTYPE = 11 THEN 'Yarı Mamul' WHEN IT.CARDTYPE = 12 THEN 'Mamul' WHEN IT.CARDTYPE = 13 THEN 'Tüketim Malı' WHEN IT.CARDTYPE = 20 THEN 'Genel Malzeme Sınıfı' ELSE '' END Tur, "Seri-Lot Kodu"=Seri.CODE , CAST( SUM( CASE WHEN SLTRANS.IOCODE IN(1,2) THEN (SLTRANS.AMOUNT * (case when SLTRANS.UINFO2=0 THEN 1 ELSE SLTRANS.UINFO2 END)/ (case when SLTRANS.UINFO1=0 THEN 1 ELSE SLTRANS.UINFO1 END)) WHEN SLTRANS.IOCODE IN(3,4) THEN (SLTRANS.AMOUNT * (case when SLTRANS.UINFO2=0 THEN 1 ELSE SLTRANS.UINFO2 END) / (case when SLTRANS.UINFO1=0 THEN 1 ELSE SLTRANS.UINFO1 END)) *-1 ELSE 0 END) AS DECIMAL(20,10)) FiiliStok, EXPDATE SonKullanimTarihi FROM LG_003_03_SLTRANS SLTRANS JOIN LG_003_03_STLINE STL ON STL.LOGICALREF=SLTRANS.STTRANSREF JOIN LG_003_03_SERILOTN Seri ON Seri.LOGICALREF=SLTRANS.SLREF JOIN LG_003_ITEMS IT ON IT.LOGICALREF=STL.STOCKREF WHERE STL.LINETYPE=0 AND STL.CANCELLED=0 GROUP BY IT.CODE,Seri.CODE,EXPDATE ,IT.CARDTYPE HAVING CAST( SUM( CASE WHEN SLTRANS.IOCODE IN(1,2) THEN (SLTRANS.AMOUNT * case when SLTRANS.UINFO2=0 THEN 1 ELSE SLTRANS.UINFO2 END / case when SLTRANS.UINFO1=0 THEN 1 ELSE SLTRANS.UINFO1 END) WHEN SLTRANS.IOCODE IN(3,4) THEN (SLTRANS.AMOUNT * case when SLTRANS.UINFO2=0 THEN 1 ELSE SLTRANS.UINFO2 END /case when SLTRANS.UINFO1=0 THEN 1 ELSE SLTRANS.UINFO1 END) *-1 ELSE 0 END) AS DECIMAL(20,10))>0
0 Yorum