About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
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
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

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.
Program CLTEST created in library QGPL.
3)Open Access Client Solutions Run SQL Scripts and run the CREATE PROCEDURE statemement:

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');
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)


[{"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
Was this topic helpful?
Document Information
Modified date:
04 December 2024
UID
nas8N1011570
Manage My Notification Subscriptions