cancel
Showing results for 
Search instead for 
Did you mean: 

APPROVAL QUERY HELP - AP Invoice with Doc Total 10% higher than Purchase Order and/or GRPO

0 Kudos

I need to trigger an approval for any AP invoice that is 10% higher than the purchase order or the GRPO. Thank you!

SELECT distinct 'true' FROM OPOR T0 INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry left join PCH1 T2 on T2.[BaseEntry] = t1.docentry and T2.[BaseLine] = T1.[LineNum] INNER JOIN OPCH T3 ON T2.DocEntry = T3.DocEntry WHERE T0.DocTotal*1.10 > T3.DocTotal

Accepted Solutions (0)

Answers (2)

Answers (2)

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

Try this query,

SELECT distinct 'true'

FROM

OPOR T0

INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry

left join PCH1 T2 on T2.[BaseEntry] = t1.docentry and T2.[BaseLine] = T1.[LineNum]

INNER JOIN OPCH T3 ON T2.DocEntry = T3.DocEntry

WHERE (T0.DocTotal*1.10) > $[OPCH.DocTotal]

Regards,

Nagarajan

0 Kudos

Thank you but I am still getting an approval trigger when the AP Invoice is the same amount as the Purchase Order.

JesperB1
Advisor
Advisor
0 Kudos

Hello,

You need to use the '$' sign so the system checks the current document.

Check:

https://answers.sap.com/questions/12939310/sap-b1-approval-process-query-for-discount-sum.html

You can also check this blog:

https://blogs.sap.com/2016/09/17/approval-template-at-the-line-level-on-marketing-documents/

I hope it helps.

Jesper