Procedure Pointers & External Data
 COBOL Examples
When technology complements business    Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
  Table of Contents Version 10.03.20 
  Introduction
  Procedure Pointer
  External Data
  Standard CALL, Program Name & LINKAGE Section
 
  Primary COBOL Program
  Secondary COBOL Program, an I/O module
  Copy File for Working Storage Definitions
  The JCL Member
  The CMD File
  Procedure Pointer & External Data Items
 
  Primary COBOL Program
  Secondary COBOL Program, an I/O Module
  Copy File for External Data Items
  The JCL Member
  The CMD File
  Setting the Environment
  Posting Messages, Display on Screen & Write to Log File
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Glossary of Terms
  Comments or Suggestions
  About SimoTime

Introduction
(Next) (Previous) (Return-to-Top)

This suite of programs will describe how to use procedure pointers and external data items. A procedure pointer will be defined in a primary COBOL (or mainline) program. The procedure pointer will then be used to call a secondary COBOL program. A LINKAGE Section will not be required in the secondary COBOL program since the data will be accessed (or shared) using EXTERNAL Data Items. Also included is a suite of programs that show the traditional method for calling programs and passing data items.

This suite of programs will provide the following.

1. Provide an example of a COBOL program calling another COBOL program using traditional coding techniques.
2. Provide an example of defining and sharing data between two COBOL programs using traditional WORKING-STORAGE and LINKAGE section data definitions.
3. Provide an example of a COBOL program calling another COBOL program using a procedure pointer.
4. Provide an example of defining and sharing data between two COBOL programs using EXTERNAL Data Items.

The calling COBOL programs will build an 80-byte data record that will be passed to the called programs that will write the record to a sequential file.

The source code, data sets and documentation are provided in a single zipped file called CALLAM01.ZIP. This zipped file may be downloaded from the SimoTime Web site. In the Windows and Micro Focus environment the file names have file extensions. When the source memebrs are uploaded to a ZOS Mainframe from the Windows and Micro Focus environment the file extensions are dropped.

Procedure Pointer
(Next) (Previous) (Return-to-Top)

Procedure pointers are data items defined with the USAGE IS PROCEDURE-POINTER clause. You can set a procedure-pointer data item by using format 6 of the SET statement. You can set procedure-pointers to contain entry addresses (or pointers) to the following entry points:.

1. Another COBOL program
2. A program written in another language.
3. An alternate entry point in another COBOL program (as defined in an ENTRY statement).

External Data
(Next) (Previous) (Return-to-Top)

COBOL programs can share data items by using the EXTERNAL clause. You specify the EXTERNAL clause on the 01-level data description in the WORKING-STORAGE Section of the COBOL program. The following rules apply.

1. Items subordinate to an EXTERNAL group item inherit the EXTERNAL property.
2. The name used for the data item cannot be used on another EXTERNAL item within the same program.
3. The VALUE clause cannot be specified for any group item, or subordinate item, that is EXTERNAL.
4. EXTERNAL data cannot be initialized. Its initial value at run time is undefined.

Note: If the application requires that EXTERNAL data items be initialized they may be explicitly initialized in the main program.

A COBOL program within a run unit that has the same data description for the item as the program containing (or defining) the item may access and process the data item. For example, if program A had the following data description:

       01  MY-EXTERNAL-ITEM      PIC X(10) EXTERNAL.

Program B could access the data item by having the identical data description in its WORKING-STORAGE Section.

Note: If the EXTERNAL data items are not identical then Program B will fail at execution time.

Standard CALL, Program Name & LINKAGE Section
(Next) (Previous) (Return-to-Top)

This section describes by example a COBOL program that uses the traditional method of calling a second COBOL program by program name. Parameters are passed using data (or a pass area) that is defined in the WORKING-STORAGE section of the calling program and is referenced in the LINKAGE section of the called program.

Standard CALL, Primary COBOL Program
(Next) (Previous) (Return-to-Top)

