Skip to Content
0
May 28, 2020 at 10:15 AM

SQL query to create alert filtering certain products from certain destinations.

49 Views

Hi,

I am still relatively new to the SAP Data Model and so am asking this:

We currently ship an electrical product that has region specific plugs (eg US, UK, or EU plugs) to various places.

I want to create an alert that will alert a user when there is an item in the system that is going to the incorrect destination based on it's plug type.

Here is what I have so far (the system is called 'STEPS').

SELECT T0.[DocNum], T2.[CardCode], T2.[CardName], T2.[MailCountr], T1.[ItemCode], T1.[Dscription] FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry] INNER JOIN OCRD T2 ON T0.[CardCode] = T2.[CardCode] WHERE T1.[Dscription] LIKE '%STEPS%' AND T1.[Dscription] LIKE '% US %' AND T2.[MailCountr] <> 'US'
AND T0.DocStatus = 'o' ORDER BY T0.[DocNum]

Can you think of any exceptions that may be missed here?

Thanks,

Alex