How to get Sales Order # from the delivery #?

tommy nguyen
DECLARE @cc NVARCHAR(MAX) DECLARE @dn NVARCHAR(MAX) DECLARE @stc NVARCHAR (MAX) SET @cc = $[$4.0.0] SET @dn = $[$8.0.0]--HOW TO GET DOC number from sales order in delivery SET @stc = $[$40.0.0] IF(SELECT               COUNT(*) AS Type FROM            dbo.ORDR INNER JOIN                          dbo.CRD1 ON dbo.ORDR.CardCode = dbo.CRD1.CardCode AND dbo.ORDR.ShipToCode = dbo.CRD1.Address WHERE        (dbo.ORDR.DocStatus = 'O') AND (dbo.CRD1.CardCode = @cc) AND (dbo.ORDR.DocNum = @dn)AND (dbo.ORDR.ShipToCode = @stc)) = 0 BEGIN SELECT 'address' FOR BROWSE END ELSE BEGIN SELECT 'success' FOR BROWSE END

So this is my query. Im comparing if the addresses are the same or not. This works on the sales order but for the delivery # it does not work. It doesnt work due to the document number. Since the data is only just copied over to create the sales order, the delivery doesnt actually have any saved data. So I was wondering how I can get the sales order # from the delivery. the "dn" is the one I need to change and fix so it matches with the sales when Im on the delivery

Comentarios

0 comentarios

Iniciar sesión para dejar un comentario.