The following (CALLUSC1.CBL) is the primary (or calling) COBOL program that uses a standard "CALL by Program Name" approach to do the call. The data items are defined in the WORKING-STORAGE Section of the calling program and are passed to the called program via a USING clause on the call statement. To ensure the data is defined identically in both programs a copy file (PASSUS80.CPY) is used to define the data.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CALLUSC1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2010 SimoTime Enterprises, LLC.            *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only and does not imply publication   *
      * or disclosure.                                                *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any non-commercial purpose and without fee is hereby      *
      * granted, provided the SimoTime copyright notice appear on all *
      * copies of the software. The SimoTime name or Logo may not be  *
      * used in any advertising or publicity pertaining to the use    *
      * of the software without the written permission of SimoTime    *
      * Enterprises.                                                  *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Enterprises. Once the fee is received by SimoTime    *
      * the latest version of the software will be delivered and a    *
      * license will be granted for use within an enterprise,         *
      * provided the SimoTime copyright notice appear on all copies   *
      * of the software. The SimoTime name or Logo may not be used    *
      * in any advertising or publicity pertaining to the use of the  *
      * software without the written permission of SimoTime           *
      * Enterprises.                                                  *
      *                                                               *
      * SimoTime Enterprises makes no warranty or representations     *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any express or implied warranty,     *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Enterprises shall not be liable for any direct, indirect,     *
      * special or consequential damages resulting from the loss of   *
      * use, data or projects, whether in an action of contract or    *
      * tort, arising out of or in connection with the use or         *
      * performance of this software                                  *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      *
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CALLUSC1 '.
           05  T2 pic X(34) value 'Standard Call with Linkage Section'.
           05  T3 pic X(10) value ' v07.06.11'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CALLUSC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2010 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CALLUSC1 '.
           05  C2 pic X(32) value 'Thank you, this technology was p'.
           05  C3 pic X(32) value 'roduced at SimoTime Enterprises,'.
           05  C4 pic X(04) value ' LLC'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CALLUSC1 '.
           05  C2 pic X(32) value 'Please send all inquires or sugg'.
           05  C3 pic X(32) value 'estions to the helpdesk@simotime'.
           05  C4 pic X(04) value '.com'.

      *****************************************************************
      * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine.    *
      *****************************************************************
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CALLUSC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

       01  TEST-RECORD.
           05  filler              pic X(12) value 'Test Record '.
           05  TEST-RECORD-COUNT   pic 9(11) value 0.

       01  RECORD-LIMIT            pic 9(5)  value 25000.

       COPY PASSWS80.

      *****************************************************************
      * The Call statements in this program do a "CALL by Name" with a
      * USING clause to pass data...
      *
       PROCEDURE DIVISION.

           perform Z-POST-COPYRIGHT

           move 'OPEN' to PASS-WS-80-REQUEST
           call 'CALLUSC2' using PASS-WS-80

           move 'PUT ' to PASS-WS-80-REQUEST
           perform until TEST-RECORD-COUNT not < RECORD-LIMIT
               add 1 to TEST-RECORD-COUNT
               move TEST-RECORD to PASS-WS-80-DATA
               call 'CALLUSC2' using PASS-WS-80
           end-perform

           move 'CLOZ' to PASS-WS-80-REQUEST
           call 'CALLUSC2' using PASS-WS-80

           perform Z-THANK-YOU.

           GOBACK.

      *****************************************************************
      * The following Z-ROUTINES provide administrative functions     *
      * for this program.                                             *
      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT
           add 12 to ZERO giving RETURN-CODE
           STOP RUN.
      *    exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-MESSAGE-TEXT.
           if MESSAGE-TEXT-2 = SPACES
               display MESSAGE-BUFFER(1:79)
           else
               display MESSAGE-BUFFER
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE
           display SIM-COPYRIGHT
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01
           display SIM-THANKS-02
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Standard CALL, Secondary COBOL Program, an I/O Module
(Next) (Previous) (Return-to-Top)

