Re: Shelling out CRTLF via QCMDEXC -- question about success/failure

Vern Hamberg via MIDRANGE-L <[email protected]> Mon, 8 Jun 2026 16:53:56 -0500
Newsgroups gmane.comp.hardware.ibm.midrange
Message-ID <[email protected]>
Hi James

There is now an SQL scalar function, QCMDEXC, that came out in 7.3 - not 
sure if that would work. It executes a command and returns a 1 if 
successful, -1 if not. Here's an example from a presentation I have 
given, where QCMDEXC executes CRTBNDCL on each member of a source PF -

WITH FF AS (SELECT TRIM(TABLE_SCHEMA) || '/' || TRIM(TABLE_PARTITION) 
PGMNAME,

TRIM(TABLE_SCHEMA) || '/' || TRIM(TABLE_NAME) SRCNAME

FROM SYSPARTITIONSTAT

WHERE TABLE_SCHEMA = 'VHAMBERG' AND TABLE_NAME = 'GOODBADSRC')

SELECT SRCNAME,

PGMNAME,

CASE

WHEN QSYS2.QCMDEXC('CRTBNDCL PGM(' || PGMNAME || ') SRCFILE(' || SRCNAME 
|| ')') = 1

THEN 'Compile succeeded'

ELSE 'Compile failed' END AS COMPILE_RESULT

FROM FF;


You could also consider using the QCAPCMD API - it is like QCMDEXC 
command but has an error code parameter, like other system APIs. It also 
has an options control block that has a message retrieve key for use in 
RTVMSG, IIRC.

*Regards*

*Vern Hamberg*

IBM Champion 2025 <cid:[email protected]> CAAC 
(COMMON Americas Advisory Council) IBM Influencer 2023


On 6/8/2026 4:31 PM, James H. H. Lampert via MIDRANGE-L wrote:
> I've got a project in which I will be using a QCMDEXC call to shell 
> out a CRTLF (from a generated source member). What is the easiest way 
> for the calling program to determine whether the CRTLF was successful?
>
> -- 
> JHHL
-- 
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related questions.