How to Retrieve Open Purchase Orders Through SQL SELECT Statement
Q - How do I retrieve an Elliott purchase order from a third party system through ODBC or ADO.NET?
A - If you only need the purchase order header, you can use the following SELECT statement:
SELECT * FROM POORDHDR WHEREHere are more details about this select statement:
ORD_HDR_ORDER_STS = 'P' AND
ORD_HDR_CHG_CANCL_CD <> 'X' AND
ORD_HDR_PRNT_PST_FG = 'X';
- POORDHDR - This is the Elliott Purchase Order Header table.
- ORD_HDR_ORDER_STS - Purchase Order Header status. The possible values are: U - unreleased PO, R - released, P - Printed, C- closed, X - canceled.
- ORD_HDR_CHG_CANCL_CD - Purchase Order Header Change Cancel Pending Code. When a PO is marked as C - "Changed" or X - "Canceled," it is in a pending mode. Only after the changed PO is printed and posted is the status finalized. In the above SELECT statement, we are excluding the cancel pending PO.
- ORD_HDR_PRNT_PST_FG - Purchase Order Header Print Post Flag. When a PO is first printed, this flag is set to "P," but it still needs to be posted to be finalized. Once the printed PO is posted, this flag is set to "X" = Posted.
SELECT POORDHDR.*, POORDLIN.* FROMThe above SELECT statement performs an inner join between POORDHDR and POORDLIN tables by using their keys:
POORDHDR, POORDLIN WHERE
ORD_HDR_ORDER_NO = ORD_LINE_ORDER_NO AND
ORD_HDR_REL_NO = ORD_LINE_REL_NO AND
ORD_HDR_ORDER_STS = 'P' AND
ORD_HDR_CHG_CANCL_CD <> 'X' AND
ORD_HDR_PRNT_PST_FG = 'X' AND
ORD_LINE_STS = 'P' AND
ORD_LINE_CHG_CNCL_CD <> 'X' AND
ORD_LINE_CLOSE_FLAG <> 'Y' AND
ORD_LINE_QTY_RECEIVD < ORD_LINE_QTY_ORDERED;
ORD_HDR_ORDER_NO = ORD_LINE_ORDER_NO ANDIn addition to the explanation above on POORDHDR, here are more details behind this select statement:
ORD_HDR_REL_NO = ORD_LINE_REL_NO
- POORDLIN - This is the Elliott Purchase Order Line Item table.
- ORD_LINE_STS - Purchase Order Line Item Status. The possible values are: N - New, P - Printed, X - Canceled.
- ORD_LINE_CHG_CNCL_CD - Purchase Order Line Item Change Cancel Pending flag. When a line item is marked as "C" - changed or "X" - canceled, it still needs to be printed and posted before it is fianlized.
- ORD_LINE_CLOSE_FLAG - Purchase Order Line Item Closed Flag. The possible value is "Y" - line item is closed or blank. A line item can be closed even if it is not fully received.
- ORD_LINE_QTY_RECEIVD - Purchase Order Line Item Qty Received.
- ORD_LINE_QTY_ORERED - Purchase Order Line Item Qty Ordered.
EMK