Approval Query for ...
 
Notifications
Clear all

Approval Query for A/P Invoice Changes from Approved PO

2 Posts
2 Users
1 Reactions
66 Views
Posts: 2
Topic starter
(@yusuf)
Bishop1
Joined: 2 months ago

Hi experts,

What approval query should be written to trigger approval for an A/P Invoice, if any data from the approved Purchase Order document, from which the A/P Invoice was created, is modified?

Thanks. Regards.

EDİT:

I wrote a query like the one below. What I’m trying to do is this: if a purchase order document that was created via approval (I check this using the draftkey field) is copied into a purchase invoice, and the quantity entered in the invoice is different from the quantity in the purchase order, then the invoice should go to approval.

But currently, regardless of whether I change the quantity or not, the approval is triggered anyway. For example, let’s say the quantity in the purchase order is 10. Even if the quantity in the invoice is also 10 (i.e., the same), the approval is still triggered, whereas it should only be triggered if the quantity is different.

SELECT DISTINCT 'TRUE'
FROM OPCH T0
INNER JOIN PCH1 T1 ON T0."DocEntry" = T1."DocEntry"
LEFT JOIN POR1 T2 ON T1."BaseEntry" = T2."DocEntry"
AND T1."BaseLine" = T2."LineNum"
AND T1."BaseType" = 22
LEFT JOIN OPOR T3 ON T2."DocEntry" = T3."DocEntry"
WHERE

T3."draftKey" IS NOT NULL
AND ( T2."Quantity" <> $[$38.11.NUMBER])

Reply
1 Reply
admin
Posts: 551
Admin
(@admin)
Knight3
Joined: 4 years ago

Hi,

Try this query. It is in SQL version, if you use HANA version, convert accordingly

SELECT DISTINCT 'TRUE'
FROM OPCH T0
INNER JOIN PCH1 T1 ON T0."DocEntry" = T1."DocEntry"
LEFT JOIN POR1 T2 ON T1."BaseEntry" = T2."DocEntry" AND T1."BaseLine" = T2."LineNum" AND T1."BaseType" = '22'
LEFT JOIN OPOR T3 ON T2."DocEntry" = T3."DocEntry"
WHERE T3."WddStatus" in ('P','A')
AND  $[$38.11.NUMBER] <> isnull((select "Quantity" from POR1 where "DocEntry"=$[$38.45.1] and "LineNum"=$[$38.46.1]),0)

Hope this helps,

Reply
Share:
x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security