Skip to end of metadata
Go to start of metadata
var common = require('common', 'hbutils');
var debugging = require('debugging', 'hbutils');
var cics = new Cics();

/*
 * This is a sample script that can be used to  
 * invoke a COBOL program using LINK WITH CHANNEL.
 * 
 * In this example we will have two containers
 *      PARMSET1 
 *      PARMSET2 
 * 
 * The COBOL program can create any number of other containers to pass data to the script 
 * as desired.  The script can process the data from the containers, update the contents and create 
 * new containers to be passed back to the calling program as needed.
 * 
 * In this example we expect the container _OUTPUT to return data from the program
 * 
 */
function invokeChannelProgam(){
        /*
         * Name of the COBOL program to be called
         */
        var pgm = new CommareaProgram('MYPROG');
        
        /*
         * What channel name should we use, it really doesn't matter, any channel name will do.
         */
        var channel = 'MyChannel';
                
        /*
         * Create the create the container.  Since this is 
         * the first time putContainerChannel is invoked, the channel is created here too.
         */
        var parmset1 = {
                container: 'PARMSET1',
                from: 'Here is some data for parm set 1',
                channel: channel
        }
        cics.exec.putContainerChannel(parmset1);
        
        /*
         * Create the container for parmset2
         */
        var parmset2 = {
                container: 'PARMSET2',
                from: 'Here is some data from parm set 2',
                channel: channel
        }
        cics.exec.putContainerChannel(parmset2);
        
        /*
         * Execute the program, return the results
         */
        pgm.runWithChannel(channel);
        
        /*
         * We will only look for return data in the _OUTPUT container
         */
        var outputContainer = {
                container: '_OUTPUT',
                channel: channel
        }
        cics.exec.getContainerChannel(outputContainer);
        
        /*
         * Write out whatever data is there
         */
        writeln('channel output:\n\t', outputContainer.into);
}

invokeChannelProgam();
  • No labels
Write a comment…