[Tips] Truy vấn thô...
 
Notifications
Clear all

[Tips] Truy vấn thông tin batch number được mua về từ phiếu nhập kho/hóa đơn nào

1 Posts
1 Users
0 Reactions
96 Views
admin
Posts: 398
Admin
Topic starter
(@admin)
Noble Member
Joined: 3 years ago

Yêu cầu:

Người dùng muốn biết chứng từ mua hàng: phiếu nhập kho (GRPO) / hóa đơn mua hàng (AP Invoice) của số lô sản phẩm.

 

Giải pháp:

Sử dụng câu truy vấn sau:

select T0.ItemCode, T0.DistNumber, T0.ExpDate, T0.LocCode, T2.DocEntry "GRPO Entry", T2.DocDate "GRPO PostingDate", T3.DocEntry "APInvoice Entry", T3.DocDate "APInvoice PostingDate"
	from		(
				select S0."ApplyType", S0."ApplyEntry", S0."ApplyLine", S0."LocCode", S0."ItemCode", S0."Quantity", S1."DistNumber", S1."ExpDate"
				from "B1_InvPostListILWithoutBinView" S0 left join OBTN S1 on S0."MdAbsEntry"=S1."AbsEntry"
				where S0.ApplyType in (18, 20) and S1.DistNumber like '[%0]'
				) T0 left join PDN1 T1 on T0.ApplyType=T1.ObjType and T0.ApplyEntry=T1.DocEntry and T0.ApplyLine=T1.LineNum
				left join OPDN T2 on T1.DocEntry=T2.DocEntry
				left join PCH1 T3 on T3.BaseType=20 and T1.DocEntry=T3.BaseEntry and T1.LineNum=T3.BaseLine
				left join OPCH T4 on T3.DocEntry=T4.DocEntry

Hình minh họa:

Reply
Share:
x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security