Home dynamics ax, sql server how to view intercompany data between packing slip and receipt item
dynamics axsql server

how to view intercompany data between packing slip and receipt item

case is:

when your logistics manager wants to know, what packing slip from others entity sent to your company in some periode

this is the query

/*
declare @DataAreaID varchar(4) = '[your entity]';
declare @dtStart date = '2016-04-01';
declare @dtEnd date = '2016-05-04';
*/

select
  CPSJ.DATAAREAID as Sender,
  CPSJ.PACKINGSLIPID, 
  CPSJ.INTERCOMPANYPURCHID,
  CPST.ORIGSALESID,
  CPST.DELIVERYDATE,
  CPST.LINENUM,
  CPST.ITEMID,
  ID.CONFIGID,
  ID.INVENTSIZEID,
  ID.INVENTCOLORID,
  CPST.ORDERED,
  VPST.QTY,		
  VPST.REMAIN,
  VPSV.INTERNALPACKINGSLIPID,
  ICPSR.SALESID
from 
  CUSTPACKINGSLIPTRANS CPST
  INNER JOIN CUSTPACKINGSLIPJOUR CPSJ
    ON CPSJ.DATAAREAID=CPST.DATAAREAID
      AND CPSJ.PACKINGSLIPID=CPST.PACKINGSLIPID 
  INNER JOIN INVENTDIM ID
    ON ID.DATAAREAID=CPST.DATAAREAID
      AND ID.INVENTDIMID=CPST.INVENTDIMID			
  INNER JOIN VendPackingSlipTrans VPST
    ON VPST.DATAAREAID=CPSJ.INTERCOMPANYCOMPANYID
      AND VPST.ORIGPURCHID=CPSJ.INTERCOMPANYPURCHID
      AND VPST.PACKINGSLIPID=CPST.PACKINGSLIPID
      AND VPST.ITEMID=CPST.ITEMID
  INNER JOIN INVENTDIM ID2
    ON ID2.DATAAREAID=VPST.DATAAREAID
      AND ID2.INVENTDIMID=VPST.INVENTDIMID
      AND ID2.CONFIGID=ID.CONFIGID
      AND ID2.INVENTSIZEID=ID.INVENTSIZEID
      AND ID2.INVENTCOLORID=ID.INVENTCOLORID      
  INNER JOIN VENDPACKINGSLIPJOUR VPSJ
    ON VPSJ.DATAAREAID=VPST.DATAAREAID
      AND VPSJ.PACKINGSLIPID=VPST.PACKINGSLIPID
      AND VPSJ.PURCHID=CPSJ.INTERCOMPANYPURCHID
  LEFT JOIN VendPackingSlipVersion VPSV
    ON VPSJ.RECID=VPSV.VENDPACKINGSLIPJOUR	    
  INNER JOIN PURCHTABLE PT
    ON PT.DATAAREAID=VPST.DATAAREAID
      AND PT.PURCHID=VPST.ORIGPURCHID
  INNER JOIN INTERCOMPANYPURCHSALESREFERENCE ICPSR
    ON ICPSR.DATAAREAID=PT.DATAAREAID
      AND ICPSR.PURCHID=PT.PURCHID			
where
  CPSJ.INTERCOMPANYCOMPANYID=@DataAreaID
  and (CPSJ.DELIVERYDATE BETWEEN @dtStart AND @dtEnd)
  and vpst.qty <> 0

I have adjust a filter from query above, vpst.qty <> 0, it means that I wont show the Good Receipt that cancelled

 

-RF-

Author

Ronny

Leave a Reply