IBM Support

Example of an External Stored Procedure Calling a CL Program with Parameter

Troubleshooting


Problem

This document provides an example of an External Stored Procedure calling a CL Program with an input parameter.

Resolving The Problem

This document provides an example of an External Stored Procedure calling a CL Program with an input parameter.

The parameter is passed in to the Stored Procedure on the call, and then passed on to the CL program. The Stored Procedure passed a value in (up to 50 characters) that will be sent as a message to QSYSOPR message queue specified in the CL program
CLPGM
Steps:
1) Write the CL program source in STRPDM.

 PGM              PARM(&MSGTXT)                     
 DCL               VAR(&MSGTXT) TYPE(*CHAR) LEN(50)  
 SNDMSG     MSG(&MSGTXT) TOUSR(*SYSOPR)       
 ENDPGM                  
2) Compile the CL program.
- CRTCLPGM PGM(QGPL/CLTEST) SRCFILE(QGPL/QCLSRC)  
Program CLTEST created in library QGPL.
               
3)Open Access Client Solutions Run SQL Scripts and run the CREATE PROCEDURE statemement:
SP-RSS
set schema QGPL;

DROP specific procedure QGPL.SPtest;

create procedure QGPL.SPtest(IN Message char(50))
language CL
not deterministic
no sql
called on null input
--external program
external name 'QGPL/CLTEST'
parameter style general;

call QGPL.SPtest ('Test message');
4) Check QSYSOPR message queue.
- DSPMSG MSGQ(QSYSOPR)  

message

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.1.0"}]

Historical Number

597170611

Document Information

Modified date:
04 December 2024

UID

nas8N1011570