We are primarily a COBOL shop. We have some COBOL ILE and some RPG. I have a need to replicate a function on the I-series that is currently done in Excel. This function allows them to create formulas on the fly to arrive at pricing information. I can work through issues with interactive maintenance of the formulas. Has anyone ever built COMPUTE or arithmetic statements on the fly inside of a program? Is so can you provide some insight on how you implmented?
Appreciate any information. Thanks!
Software/Hardware used:
ASKED:
October 31, 2006 12:47 PM
UPDATED:
December 26, 2009 6:22 PM
yes, we have done something similar that may be helpful. Its basically a compiler and scripting language that creates machine code you can call at runtime. The users can generate script modules the would be compiled and linked in to other programs. Since it generates machine code its extremely fast for high volume transactions.
If you’d like to talk about licensing this technlogy or getting some assistance send me a private message.
I’m sure you are using CL to execute this application. I’ve done similar by passing parameters to the executing
program.
Use dynamic SQL. This allows you to do calculations on the run.
I once (in 1990) wrote a program to calculate the value of an arithmatic statement. This program is written in RPG III and has 3 parameters, the statement (255A), the result (30,9) and an error code (2A). The statement can consist of the following signs, +, -, /, *, ^, (, ), SQR() for square root with numbers everywhere in it.
If you’re interested, send me a private message.
our solution uses a proprietary scripting language and compiler to generate machine code. Assembly modules dynamically load these functions from the Loadlib based on VSAM table entries then the calculations are loaded and executed. The script language provids access to fields in our system and results are passed back in return values to be processed by cobol programs in a batch process.
This is part of a proprietary system that has been running nightly at several customers for about 8+ years.
If you can use Dynamic SQL or a stored proc it would be a good option. We were limited to mainframe and VSAM, but needed a scripting/parsing solution that changes based on customer input.
If you have a front end that is a Windows EXE there are add-ons that can use VB and you can run VB on the fly in your front end.
One note on security when using Dynamic SQL to execute instructions – you should provide means to ensure that the submitted string doesn not contain any malicious SQL code. Any time you create a pass-through function to Dynamic SQL, you potentially allow your system to be compromised.
In this case, if the input text was only expected to be an arithmetic expression, you could simply parse for the existence of any alphabetic characters.
When the input can contain alpha characters, the problem is a bit more difficult, but you should never allow raw input to be sent to Dynamic SQL to be executed. At the very least, parse for the existence of a semi-colon statement delimiter.