Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
It seems to me that a huge number of RPG programmers are "closet" CL programmers. That is they call CL commands from within RPG instead of calling the appropriate API or procedure.
With the exception of a handful of CL commands that RPG and APIs do not support (and I do mean a handfull) why would you ever run a CL command from RPG?
Thoughts? Comments?
Because maybe it's easier to just run the command and monitor its completion rather than look up the appropriate API (if any) and then develop all the interfacing parms, and user indexes, etc. needed to run it.
I'll admit to using APIs quite often but it's just too easy to run a CL from RPG.
Just my 2 cents...
Calls to CL programs? Sure. Single CL command? Few and far between. I know there are some OVRPRTF and corresponding DLTOVR, which aren't easily replaced. Maybe some lingering OPNQRYF somewhere that we haven't had a reason to touch. Can't really think of any others. (But haven't actually searched the code for QCMDEXC, etc.)
Here's what sparked the question: I have a customer using COZTOOLS. In COZTOOLS there is a "simple" (my opinion) sndinfMsg() function that will send a program message, relative to the procedure from which it is called. Yet the client sent me a support question that asked why SNDPGMMSG wasn't working when he passed it to my prototype for the C runtime "system" function (similar to QCMDEXC but with no length parameter required).
I asked why do you want to do that instead of SndInfMsg('Hello world')?
Has screwed up APIs so badly that even life-long OS/400 programmers are avoiding Procedure or should I say "Prototyped" calls in favor of CL commands.
I have some OVRPRTF, ADDLIBLE, etc. in RPGs, and these are generally done using "system".
Other commands done similarly are those from 3rd-party vendors. For example, we have several of the Gumbo products such as Gumbo Mail and SpoolMail, so these commands are easily done from RPG with "system" as well.
Yep, done that. Not all the time mind you but if your RPG is trying to work with a bought piece of software for FTP, E-mail etc that does not supply API's you kinda have no options. Same situation as Viking basically. Works fine, though error handling can be a pain in the backside.
On the IBM supplied commands only OVRDBF sounds like something I have used in the pre-free-era. But nowadays we can use RPG for that so this has become obsolete.
I don't know a lot of IBM APIs so yeah, I use CL commands unless there is no RPG opcode/BIF/sub-procedure and no CL command, then I learn the API. Is the speed difference that much between an API and corresponding CL command these days? Putting on my armor, crawling back under rock.
Chris Ringer
PS: I mean I call a CL program containing many commands to perform some function, like copy data to IFS, change owner, authorities, etc.