Thursday, August 25, 2016

SAP OPInt Business Situation

Think that you want to have an alarm when there is no order created in a particular day.

In OPInt this is achieved by creating a new Business Situation with a detection procedure.

A detection procedure returns data in table format.
For example you want to find days which you create any purchase order in last 10 days.

PROCEDURE "TABLESCHEMA"."RFX_Business_Scenario::chk_replication" ( out OUTPUT_TABLE "YOURSCHEMA"."DAILYCOUNT" )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER

READS SQL DATA AS
BEGIN
var1 = SELECT
top 20
LPAD(CAST(LPAD(cast("CREATED_AT" as NVARCHAR),14,'0') AS timestamp),10,'0') , count(*)

FROM "SRM_GRPQ_REPL"."CRMD_ORDERADM_H"
where
LPAD(CAST(LPAD(cast("CREATED_AT" as NVARCHAR),14,'0') AS timestamp),10,'0') < LPAD( now(),10,'0')

group by LPAD(CAST(LPAD(cast("CREATED_AT" as NVARCHAR),14,'0') AS timestamp),10,'0')
order BY LPAD(CAST(LPAD(cast("CREATED_AT" as NVARCHAR),14,'0') AS timestamp),10,'0') DESC ;



OUTPUT_TABLE = SELECT count(*) as TOTAL_COUNT FROM :var1 ;
END;

No comments:

Post a Comment