Program control
This section describes how to access and use a program other than the one that is currently executing.
Program control uses IccProgram class, one of the resource classes.
Programs may be loaded, unloaded and linked to, using an IccProgram object. An IccProgram object can be interrogated to obtain information about the program. See IccProgram class for more details.
The example shown here shows one program calling another two programs in turn, with data passing between them via a COMMAREA. One program is assumed to be local, the second is on a remote CICS® system. The programs are in two files, ICC$PRG1 and ICC$PRG2. See C++ sample programs for the location of these files and the expected output from these sample programs.
#include "icceh.hpp"
#include "iccmain.hpp"
void IccUserControl::run()
{
IccSysId sysId( "ICC2" );
IccProgram icc$prg2( "ICC$PRG2" );
IccProgram remoteProg( "ICC$PRG3" );
IccBuf commArea( 100, IccBuf::fixed );
icc$prg2.load();
if (icc$prg2.condition() == IccCondition::NORMAL)
{
term->sendLine( "Loaded program: %s <%s> Length=%ld Address=%x",
icc$prg2.name(),
icc$prg2.conditionText(),
icc$prg2.length(),
icc$prg2.address() );
icc$prg2.unload();
}
commArea = "DATA SET BY ICC$PRG1";
icc$prg2.link( &commArea );
The communication area buffer is set to contain some data to be passed to the first program that ICC$PRG1 links to (ICC$PRG2). ICC$PRG1 is suspended while ICC$PRG2 is run.
IccBuf& commArea = IccControl::commArea();
commArea = "DATA RETURNED BY ICC$PRG2";
return;
ICC$PRG2 gains access to the communication area that was passed to it. It then modifies the data in this communication area and passes control back to the program that called it.
remoteProg.setRouteOption( sysId );
commArea = "DATA SET BY ICC$PRG1";
remoteProg.link( &commArea );
The setRouteOption requests that calls on this object are routed to the remote system. The communication area is set again (because it will have been changed by ICC$PRG2) and it then links to the remote program (ICC$PRG3 on system ICC2).
IccBuf& commArea = IccControl::commArea();
commArea = "DATA RETURNED BY ICC$PRG3";
return;
return;
};
Finally, the calling program itself ends and returns control to CICS.