Skip to main content
Answer

Join GLTran to SOOrder or SOLine in a TSQL Query?

  • March 5, 2025
  • 2 replies
  • 42 views

I'm working on a query to join GLTran data to Sales Order (SOOrder or SOLine) and need some pointers if anyone knows.

From what little I could find, I need to join GLTran and Sales Order through ARTran. I have the join between GLTran and ARTran producing correct results. However, I'm struggling on the Sales Order to ARTran join as it's not producing the correct results. Below is what I have thus far.

Any help or guidance is much appreciated!

 

select top 100 *
from acumatica.dbo.SOLine sol
left join acumatica.dbo.SOShipLine sl
on sol.OrderNbr = sl.OrigOrderNbr
and sol.LineNbr = sl.OrigLineNbr
and sol.OrderType = sl.OrigOrderType
left join acumatica.dbo.SOShipment SS
on sl.CompanyID = ss.CompanyID
and sl.ShipmentType = SS.ShipmentType
and sl.ShipmentNbr = SS.ShipmentNbr
left Join acumatica.dbo.ARTran AR
on sl.CompanyID = ar.CompanyID
and sl.OrigOrderType = ar.SOOrderType
and sl.OrigOrderNbr = ar.SOOrderNbr
and sl.LineNbr = ar.SOOrderLineNbr

 

Best answer by lauraj46

Hi ​@mbhsi ,

You should be able to join SOLine sol with ARTran ar on

sol.OrderType = ar.SOOrderType and sol.OrderNbr = ar SOOrderNbr and sol.LineNbr = ar.SOOrdedLineNbr

Beware that this query will return duplicates if there are multiple shipments and invoices for a particular sales order line.  You might find this thread helpful:

You can also use the Acumatica DAC browser, available from any screen on the Tools menu, to examine the relationships between the DAC classes.  It's not always a direct correspondence from DAC to the underlying SQL tables, but still quite useful.

Hope this helps!

Laura 

2 replies

lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • Answer
  • March 6, 2025

Hi ​@mbhsi ,

You should be able to join SOLine sol with ARTran ar on

sol.OrderType = ar.SOOrderType and sol.OrderNbr = ar SOOrderNbr and sol.LineNbr = ar.SOOrdedLineNbr

Beware that this query will return duplicates if there are multiple shipments and invoices for a particular sales order line.  You might find this thread helpful:

You can also use the Acumatica DAC browser, available from any screen on the Tools menu, to examine the relationships between the DAC classes.  It's not always a direct correspondence from DAC to the underlying SQL tables, but still quite useful.

Hope this helps!

Laura 


  • Author
  • Freshman I
  • March 6, 2025

Thanks for the information ​@lauraj46. I’ll give this a try today.