This script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posting the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.
This script returns a list of all line items from Sales Order Processing at a status of work.
/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
SELECT
SOP10200.SOPNUMBE
,CASE SOP10200.SOPTYPE
WHEN 1 THEN
'Quote'
WHEN 2 THEN
'Order'
WHEN 3 THEN
'Invoice'
WHEN 4 THEN
'Return'
WHEN 5 THEN
'Back Order'
WHEN 6 THEN
'Fulfillment Order'
END AS 'Trx Type'
,SOP10200.LNITMSEQ
,SOP10100.DOCDATE
,SOP10100.CURNCYID
,SOP10100.CSTPONBR
,SOP10200.ITEMNMBR
,SOP10200.ITEMDESC
,SOP10200.ReqShipDate
,SOP10200.LOCNCODE
,SOP10200.QUANTITY
,SOP10200.UNITCOST
,SOP10200.EXTDCOST
,SOP10200.UNITPRCE
,SOP10200.XTNDPRCE
,SOP10100.SUBTOTAL + SOP10100.TAXAMNT + SOP10100.FRTAMNT + SOP10100.MSCTXAMT - SOP10100.TRDISAMT AS 'Value (Gross)'
,SY01200.INETINFO
FROM
SOP10200 --Sales Transaction Amounts Work (SOP10200)
INNER JOIN
SOP10100 --Sales Transaction Work (SOP10100)
ON
SOP10100.SOPTYPE = SOP10200.SOPTYPE
AND
SOP10100.SOPNUMBE = SOP10200.SOPNUMBE
LEFT JOIN
SY01200 --Internet Addresses (SY01200)
ON
SY01200.Master_Type = 'ITM'
AND
SY01200.Master_ID = SOP10200.ITEMNMBR