On Sat, Mar 14, 2026 at 6:48 AM Rob Berendt <robertowenberendt@xxxxxxxxx>
wrote:
Have you thought of abandoning CL for SQL stored procedures? There are SQL
services to check for IFS existence, locks, etc. To me this is a much
better solution than calling out to APIs, shoehorning SQL into CL, etc.
I need the CL to run CPYTOIMPF. Is there an SQL way?
But yes, SQL procedures and functions are terrific. Just be an expert in
terms of debugging. In my case, the CL program uses RUNSQL to call the SQL
procedure. I am creating a lot of CSV files, so the CL does its thing to
organize the IFS folder where the .CSV files are stored.
Grok was a big help in writing the CL program that uses STRQSH to run the
unix "test" command to test for existence of the IFS folder. Only thing,
Grok forgot to tell me to add the QIBM_QSH_CMD_ESCAPE_MSG environment
variable. Good thing Google AI knew about that. Otherwise I would have
had to read some manuals.
Here is the CHKDIR CL program that AI and I came up with:
PGM PARM(&outExists &DIR)
dcl &outExists *char 1
DCL VAR(&DIR) TYPE(*CHAR) LEN(256)
DCL VAR(&CMD) TYPE(*CHAR) LEN(2048)
/* Build shell test command */
CHGVAR VAR(&CMD) VALUE('test -d "' *TCAT &dir *TCAT '" &&
exit 0 || exit 1')
/* important!. Set environment variable to tell QSH to send *escape message
*/
/* when exit code of the shell command is not 0 - success.
*/
ADDENVVAR ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) VALUE('Y')
REPLACE(*YES)
/* Run it */
CHGVAR VAR(&outEXISTS) VALUE('1')
STRQSH CMD(&CMD)
/* If exit code = 0 ? exists */
MONMSG MSGID(QSH0000) EXEC(CHGVAR VAR(&outEXISTS)
VALUE('0'))
endpgm
As an Amazon Associate we earn from qualifying purchases.