cancel
Showing results for 
Search instead for 
Did you mean: 

Approval Query for A/P Invoice Changes from Approved PO

Y-Yusuf
Explorer
0 Kudos
140

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])

 

View Entire Topic
williamwachholz
Active Participant
0 Kudos

Hello,

As far as I understand, approval process is made to be run before the document is created (SAP B1 creates a draft). Approval process won't run after the document is already created nor in any document besides the one that is being created.

 

Maybe some expert can confirm this information.

Best regards

Y-Yusuf
Explorer
0 Kudos
Hi, I think there is a misunderstanding. I need an approval query for an A/P Invoice, which should work as follows: If an A/P Invoice is created using the 'Copy To' function from an approved Purchase Order, and any data from the PO (such as unit price, document total, or quantity) is modified, the A/P Invoice should trigger the approval process.