title: SAP B1 query for stand alone documents
body: <p>I am trying to get this documents (sales orders) in SAP Business One, those that are not forwarded to Delivery or those that have no PO.</p>
  <p>I have tried this:</p>
  <pre><code>SELECT * FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry=T1.Docentry
  WHERE T1.TrgtEntry IS NULL AND T1.BaseEntry IS NULL.
  </code></pre>
  <p>The problem is, we allow partial delivery of sales orders. So if sales order has 10 items and 5 of these items are partially delivered. This kind of documents are included in my query.</p>
  <p>What can i do? I though this is easy but it's making me crazy. If only the header document can identify if it already have linking tables.</p>
  <p>Thank you.</p>
  <p>SAP B1 DB Schema</p>
  <p><a href="https://i.stack.imgur.com/5Agko.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Agko.png" alt="enter image description here" /></a></p>
  <blockquote>
  <pre><code>**POR1 child table of purchase order (OPOR)
  **DLN1 child table of Delivery (ODLN)
  DocEntry is the relationship between Header(ORDR) and child(RDR1)
  BaseEntry is the relationship between child(POR1) to child(RDR1) 
  TrgtEntry is the relationship between child(RDR1) to child(DLN1)
  </code></pre>
  </blockquote>