The following (CALLUSC2.CBL) is the secondary (or called) COBOL program that receives control via a traditional call by name. The data items are defined in the WORKING-STORAGE Section of the calling program and are passed to the called program via a USING clause on the call statement. The data items are then accessed based on the data definitions of the called program's LINKAGE Section. To ensure the data is defined identically in both programs a copy file (PASSUS80.CPY) is used to define the data. This called program is an I/O module that simply writes records to a record sequential file.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CALLUSC2.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      *             A product of SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *  An I/O Module for a New Sequential File with Fixed, 80-Byte  *
      *                                                               *
      *                                   Record    Record     Key    *
      *  Function  Name     Organization  Format    Max-Min  Pos-Len  *
      *  OUTPUT    SIMOSEQ1 SEQUENTIAL    FIXED      00080            *
      *                                                               *
      *****************************************************************
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT SIMOSEQ1-FILE  ASSIGN TO       SIMOSEQ1
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS SIMOSEQ1-STATUS.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       FD  SIMOSEQ1-FILE
           DATA RECORD    IS SIMOSEQ1-REC.
       01  SIMOSEQ1-REC.
           05  SIMOSEQ1-DATA-01 PIC X(80).

      *****************************************************************
       WORKING-STORAGE SECTION.
       01  SIMOSEQ1-STATUS.
           05  SIMOSEQ1-STATUS-L     pic X.
           05  SIMOSEQ1-STATUS-R     pic X.
       01  SIMOSEQ1-EOF              pic X       value 'N'.
       01  SIMOSEQ1-OPEN-FLAG        pic X       value 'C'.

      *****************************************************************
      * The following buffers are used to create a four-byte status   *
      * code that may be displayed.                                   *
      *****************************************************************
       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  IO-STATUS-04.
           05  IO-STATUS-0401      pic 9     value 0.
           05  IO-STATUS-0403      pic 999   value 0.
       01  TWO-BYTES-BINARY        pic 9(4)  BINARY.
       01  TWO-BYTES-ALPHA         redefines TWO-BYTES-BINARY.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.

      *****************************************************************
      * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine.    *
      *****************************************************************
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CALLUSC2 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

      *****************************************************************
       01  PROGRAM-NAME            pic X(8)     value 'CALLUSC2'.

       01  APPL-RESULT             pic S9(9)    comp.
           88  APPL-AOK            value 0.
           88  APPL-EOF            value 16.

      *****************************************************************
       LINKAGE SECTION.
       COPY PASSWS80.

      *****************************************************************
      * The "USING" clause on the following statement is required. The
      * PASS-WS-80 is a group items defined in the Copy File that is
      * located in the LINKAGE Section of this program.
      *
       PROCEDURE DIVISION using PASS-WS-80.
           evaluate PASS-WS-80-REQUEST
             when 'PUT ' move PASS-WS-80-DATA to SIMOSEQ1-DATA-01
                         perform SIMOSEQ1-WRITE
             when 'OPEN' perform SIMOSEQ1-OPEN
             when 'CLOZ' perform SIMOSEQ1-CLOSE
             when other  add 16 to ZERO giving RETURN-CODE
                         move 0016 to PASS-WS-80-RESPOND
           end-evaluate

           GOBACK.
      *****************************************************************
      * I/O Routines for the OUTPUT File...                           *
      *****************************************************************
       SIMOSEQ1-WRITE.
           if  SIMOSEQ1-OPEN-FLAG = 'C'
               perform SIMOSEQ1-OPEN
           end-if
           write SIMOSEQ1-REC
           if  SIMOSEQ1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  SIMOSEQ1-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'WRITE Failure with SIMOSEQ1' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move SIMOSEQ1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       SIMOSEQ1-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open OUTPUT SIMOSEQ1-FILE
           if  SIMOSEQ1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to SIMOSEQ1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with SIMOSEQ1' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move SIMOSEQ1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       SIMOSEQ1-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close SIMOSEQ1-FILE
           if  SIMOSEQ1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to SIMOSEQ1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with SIMOSEQ1' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move SIMOSEQ1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * The following Z-ROUTINES provide administrative functions     *
      * for this program.                                             *
      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT
           add 12 to ZERO giving RETURN-CODE
           STOP RUN.
      *    exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-MESSAGE-TEXT.
           if MESSAGE-TEXT-2 = SPACES
               display MESSAGE-BUFFER(1:79)
           else
               display MESSAGE-BUFFER
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
      * Display the file status bytes. This routine will display as   *
      * four digits. If the full two byte file status is numeric it   *
      * will display as 00nn. If the 1st byte is a numeric nine (9)   *
      * the second byte will be treated as a binary number and will   *
      * display as 9nnn.                                              *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1 = '9'
               move IO-STAT1 to IO-STATUS-04(1:1)
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-04 to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           else
               move '0000' to IO-STATUS-04
               move IO-STATUS to IO-STATUS-04(3:2)
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-04 to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           exit.

      *****************************************************************
      *             A product of SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Standard CALL, Copy File for Working Storage Definitions
(Next) (Previous) (Return-to-Top)

The following (PASSWS80.CPY) is the COBOL copy file that is used by both programs to define or access the data Items. The COPY statement is placed in the WORKING-STORAGE Section of the calling program and the LINKAGE Section of the called program.

       01  PASS-WS-80.
           05  PASS-WS-80-REQUEST  pic X(4).
           05  PASS-WS-80-RESPOND  pic x(4).
           05  PASS-WS-80-DATA     pic X(80).

Standard CALL, the JCL Member
(Next) (Previous) (Return-to-Top)

The following (CALLUSJ1.JCL) is the Mainframe Job Control (or JCL) member that is used to run the sample application. Using this approach requires a valid license for Micro Focus Mainframe Express or Micro Focus Enterprise Server with the Mainframe Transaction Option (ES/MTO).

//CALLUSJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   -   Standard Call with a Linkage Section.
//* Author -   SimoTime Enterprises
//* Date   -   January 01, 1997
//*
//* This set of COBOL programs will use a standard calling interface
//* between a mainline program and an I/O module to create a new
//* sequential file with 80-byte, fixed-length records.
//*
//*         ************
//*         * CALLUSJ1 *
//*         ********jcl*
//*              *
//*              *
//*         ************
//*         *  IEFBR14 *      * Delete USE1SEQ1 File
//*         ********jcl*
//*              *
//*              *
//*         ************      ************
//*         * CALLUSC1 *-call-* CALLUSC2 *
//*         ********cbl*      ********cbl*
//*              *                 *
//*              *            ************
//*              *            * USE1SEQ1 *
//*              *            *******qsam*
//*         ************
//*         *   EOJ    *
//*         ************
//*
//* *******************************************************************
//* Step 1, Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//SIMOSEQ1 DD  DSN=SIMOTIME.DATA.USE1SEQ1,
//             DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 2, Create a new sequential file...
//*
//CALLUSS1 EXEC PGM=CALLUSC1
//STEPLIB  DD  DISP=SHR,DSN=MFI01.SIMOPROD.LOADLIB1
//SIMOSEQ1 DD  DISP=SHR,DSN=SIMOTIME.DATA.USE1SEQ1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*

Standard CALL, the Command File
(Next) (Previous) (Return-to-Top)

The following (CALLUSE1.CMD) is the Windows Command file that is used to run the sample application. Using this approach only requires a valid Micro Focus license for Net Express. Micro Focus Enterprise Server with the Mainframe Transaction Option (ES/MTO) is not required.

@echo OFF
rem  * *******************************************************************
rem  *                   This program is provided by:                    *
rem  *                    SimoTime Enterprises, LLC                      *
rem  *           (C) Copyright 1987-2010 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   -   Standard Call by Name with a Linkage Section.
rem  * Author -   SimoTime Enterprises
rem  * Date   -   January 01, 2006
rem  *
rem  * This set of COBOL programs will use a standard calling interface
rem  * between a mainline program and an I/O module to create a new
rem  * sequential file with 80-byte, fixed-length records.
rem  *
rem  * ********************************************************************
rem  * Step 1 of 2, Set the global environment variables...
rem  *
     setlocal
     call Env1PROD
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE "*******************************************************CallUsE1"
     call SimoNOTE "Starting JobName CallUsE1"
rem  * ********************************************************************
rem  * Step 2 of 2, Execute the sample program...
rem  *
     set SIMOSEQ1=%BaseLib1%\DataLibA\Wrk1\USE1Cmd1.DAT
     echo %SYSOUT%
     if exist %SIMOSEQ1% erase %SIMOSEQ1%
     run CALLUSC1
     if ERRORLEVEL = 1 set JobStatus=0001
     if not "%JobStatus%" == "0000" goto :EojNOK
:EojAOK
     call SimoNOTE "Finished JobName CallUsE1, Job Status is %JobStatus%"
     goto :End
:EojNOK
     call SimoNOTE "ABENDING JobName CallUsE1, Job Status is %JobStatus%"
     goto :End
:End
     call SimoNOTE "Conclude SysOut is %SYSOUT%"
     if not "%1" == "nopause" pause
     endlocal

Procedure Pointer & External Data Items
(Next) (Previous) (Return-to-Top)

This section describes by example a COBOL program that uses a procedure pointer to call a second COBOL program. Data is passed (or shared) by both programs using EXTERNAL Data Items that are defined in the WORKING-STORAGE Section of each program. A LINKAGE Section is not required in the called program.

Procedure Pointer, Primary COBOL Program
(Next) (Previous) (Return-to-Top)

