Following challenge: I would like to store code like “A = 5” in a table, where A will be a variable in the “real” code. So, in the “real” code I would like to use this tabledata to “build” a real IF-statement type IF rec.Field = TRUE then … Possible?[8D]
Hi, I think this will be hard to achieve. You would need a code that would parse your formula. If you plan to use only a few variables (like A), you could write a function with CASEs, which would evaluate formula for you (using actual variables). Give us a problem in terms of ‘what you want to do’ and not ‘how you want to do it’. You might get some other ideas how to do it [:)]
I think it is quite impossible. If you put the code once in a database then you can use only as a string. Navision does not have something like preprocessor directives that can change the meaning of a string to a part of the code. What do you want to do?
I don’t think you can do it this way… but there is always a way. You can send your code to be evaluated in another tool (Ex: test the result with Excel automation and use the result in your code). For sure, it would be easier if you tell us what you want to accomplish…
This is what I want to do: SAP has a product configurator, the functionality of which I have implemented in Navision. The rules/restrictions/preconditions in SAP are formulated in code (e.g. Precondition: Type EQ ‘PC’). I have the same structure of all entries in Navision. Now I want an easy way to update my rules/restrictions/preconditions in Navision by storing (and using) the SAP code for restrictrictions etc. in a table in Navision. In order to use that code in Navision, I would obviously have to “convert” the string in the table into C/AL code (like a parser). Does this help?
It looks like a classic problem where you have two different systems doing the same thing. If one function is updated in one system, it must be updated the same way in the other system. Obviously, the code is different and the triggers launching the code are not always the same. We had the same issue when building a web interface for a Navision sales invoice. We had the option to reproduce all the table and form triggers is ASP code, but we finally decided to use the code in Navision, using an XML tool to send the data to Navision, run the validate triggers, and get the result in XML. You can also launch Navision triggers by using C/FRONT. If it’s possible, my suggestion would be to keep the code in one place (SAP or Navision) for each of the interface points, and to use tools like the ones I just described to execute from there. I’m not an SAP expert, so I don’t know what tools are available to execute SAP code from an external application. Please keep us updated on the final solution…
Hi, check out this thread, which discusses how to get navision to calculate arbitrary mathematical forumulas: http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=10179 It would be complex, but Im sure you can build a variation of codeunit 8 to include extra functionality such as IF comparisons. The codeunit is recursive so there are limitations on how complex the formulas can be (what is the limit for recursion before error?). Regards, edd