<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="task" />
<meta name="DC.Title" content="Use CL procedures" />
<meta name="abstract" content="This gives an overview of the types of operations performed using CL procedures" />
<meta name="description" content="This gives an overview of the types of operations performed using CL procedures" />
<meta name="DC.subject" content="CL procedure, using, example, typical, control processing with CL command, processing, using CL command, control processing, controlling processing, control language (CL), program" />
<meta name="keywords" content="CL procedure, using, example, typical, control processing with CL command, processing, using CL command, control processing, controlling processing, control language (CL), program" />
<meta name="DC.Relation" scheme="URI" content="clpro.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="workp" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Use CL procedures</title>
</head>
<body id="workp"><a name="workp"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use CL procedures</h1>
<div><p>This gives an overview of the types of operations performed using
CL procedures</p>
<div class="section"> <div class="p">In general, you can:  <ul><li>Use variables, logic control commands, expressions, and built-in functions
to manipulate and process data within a CL procedure:  <pre>PGM
DCL &amp;C *LGL
DCL &amp;A *DEC VALUE(22)
DCL &amp;B *CHAR VALUE(ABCDE)
•
•
•
CHGVAR &amp;A (&amp;A + 30)
•
•
•
IF (&amp;A &lt; 50) THEN(CHGVAR &amp;C '1')
•
DSPLIB ('Q' ∨∨ &amp;B)
•
IF (%SST(&amp;B 5 1)=E) THEN(CHGVAR &amp;A 12)
•
•
•
ENDPGM</pre>
</li>
<li>Use a system value as a variable in a CL procedure. <br /><img src="rbafn551.gif" alt="Use a system value as a variable in a CL procedure." /><br /></li>
<li>Use a job attribute as a variable in a CL procedure. <br /><img src="rbafn552.gif" alt="Use a job attribute as a variable in a CL procedure." /><br /></li>
<li>Send and receive data to and from a display file with a CL procedure. <br /><img src="rbafn553.gif" alt="Send and receive data to and from a display file with a CL procedure." /><br /></li>
<li>Create a CL procedure to monitor error messages for a job, and take corrective
action if necessary.  <pre>        PGM
 
        MONMSG MSGID(CPF0001) EXEC(GOTO ERROR)
        CALL PROGA
        CALL PROGB
        RETURN
ERROR:  SNDPGMMSG MSG('A CALL command failed') MSGTYPE(*ESCAPE)
        ENDPGM</pre>
</li>
<li>Control processing among procedures and programs and pass parameters from
a CL procedure to other procedures or programs to override files.</li>
</ul>
<br /><img src="rbafn554.gif" alt="Control processing among procedures and programs and pass parameters from a CL procedure to other procedures or programs to override files." /><br /></div>
<p>Used as
a controlling procedure, a CL procedure can call procedures written in other
languages.  The preceding illustration shows how control can be passed between
a CL procedure and RPG IV* and ILE COBOL procedures in an application.  To
use the application, a workstation user would request program A, which controls
the entire application.  The illustration shows a single bound program (PGMA)
that is called using the CALL command with PGMA.  PGMA consists of:  </p>
<ul><li>A CL procedure (PGMA) calling an RPG IV procedure (PGMB)</li>
<li>An RPG IV procedure (PGMB) calling another RPG IV procedure (PGMC)</li>
<li>An RPG IV procedure (PGMB) calling a CL procedure (PGMD)</li>
<li>A CL procedure (PGMA) calling an ILE COBOL procedure (PGME)</li>
<li>An ILE COBOL procedure (PGME) calling a CL procedure (PGMF)</li>
</ul>
<br /><img src="rbafn502.gif" alt="The following illustration shows how control can be passed between a CL procedure and RPG IV* and ILE COBOL procedures in an application." /><br /><p>The procedures can be created
as indicated in the following example. You can enter source for procedures
in separate source members.  </p>
<pre>    CRTCLMOD PGMA
    CRTRPGMOD PGMB
    CRTRPGMOD PGMC
    CRTCLMOD PGMD
    CRTCBLMOD PGME
    CRTCLMOD PGMF
    CRTPGM PGM(PGMA) +
           MODULE(PGMA PGMB PGMC PGMD PGME PGMF) +
           ENTMOD(*FIRST)</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="clpro.htm" title="This provides tasks and concepts specific to CL programming.">CL programming</a></div>
</div>
</div>
</body>
</html>