The following (CALLPEC1.CBL) is the primary (or calling) COBOL program that uses a procedure pointer to do the call. Both programs use EXTERNAL Data Items to pass (or share) data items. To ensure the EXTERNAL Data is defined identically in both programs a copy file (PASSEX80.CPY) is used to define the data.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CALLPEC1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2010 SimoTime Enterprises, LLC.            *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only and does not imply publication   *
      * or disclosure.                                                *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any non-commercial purpose and without fee is hereby      *
      * granted, provided the SimoTime copyright notice appear on all *
      * copies of the software. The SimoTime name or Logo may not be  *
      * used in any advertising or publicity pertaining to the use    *
      * of the software without the written permission of SimoTime    *
      * Enterprises.                                                  *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Enterprises. Once the fee is received by SimoTime    *
      * the latest version of the software will be delivered and a    *
      * license will be granted for use within an enterprise,         *
      * provided the SimoTime copyright notice appear on all copies   *
      * of the software. The SimoTime name or Logo may not be used    *
      * in any advertising or publicity pertaining to the use of the  *
      * software without the written permission of SimoTime           *
      * Enterprises.                                                  *
      *                                                               *
      * SimoTime Enterprises makes no warranty or representations     *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any express or implied warranty,     *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Enterprises shall not be liable for any direct, indirect,     *
      * special or consequential damages resulting from the loss of   *
      * use, data or projects, whether in an action of contract or    *
      * tort, arising out of or in connection with the use or         *
      * performance of this software                                  *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      *
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CALLPEC1 '.
           05  T2 pic X(34) value 'Procedural-Pointer/External-Memory'.
           05  T3 pic X(10) value ' v07.06.11'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CALLPEC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2010 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CALLPEC1 '.
           05  C2 pic X(32) value 'Thank you, this technology was p'.
           05  C3 pic X(32) value 'roduced at SimoTime Enterprises,'.
           05  C4 pic X(04) value ' LLC'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CALLPEC1 '.
           05  C2 pic X(32) value 'Please send all inquires or sugg'.
           05  C3 pic X(32) value 'estions to the helpdesk@simotime'.
           05  C4 pic X(04) value '.com'.

      *****************************************************************
      * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine.    *
      *****************************************************************
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CALLPEC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

       01  TEST-RECORD.
           05  filler              pic X(12) value 'Test Record '.
           05  TEST-RECORD-COUNT   pic 9(11) value 0.

       01  RECORD-LIMIT            pic 9(9)  value 25000.
      *01  RECORD-LIMIT            pic 9(9)  value 500000.

       01  CALLPEC2-PTR            PROCEDURE-POINTER.
       01  CALLPEC2-PGM            pic X(8)    value 'CALLPEC2'.

       COPY PASSEX80.

      *****************************************************************
       PROCEDURE DIVISION.

           perform Z-POST-COPYRIGHT

           set CALLPEC2-PTR to entry CALLPEC2-PGM

           move 'OPEN' to PASS-EX80-REQUEST
           call CALLPEC2-PTR

           move 'PUT ' to PASS-EX80-REQUEST
           perform until TEST-RECORD-COUNT not < RECORD-LIMIT
               add 1 to TEST-RECORD-COUNT
               move TEST-RECORD to PASS-EX80-DATA
               call CALLPEC2-PTR
           end-perform

           move 'CLOZ' to PASS-EX80-REQUEST
           call CALLPEC2-PTR

           perform Z-THANK-YOU.

           GOBACK.

      *****************************************************************
      * The following Z-ROUTINES provide administrative functions     *
      * for this program.                                             *
      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT
           add 12 to ZERO giving RETURN-CODE
           STOP RUN.
      *    exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-MESSAGE-TEXT.
           if MESSAGE-TEXT-2 = SPACES
               display MESSAGE-BUFFER(1:79)
           else
               display MESSAGE-BUFFER
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE
           display SIM-COPYRIGHT
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01
           display SIM-THANKS-02
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Procedure Pointer, Secondary COBOL Program, an I/O Module
(Next) (Previous) (Return-to-Top)

