Recently I had the problem to apply an calculation where the formula depends on some conditions. But as you probably know, it is not possible to build an action script dynamically at runtime.
Thus, I found an approach using SQL, because it is possible to create a SQL statement at runtime. I have implemented this as follows:
1. Create a temporary SQLite table in memory:
CREATE TABLE “ATPcalculator” (“MATNR” text,
2. Insert data into table:
INSERT INTO “ATPcalculator” (MATNR,
3. Build SQL statement in an action script:
set sql = concat(“select “, formula, ” as atp from ATPcalculator where MATNR ='”, matnr, “” );
The value in formula could be an expression like “ATP – (UNCQTY_CURMTH + UNCQTY_PREVMTH)”
4. Perform SQL statement to get the calculated ATP value for a material.
5. Drop temporary table
This solution works fine, but i’m wondering whether there is maybe not a less complicated approach.
Any suggestions ? Maybe with Java-Script ? How could look a different solution?