The following (CALLPEC2.CBL) is the secondary (or called) COBOL program that receives control via a procedure pointer. Both programs use EXTERNAL Data Items to pass (or share) data items. To ensure the EXTERNAL Data is defined identically in both programs a copy file (PASSEX80.CPY) is used to define the data. This program is an I/O module that simply writes records to a record sequential file.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CALLPEC2.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      *           This program was generated by SimoZAPS              *
      *             A product of SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *  An I/O Module for a New Sequential File with Fixed, 80-Byte  *
      *                                                               *
      *                                   Record    Record     Key    *
      *  Function  Name     Organization  Format    Max-Min  Pos-Len  *
      *  OUTPUT    SIMOSEQ1 SEQUENTIAL    FIXED      00080            *
      *****************************************************************
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT SIMOSEQ1-FILE  ASSIGN TO       SIMOSEQ1
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS SIMOSEQ1-STATUS.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       FD  SIMOSEQ1-FILE
           DATA RECORD    IS SIMOSEQ1-REC.
       01  SIMOSEQ1-REC.
           05  SIMOSEQ1-DATA-01 PIC X(80).

      *****************************************************************
       WORKING-STORAGE SECTION.
       01  SIMOSEQ1-STATUS.
           05  SIMOSEQ1-STATUS-L     pic X.
           05  SIMOSEQ1-STATUS-R     pic X.
       01  SIMOSEQ1-EOF              pic X       value 'N'.
       01  SIMOSEQ1-OPEN-FLAG        pic X       value 'C'.

      *****************************************************************
      * The following buffers are used to create a four-byte status   *
      * code that may be displayed.                                   *
      *****************************************************************
       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  IO-STATUS-04.
           05  IO-STATUS-0401      pic 9     value 0.
           05  IO-STATUS-0403      pic 999   value 0.
       01  TWO-BYTES-BINARY        pic 9(4)  BINARY.
       01  TWO-BYTES-ALPHA         redefines TWO-BYTES-BINARY.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.

      *****************************************************************
      * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine.    *
      *****************************************************************
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CALLPEC2 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

      *****************************************************************
       01  PROGRAM-NAME            pic X(8)     value 'CALLPEC2'.

       01  APPL-RESULT             pic S9(9)    comp.
           88  APPL-AOK            value 0.
           88  APPL-EOF            value 16.

       COPY PASSEX80.

      *****************************************************************
       PROCEDURE DIVISION.

           evaluate PASS-EX80-REQUEST
             when 'PUT ' move PASS-EX80-DATA to SIMOSEQ1-DATA-01
                         perform SIMOSEQ1-WRITE
             when 'OPEN' perform SIMOSEQ1-OPEN
             when 'CLOZ' perform SIMOSEQ1-CLOSE
             when other  add 16 to ZERO giving RETURN-CODE
                         move 0016 to PASS-EX80-RESPOND
           end-evaluate

           GOBACK.

      *****************************************************************
      * I/O Routines for the OUTPUT File...                           *
      *****************************************************************
       SIMOSEQ1-WRITE.
           if  SIMOSEQ1-OPEN-FLAG = 'C'
               perform SIMOSEQ1-OPEN
           end-if
           write SIMOSEQ1-REC
           if  SIMOSEQ1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  SIMOSEQ1-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'WRITE Failure with SIMOSEQ1' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move SIMOSEQ1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       SIMOSEQ1-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open OUTPUT SIMOSEQ1-FILE
           if  SIMOSEQ1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to SIMOSEQ1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with SIMOSEQ1' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move SIMOSEQ1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       SIMOSEQ1-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close SIMOSEQ1-FILE
           if  SIMOSEQ1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to SIMOSEQ1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with SIMOSEQ1' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move SIMOSEQ1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * The following Z-ROUTINES provide administrative functions     *
      * for this program.                                             *
      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT
           add 12 to ZERO giving RETURN-CODE
           STOP RUN.
      *    exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-MESSAGE-TEXT.
           if MESSAGE-TEXT-2 = SPACES
               display MESSAGE-BUFFER(1:79)
           else
               display MESSAGE-BUFFER
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
      * Display the file status bytes. This routine will display as   *
      * four digits. If the full two byte file status is numeric it   *
      * will display as 00nn. If the 1st byte is a numeric nine (9)   *
      * the second byte will be treated as a binary number and will   *
      * display as 9nnn.                                              *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1 = '9'
               move IO-STAT1 to IO-STATUS-04(1:1)
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-04 to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           else
               move '0000' to IO-STATUS-04
               move IO-STATUS to IO-STATUS-04(3:2)
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-04 to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           exit.
      *****************************************************************
      *             A product of SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Procedure Pointer, Copy File for Working Storage Definitions
(Next) (Previous) (Return-to-Top)

The following (PASSEX80.CPY) is the COBOL copy file that is used by both programs to define or access the EXTERNAL Data Items.

       01  PASS-EX80              EXTERNAL.
           05  PASS-EX80-REQUEST  pic X(4).
           05  PASS-EX80-RESPOND  pic x(4).
           05  PASS-EX80-DATA     pic X(80).

Procedure Pointer, the JCL Member
(Next) (Previous) (Return-to-Top)

The following (CALLPEJ1.JCL) is the Mainframe Job Control (or JCL) member that is used to run the sample application. Using this approach requires a valid license for Micro Focus Mainframe Express or Micro Focus Enterprise Server with the Mainframe Transaction Option (ES/MTO).

//CALLPEJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   -   Procedure Pointer with External Data Items.
//* Author -   SimoTime Enterprises
//* Date   -   January 01, 2006
//*
//* This set of COBOL programs will use a prodedure pointer to transfer
//* control between a mainline program to an I/O module to create a new
//* sequential file with 80-byte, fixed-length records. The parameters
//* are passed using EXTERNAL Data Items.
//* A LINKAGE Section is not required in the I/O module.
//*
//*         ************
//*         * CALLPEJ1 *
//*         ********jcl*
//*              *
//*              *
//*         ************
//*         *  IEFBR14 *      * Delete PEE1SEQ1 File
//*         ********jcl*
//*              *
//*              *
//*         ************      ************
//*         * CALLPEC1 *-call-* CALLPEC2 *
//*         ********cbl*      ********cbl*
//*              *                 *
//*              *            ************
//*              *            * PEE1SEQ1 *
//*              *            *******qsam*
//*         ************
//*         *   EOJ    *
//*         ************
//*
//* *******************************************************************
//* Step 1, Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//SIMOSEQ1 DD  DSN=SIMOTIME.DATA.PEE1SEQ1,
//             DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 2, Create a new sequential file...
//*
//CALLPES1 EXEC PGM=CALLPEC1
//STEPLIB  DD  DISP=SHR,DSN=MFI01.SIMOPROD.LOADLIB1
//SIMOSEQ1 DD  DISP=SHR,DSN=SIMOTIME.DATA.PEE1SEQ1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*

Procedure Pointer, the Command File
(Next) (Previous) (Return-to-Top)

The following (CALLPEE1.CMD) is the Windows Command file that is used to run the sample application. Using this approach only requires a valid Micro Focus license for Net Express. Micro Focus Enterprise Server with the Mainframe Transaction Option (ES/MTO) is not required.

@echo OFF
rem  * *******************************************************************
rem  *                   This program is provided by:                    *
rem  *                    SimoTime Enterprises, LLC                      *
rem  *           (C) Copyright 1987-2010 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   -   Procedure Pointer with External Data Items.
rem  * Author -   SimoTime Enterprises
rem  * Date   -   January 01, 2006
rem  *
rem  * This set of COBOL programs will use a prodedure pointer to transfer
rem  * control between a mainline program to an I/O module to create a new
rem  * sequential file with 80-byte, fixed-length records. The parameters
rem  * are passed (or shared) using EXTERNAL Data Items.
rem  * A LINKAGE Section is not required in the I/O module.
rem  *
rem  * ********************************************************************
rem  * Step 1 of 2, Set the global environment variables...
rem  *
     setlocal
     call Env1PROD
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE "*******************************************************CallPeE1"
     call SimoNOTE "Starting JobName CallPeE1"
rem  * ********************************************************************
rem  * Step 2 of 2, Execute the sample program...
rem  *
     set SIMOSEQ1=%BaseLib1%\DataLibA\Wrk1\SimoSeq1.DAT
     set SYSOUT=%BaseLib1%\LOGS\ApplSysOut.TXT
     echo %SYSOUT%
     run CALLPEC1
     if ERRORLEVEL = 1 set JobStatus=0001
     if not "%JobStatus%" == "0000" goto :EojNOK
:EojAOK
     call SimoNOTE "Finished JobName CallPeE1, Job Status is %JobStatus%"
     goto :End
:EojNOK
     call SimoNOTE "ABENDING JobName CallPeE1, Job Status is %JobStatus%"
     goto :End
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause
     endlocal

Setting the Environment
(Next) (Previous) (Table-of-Contents)

The following (Env1PROD.CMD) is a Windows Command file that is used to set the commonly used environment variables. This command file is used by many of the examples provided by SimoTime. It provides a single point of configuration for commonly used environment settings.

rem  * *******************************************************************
rem  * Set the commonly used environment variables. This is used to
rem  * provide a single point for managing the commonly used environment
rem  * variables.
rem  *
     set BaseLib1=c:\SimoSAM1
     set syslog=%BaseLib1%\LOGS\SpoolSysLog.TXT
     set SimoNOTE=%BaseLib1%\LOGS\SimoNoteLog01.TXT
     call SimoNOTE "Starting JobName Env1PROD.CMD"
rem  *
     set sysout=%BaseLib1%\LOGS\ApplSysOut.TXT
     set CobCpy=%BaseLib1%\CobCpy1;c:\SimoLIBR
rem  *
rem  * set MFTRACE_CONFIG=c:\SimoSAM1\LOGS\TRACE001\ctfrtsfs.cfg
rem  * set MFTRACE_LOGS=c:\SimoSAM1\LOGS\TRACE001
rem  *
rem  * The following SORTSPACE of 1 gigabyte is used when sorting very large files.
rem  * The value is the digit one (1) followed by nine (9) zeroes. To allocate this
rem  * amount of memory for sorting will require a minimum of two (2) gigabytes of RAM.
rem  set SORTSPACE=1000000000
rem  *
rem  * Set environment for MFBSI (Micro Focus Batch Scheduling Interface)
     set ES_EMP_EXIT_1=mfbsiemx
     set MFBSI_DIR=%BaseLib1%\BSIA\SimoBatA
     set MFBSIEOP_CMD=ENABLE
     set MFBSIEOP_CSV=ENABLE
rem  *
rem  * The following is used to map the location of files that are allocated using JCL
rem  * with ES/MTO.
     set ES_ALLOC_OVERRIDE=%BaseLib1%\SysLibA1\CatMapA1.cfg
rem  *
rem  * Set the environment for Core Dump on System error, CBLCORE file
rem  set COBCONFIG_=%BaseLib1%\SysLibA1\Diagnose.CFG
rem  *
rem  * Specify the location of the IDY files when animating
     set COBIDY=%BaseLib1%\COBOL
rem  *
rem  * The following may need to be adjusted based on individual systems and the
rem  * various versions of the Operating System, Sub-Systems and other software.
     if "%ENV1PROD%" == "Y" goto :NOPATH
     set iexplore=C:\Program Files\Internet Explorer
     set path="C:\Program Files\Micro Focus\Net Express 5.0\Base\";"C:\Program Files\Micro Focus\Net Express 5.0\Base\bin";%PATH%;
rem  set path="C:\Program Files\Micro Focus\Server 5.0\Base\";"C:\Program Files\Micro Focus\Server 5.0\Base\bin";%PATH%;
:NOPATH
     set cobpath=%BaseLib1%\ProdLibA;%BaseLib1%\ProdLibA\UTIL
     set JobStatus=0000
     set StepStatus=0000
     set ENV1PROD=Y
     call SimoNOTE "Finished JobName Env1PROD.CMD"

Posting Messages, Display on Screen & Write to Log File
(Next) (Previous) (Table-of-Contents)

The following (SimoNOTE.CMD) is a Windows Command file that is used to display messages on the screen and write messages to a log file. This command file is used by many of the examples provided by SimoTime. It provides a consistent method for displaying and logging messages when called from other command files.

@echo OFF
rem  * *******************************************************************
rem  *                   This program is provided by:                    *
rem  *                    SimoTime Enterprises, LLC                      *
rem  *           (C) Copyright 1987-2010 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text    - Display message on screen and write to a log file.
rem  * Author  - SimoTime Enterprises
rem  *
rem  * This script may be called from other scripts and expects a single
rem  * parameter enclosed in double quotes. The double quotes will be
rem  * removed. Before writing to the log file a date and time stamp
rem  * will be inserted in front of the message text.
rem  *
rem  * Note: The tilde (~) removes leading/trailing double-quotes.
rem  *
if "%SimoNOTE%" == "" set SimoNOTE=c:\SimoLIBR\LOGS\SimoTime.LOG
echo %date% %time% %~1>> %SimoNOTE%
echo %~1

Summary
(Next) (Previous) (Table-of-Contents)

The purpose of this suite of programs is as follows.

1. Provide an example of a COBOL program calling another COBOL program using traditional coding techniques.
2. Provide an example of defining and sharing data between two COBOL programs using traditional WORKING-STORAGE and LINKAGE section data definitions.
3. Provide an example of a COBOL program calling another COBOL program using a procedure pointer.
4. Provide an example of defining and sharing data between two COBOL programs using EXTERNAL Data Items.

The calling COBOL programs will build an 80-byte data record that will be passed to the called programs that will write the record to a sequential file.

Software Agreement and Disclaimer
(Next) (Previous) (Table-of-Contents)

Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Enterprises. Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.

SimoTime Enterprises makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software, documentation or training material.

Downloads and Links to Similar Pages
(Next) (Previous) (Table-of-Contents)

You may download an evaluation copy of this software at http://www.simotime.com/sim4dzip.htm#COBOLcallam01 or view the complete list of SimoTime Examples at http://www.simotime.com/sim4dzip.htm.

Note: You must be attached to the Internet to download a Z-Pack or view the list.

This document provides a quick summary of the  File Status Key  for VSAM data sets and QSAM files.

Check out  The JCL Connection  for more mainframe JCL examples.

Check out  The SimoTime Library  for a wide range of topics for Programmers, Project Managers and Software Developers.

To review all the information available on this site start at  The SimoTime Home Page .

Glossary of Terms
(Next) (Previous) (Table-of-Contents)

Check out  The SimoTime Glossary  for a list of terms and definitions used in the documents provided by SimoTime.

Comments or Suggestions
(Next) (Previous) (Table-of-Contents)

If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com

About SimoTime Enterprises
(Next) (Previous) (Table-of-Contents)

Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
When technology complements business