fujitsu cobol - users guide

784
Microsoft Windows  ® Microsoft Windows  95 Microsoft Windows NT COBOL85 User’s Guide 3.0

Upload: riccooliverafilho

Post on 07-Aug-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 1/783

Microsoft Windows ® 

Microsoft Windows 95™

Microsoft Windows NT™

COBOL85

User’s Guide

3.0

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 2/783

Third Edition: March 1997

The contents of this manual may be revised without prior notice. No part ofthis document may be reproduced or transmitted in any form or by anymeans, electronic or mechanical, for any purpose, without the expresswritten permission of Fujitsu Limited.

© 1997 Fujitsu Limited. All Rights Reserved.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 3/783

COBOL85 User’s Guide iii

Preface

COBOL85 allows you to create, execute, and debug COBOLprograms with Microsoft Windows 95, Windows NT and

Windows 3.1. This manual describes the functions andoperations of COBOL85, but does not detail COBOL syntax.Refer to the “COBOL85 Reference Manual” for details on COBOLsyntax.

Throughout this manual, Windows 95 and Windows NT-specificitems are denoted with (32); Windows 3.1-specific items are

denoted with (16).

Audience

This manual is for users who develop COBOL programs usingCOBOL85. This manual assumes users possess basic knowledgeof COBOL 85 and are familiar with the appropriate Windowsplatform.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 4/783iv COBOL85 User’s Guide

How this Manual is Organized

This manual consists of the following chapters and appendixes:

Chapter ContentsChapter 1. Overview of COBOL85 The operating environment and functions

of COBOL85.Chapter 2. Creating and Editing aProgram

Writing a COBOL program.

Chapter 3. Compiling Programs Compiling COBOL programs.

Chapter 4. Linking Programs Linking COBOL programs.Chapter 5. Executing Programs Executing a COBOL program that has beencompiled and linked.

Chapter 6. Project Management Registering files and control linker options.Chapter 7. File Processing Using files.Chapter 8. Printing Printing data and documents.Chapter 9. Input-Output Using Screens Transferring data with screens.Chapter 10. Calling Subprograms (Inter-Program Communication)

Calling subprograms from a COBOLprogram.

Chapter 11. Using ACCEPT and DISPLAYStatements

The simplified input-output, commandline argument operation, and environmentvariable operation functions, usingACCEPT and DISPLAY statements.

Chapter 12. Using SORT/MERGEStatements (Sort-Merge Function)

Sort-merge processing.

Chapter 13. System Program Description(SD) Functions

Functions such as the pointer and ADDR,used to create system programs.

Chapter 14. Communication Functions Using simplified inter-application andother communication types.Chapter 15. Database (SQL) Remote database access under ODBC.Chapter 16. Distributed DevelopmentSupport Functions

Designing and developing COBOLprograms in a distributed environment.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 5/783

COBOL85 User’s Guide v

Chapter ContentsAppendix A. Compiler Options The options provided for the COBOL85

compiler.Appendix B. I-O Status List The values returned from input-output

statement execution, indicating I-O statusand their meanings.

Appendix C. Global Optimization The optimization performed by theCOBOL85 compiler.

Appendix D. Built-in Function List The list of COBOL85 built-in functions.Appendix E. Special Registers Used withScreen and Form Functions

The values set in the special registers forscreen and form functions.

Appendix F. Message Lists Compilation and execution messages.Appendix G. Writing Special Literals Writing literals for Windows.Appendix H. High-Speed File Processing Specifications for high-speed file

processing.Appendix I. GS-series FunctionComparison

Compares the functions available with theGS- series and this COBOL85.

Appendix J. Command Formats Compiler and linker command formats.Appendix K. FCB Control Statement The specification of the FCB control

statement.Appendix L. Indexed File Recovery Recovering indexed files (includes

examples, codes, and messages).

Appendix M. Using Other File Systems Using Btrieve and RDM files.Appendix N. A COBOL-SupportedSubroutine

The subroutine for receiving a windowhandle.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 6/783

vi COBOL85 User’s Guide

How to Use This Manual

If you are a first-time user of this product, start with Chapter 1.

If you want information about the steps from COBOL programgeneration to execution, refer to Chapter 2 through Chapter 6.

If you want to know how to use various functions of COBOL85,refer to Chapter 7 through Chapter 13.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 7/783

COBOL85 User’s Guide vii

 Conventions Used in this Manual

This manual uses the following typographic conventions.

Example of Convention Description

setup Characters you enter appear in bold.

Program-name Underlined text indicates a place holderfor information you supply.

ENTER Small capital letters are used for thename of keys and key sequences suchas ENTER and CTRL+R. A plus sign(+) indicates a combination of keys.

… Ellipses indicate the item immediatelypreceding can be specified repeatedly.

Edit, Literal Names of pulldown menus andoptions appear with the initial lettercapitalized.

[def] Indicates that the enclosed item may beomitted.

{ABC|DEF} Indicates that one of the enclosed items

delimited by | is to be selected.CHECKWITH PASCAL LINKAGEALLPARAGRAPH-IDCOBOLALL

Commands, statements, clauses, andoptions you enter or select appear inuppercase. Program section names, andsome proper names also appear inuppercase. Defaults are underlined.

PROCEDURE DIVISION  :  ADD 1 TO POW-FONTSIZE OF LABEL1.  IF POW-FONTSIZE OF LABEL1 > 70 THEN  MOVE 1 TOW POW-FONTSIZE OF LABEL1.  END-IF.

This font is used for examples ofprogram code.

The sheet acts as an application creationwindow.

Italics are occasionally used foremphasis.

“COBOL Reference Manual”Refer to “Compile Options” in Chapter 5.

References to other publications orsections within publications are inquotation marks.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 8/783

viii COBOL85 User’s Guide

Differences Between Operating Systems

Windows 95 and Windows NT are occasionally denoted with(32); Windows 3.1 is occasionally denoted with (16). COBOL85supports the following operating systems:

• Windows 95 Operating System

• Windows NT Workstation Operating System 3.5

• Windows NT Server Network Operating System 3.5

• Windows Operating System 3.1

We have tried to make all of our examples position-sensitive.However, given the restrictions of the size of the page, in someexamples we have not been able to accomplish this. You shouldbe aware that COBOL85 is a position-sensitive language.

The term national language or national in this manual indicatesdouble byte character languages, such as Japanese, Korean, orChinese. Functions that are only available in the nationallanguage version of this system are indicated by [*XXXXXX*].

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 9/783

COBOL85 User’s Guide ix

Related Manuals

Other manuals for COBOL85 and related products:

Title Contents

“COBOL85 Reference Manual” Detailed explanation of COBOL85 syntax (opensystem)

“Getting Started with Fujitsu COBOL” Demonstration of COBOL85 functions using thesample programs as examples

“FUJITSU COBOL Debugging Guide” Explanation of the debugging functions ofCOBOL85

”Migration Guide MF to FujitsuCOBOL”

Migration information related to convertingCOBOL applications from Micro Focus to COBL85

“COBOL Debugging Manual” Usage information associated with the COBOL85“Power COBOL User’s Guide” Information related to using Power COBOL

graphical programming capabilities“Power COBOL Programming Guide” Explanation of how to create graphical COBOL

applications“Power FORM Getting Started” Explanation of how to create form descriptors

The following products are not supported in the English-

language version of this product:• SequeLink

• MeFt/NET

• MeFt/NET-SV

• BS*NET

• RDB/7000 Server for Windows NT

• RDB II

• RDB II Esql-COBOL

• PowerAIM

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 10/783

x COBOL85 User’s Guide

Trademarks

MS-DOS, Visual Basic, Windows, are registered trademarks and

Visual C++, Microsoft Open Database Connectivity SoftwareDevelopment Kit, Windows 95, and Windows NT aretrademarks of Microsoft Corporation.

UNIX is a registered trademark in the United States and othercountries, licensed exclusively through X/Open CompanyLimited.

Btrieve is a trademark of Btrieve Technologies, Inc.NetWare is a registered trademark of Novell, Inc.

HP, HP-UX, and SoftBench are trademarks of the Hewlett-Packard Company.

Oracle is a registered trademark of Oracle Corporation.

SequeLink is a registered trademark of TechGnOsIsInternational, Inc.

INFORMIX is a registered trademark of Informix Software Co.

EPSON ESC/P is a registered trademark of Seiko Epson, Inc.

LIPS is a registered trademark of Canon, Inc.

Sun is a trademark of Sun Microsystems Company (U.S.).

Other product names are trademarks or registered trademarks ofeach company. Trademark indications are omitted for somesystem and product names described in this manual.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 11/783

COBOL85 User’s Guide xi

Acknowledgment

The language specifications of COBOL are based on the originalspecifications developed by the work of the Conference on Data

Systems Languages (CODASYL). The specifications described inthis manual are also derived from the original. The followingpassages are quoted at the request of CODASYL.

“COBOL is an industry language and is not the property of anycompany or group of companies, or of any organization or groupof organizations. No warranty, expressed or implied, is made bythe COBOL Committee as to the accuracy and functioning of the

programming system and language. Moreover, no responsibilityis assumed by the committee, in connection therewith.

“The authors of the following copyrighted material haveauthorized the use of this material in part in the COBOLspecifications. Such authorization extends to the use of theoriginal specifications in other COBOL specifications:

• FLOW-MATIC (Trademark of Sperry Rand Corporation),Processing for the UNIVAC I and II, Data AutomationSystems, copyrighted 1958, 1959, by Sperry RandCorporation.

• IBM Commercial Translator, Form No. F28-8013, copyrighted1959 by International Business Machines Corporation.

• FACT, DSI 27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell.”

All Rights Reserved, Copyright, Fujitsu Limited 1996.

All Rights Reserved, Copyright, Microsoft Corporation, 1983-1996.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 12/783

xii COBOL85 User’s Guide

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 13/783

COBOL85 User’s Guide xiii

Contents

Chapter 1. Overview of COBOL85................................................................................ 1

COBOL85 Functions.. ................................................................................................... 2COBOL Functions..................................................................................................... 2Programs and Utilities Provided by COBOL85 ..................................................... 3

COBOL85 Development Environment ....................................................................... 7Setting Up Environment Variables ......................................................................... 8Related Products......................................................................................................10

Developing a Program ................................................................................................11

Chapter 2. Creating and Editing a Program................................................ ................15

Creating the Program ..................................................................................................16Creating and Editing a COBOL Source Program .................................................16

Creating Library Text ..................................................................................................18Program Format...................................................................... .....................................19

Fixed Format............................................................................................................19Variable Format.......................................................................................................19Free Format..............................................................................................................20

Compiler Directing Statement........................... .........................................................20Chapter 3. Compiling Programs................................................................... ................23

Compiling Sample Programs................................................. .....................................24Windows 95 and Windows NT..............................................................................24Windows 3.1 ............................................................................................................29

Resources Necessary for Compilation .......................................................................34Files Used by the COBOL85 Compiler ..................................................................34

Information Provided by the COBOL85 Compiler............................... ................38Compiling a COBOL Source Program .......................................................................40Compiling a Single Source File.......................................... .....................................40Compiling Several Source Files..............................................................................41

WINCOB Window.......................................................................................................43Activating the WINCOB Window (32)..................................................................43Specifying Continuous Compilation......................................................................44Specifying a File Name............................................................................................46Setting Compiler Options .......................................................................................47Specifying the Main Program... ..............................................................................47

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 14/783

xiv COBOL85 User’s Guide

Starting and Quitting Compilation ........................................................................49Compiler Options Dialog Box ....................................................................................50

Setting Compiler Options .......................................................................................50Setting a Library Name...........................................................................................54

Correcting a Compile Error ........................................................................................59Compile Messages.............................................................. .....................................59Using Error Search ..................................................................................................60

Using Commands to Compile ....................................................................................63COBOL32 Commands.............................................................................................63

Chapter 4. Linking Programs .......................................................................................67

Linking Sample Programs...................................................... .....................................68Windows 95 and Windows NT..............................................................................68Windows 3.1 ............................................................................................................70

Resources Required for Linking........................ .........................................................71Executable Files .......................................................................................................75DLLs ......................................................................................................... ................76Import Library.........................................................................................................76Module Definition File ............................................................................................76

Linkage Types and Program Structure......................................................................81Link Procedures...........................................................................................................84

Linking a Single Object Program............................................................................84Creating a DLL ........................................................................................................85

Creating an Executable Program with a Simple Structure...................................85Creating an Executable Program with a Dynamic Link Structure......................86Creating an Executable Program with a Dynamic Program Structure ...............88Creating a Library ...................................................................................................89Creating an Import Library ....................................................................................89

WINLINK.....................................................................................................................90Activating the WINLINK Window........................................................................90WINLINK [Linking Files] Window........................................................................91

Starting and Quitting Linking ................................................................................97WINLINK [Building COBOL Libraries] Window ................................................98

Using Commands to Link.................................. .......................................................101LINK Command (32).............................................................................................102LIB Command (32) ................................................................................................102Examples of Using the LINK and LIB commands (32) ......................................102LINK Command (16).............................................................................................103

Linker Messages ........................................................................................................105

Windows 95 and Windows NT............................................................................105Linker Messages (16).......................................................... ...................................107

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 15/783

COBOL85 User’s Guide xv

Chapter 5. Executing Programs ..................................................................................109

Executing Sample Programs .....................................................................................110Windows 95 and Windows NT............................................................................110Windows 3.1 ..........................................................................................................113

Execution Procedures.................................................................................. ..............117Before Executing COBOL Programs...................................................... ..............117

Executing COBOL Programs............................................. ...................................118Setting Run-time Environment Information............................................................119

Types of Run-time Environment Information.....................................................119How to Set Run-time Environment Information ................................................122

Format of Run-time Environment Information.......................................................129Environment Variables .........................................................................................129Entry Information.................................................................................... ..............147

WINEXEC ..................................................................................................................152

Activating the WINEXEC Window (32) ..............................................................152Activating the WINEXEC Window (16) ..............................................................154Entering a File Name.......................................................... ...................................154Starting and Quitting Execution...........................................................................155

Run-time Environment Setup Window (32)............................................................155Setting Environment Variable Information.........................................................158Setting Entry Information.....................................................................................160Saving to the Initialization File............................................................... ..............161

Setting Printers ......................................................................................................161Exiting the Run-time Environment Setup Window............................................162Run-time Environment Setup Window (16)............................................................162

Setting Environment Variable Information.........................................................163Setting Entry Information.....................................................................................164Saving to the Initialization File............................................................... ..............165Exiting from the Run-time Environment Setup Window ..................................165

Format of Run-time Options.................................................. ...................................166

Chapter 6. Project Management.................................................................................169

What is the Project Management Function? ............................................................170Resources Required for Project Management .........................................................171Project Management Procedures................................................................ ..............173Project Window .........................................................................................................175

Creating the Project File................................. .......................................................176Registering Files....................................................................................... ..............177

Setting Compiler Options .....................................................................................183Setting Linker Options ..........................................................................................185

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 16/783

xvi COBOL85 User’s Guide

Creating the Module Definition File ....................................................................185Building and Rebuilding the Project....................................................................187Modifying File Contents .......................................................................................187Executing Application Programs .........................................................................188

Chapter 7. File Processing...........................................................................................189

File Organization Types ............................................................................................190File Organization Types and Characteristics ......................................................190Record Sequential Files .........................................................................................191Line Sequential Files................................................................................ ..............192Relative Files..........................................................................................................193Indexed Files..........................................................................................................194Designing Records................................................................................... ..............194Processing Files........................................................................................ ..............196

Using Record Sequential Files ..................................................................................198Defining Record Sequential Files .........................................................................199Defining Record Sequential File Records ............................................................201Processing Record Sequential Files ......................................................................202Processing Outline.............................................................. ...................................204

Using Line Sequential Files......................................................................... ..............206Defining Line Sequential Files ..............................................................................206Defining Line Sequential File Records.......... .......................................................207Processing Line Sequential Files............................................................. ..............208

Processing Outline.............................................................. ...................................210Using Relative Files ...................................................................................................211

Defining Relative Files ..........................................................................................212Defining Relative File Records .............................................................................214Processing Relative Files .......................................................................................215Processing Outline.............................................................. ...................................218

Using Indexed Files ...................................................................................................221Defining Indexed Files ..........................................................................................222

Defining Indexed File Records .............................................................................224Processing Indexed Files......................................................................... ..............226Processing Outline.............................................................. ...................................228

Input-Output Error Processing.................................................................................232AT END Specification ...........................................................................................232INVALID KEY Specification ................................................................................233FILE STATUS Clause ............................................................................................233Error Procedures ...................................................................................................234

Input-Output Error Execution Results ................................................................235File Processing............................................................................................................236

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 17/783

COBOL85 User’s Guide xvii

Assigning Files......................................................................................... ..............237Exclusive Control of Files .....................................................................................240File Processing Results ..........................................................................................244

COBOL85 FILE UTILITY ..........................................................................................246Using the COBOL85 FILE UTILITY....................................................... ..............246COBOL85 FILE UTILITY Functions ....................................................................251

Chapter 8. Printing.......................................................................................................267Types of Printing Methods .......................................................................................268

Outline of Printing Methods.................................................................................268Print Characters.....................................................................................................271Form Overlay Patterns....................................................... ...................................275Forms Control Buffers (FCB)............................................. ...................................276Form Descriptors...................................................................................................277

Using Print File 1 .......................................................................................................278Outline....................................................................................................................279Program Specifications..........................................................................................280Program Execution................................................................................................283Examples of Programs ..........................................................................................287

Using Print File 2 .......................................................................................................292Outline....................................................................................................................293Program Specifications..........................................................................................293Program Execution................................................................................................302

Using Print Files with Form Descriptors .................................................................307Outline....................................................................................................................308Program Specifications..........................................................................................308Program Execution................................................................................................314

Using Presentation Files (Printing Forms)............................ ...................................315Outline....................................................................................................................316Work Procedures...................................................................................................317Generating Form Descriptors ...............................................................................318

Program Specifications..........................................................................................319Generating Printer Information Files ...................................................................323Program Execution................................................................................................324

Chapter 9. Input-Output Using Screens ...................................................................327

Types of Input-Output Using Screens......................................................................328Using Presentation Files (Screen Input-Output) .....................................................329

Outline....................................................................................................................329

Operation Environments ......................................................................................329Work Procedures...................................................................................................332

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 18/783

xviii COBOL85 User’s Guide

Generating Screen Descriptors.......................................... ...................................332Program Specification...........................................................................................333Generating Window Information Files ................................................................340Program Execution................................................................................................341

Using the Screen Handling Function .......................................................................343Outline....................................................................................................................344Screen Windows....................................................................................................344

User-Defined Function Keys ................................................................................345Program Specification...........................................................................................346Program Execution................................................................................................350

Chapter 10. Calling Subprograms (Inter-Program Communication) ...... ..............353

Outline of Calling Relationships...............................................................................354Calling Relationship Forms ..................................................................................354Differences Among Linkage Rules.................................... ...................................355

Linkage Rules and Supporting Compilers ..........................................................356Calling COBOL Programs from COBOL Programs ...............................................356

Calling Method......................................................................................................356Secondary Entry Points...................................................... ...................................357Returning Control and Exiting Programs............................................................357Passing Parameters................................................................................................358Sharing Data ..........................................................................................................359Return Codes .........................................................................................................360

Internal Programs.................................................................................... ..............361Notes.......................................................................................................................363

Linking C Programs ..................................................................................................364Calling C Programs from COBOL Programs......................................................364Calling COBOL Programs from C Programs......................................................368Correspondence of Data Types ............................................................................369Compiling Programs.............................................................................................371Executing Programs ..............................................................................................381

Chapter 11. Using ACCEPT and DISPLAY Statements..........................................383

ACCEPT/DISPLAY Function...................................................................................384Outline....................................................................................................................384Input/Output Destination Types and Specification Methods...........................385Reading/Writing Data with Console Windows .................................................386Writing Messages to Message Boxes ...................................................................390Programs Using Files ............................................................................................392

Entering Current Date and Time..........................................................................397Fetching Command Line Arguments.......................................................................399

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 19/783

COBOL85 User’s Guide xix

Outline....................................................................................................................399Environment Variable Handling Function ..............................................................403

Outline....................................................................................................................403

Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function) .................407

Outline of Sort and Merge Processing .....................................................................408Sort..........................................................................................................................408Merge......................................................................................................................408

Using Sort...................................................................................................................409Types of Sort Processing.......................................................................................411Program Specifications..........................................................................................411Program Compilation and Linkage......................................................................413Program Execution................................................................................................414

Using Merge...............................................................................................................415Types of Merge Processing...................................................................................417

Program Specifications..........................................................................................417Program Compilation and Linkage......................................................................419Program Execution................................................................................................419

Chapter 13. System Program Description (SD) Functions......................................421

Types of System Program Description Functions...................................................422Pointer ....................................................................................................................422ADDR Function and LENG Function.................................................... ..............422

PERFORM Statement without an “at end” Condition .......................................423Using Pointers.............................................................................................. ..............423

Outline....................................................................................................................423Program Specifications..........................................................................................424Program Compilation and Linkage......................................................................425Program Execution................................................................................................425

Using the ADDR and LENG Functions ...................................................................426Outline....................................................................................................................426

Program Specifications..........................................................................................426Program Compilation and Linkage......................................................................427Program Execution................................................................................................427

Using the PERFORM Statement without an “at end” Condition..........................428Outline....................................................................................................................428Program Specifications..........................................................................................428Program Compilation and Linkage......................................................................429Program Execution................................................................................................429

Chapter 14. Communication Functions.....................................................................431

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 20/783

xx COBOL85 User’s Guide

Communication Types ..............................................................................................432Using Presentation File Module (Asynchronous Message Communication) .......434

Outline....................................................................................................................435Operating Environment........................................................................................435Program Specifications..........................................................................................436Program Compilation and Linkage......................................................................440Program Execution................................................................................................440

Using ACM Communication.................................................................. ..............441Using Presentation File Module (Synchronous Communication Programs)........442

Outline....................................................................................................................443Program Specifications..........................................................................................445Program Compilation and Linkage......................................................................449Program Execution................................................................................................449

Using Simplified Inter-application Communication...............................................449Outline....................................................................................................................449

Operating Procedures ...........................................................................................450Server Operation Windows ..................................................................................454Client Operation Window ....................................................................................473Estimating Memory................................................................................. ..............478

Simplified Inter-application Communication Functions ........................................480COBCI_OPEN........................................................................................................482COBCI_CLOSE......................................................................................................484COBCI_READ........................................................................................................485

COBCI_WRITE ......................................................................................................488Error Codes................................................................................................................493

Chapter 15. Database (SQL) .......................................................................................501

ODBC Outline............................................................................................................502Configuration of a COBOL Program with SQL ..................................................503Operations Using Embedded SQL.................................... ...................................504

Connection .................................................................................................................505

Connecting to a Server................................... .......................................................505Disconnecting from a Server ................................................................................507Selecting a Connection ..........................................................................................507

Manipulating Data.....................................................................................................511Sample Database....................................................................................................512Retrieving Data......................................................................................................514Updating Data .......................................................................................................522Deleting Data.........................................................................................................523

Inserting Data ........................................................................................................523Using Dynamic SQL........................................................... ...................................524

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 21/783

COBOL85 User’s Guide xxi

Using Variable Length Character Strings......................... ...................................530Operating the Cursor with More than One Connection.....................................533

Compiling the Program.............................................................................................535Executing the Program................................................................................ ..............536

Constructing the Program Execution Environment ...........................................536Defining Default Connection Information...........................................................541Using the ODBC Information Setup Tool............................................................542

Maximum Length of Information Specified in the ODBC Information File.....543Preparing Linkage Software and the Hardware Environment..........................543

Embedded SQL Keyword List..................................................................................545Correspondence Between ODBC-Handled Data and COBOL85-Handled Data .548SQLSTATE, SQLCODE, and SQLMSG ...................................................................550Notes on Using the ODBC Driver............................................................................552

Notes on SQL Statement Syntax...........................................................................552Notes on Executing Embedded SQL Statements............. ...................................553

Quantitative Limits of Embedded SQL Statement at Execution .......................554

Chapter 16. Distributed Development Support Functions ....................................555

Outline of Distributed Development .......................................................................556Scope of Distributed Development Functions.........................................................557Distributed Development Support Functions.. .......................................................559

Target Language Construct ..................................................................................559Usage......................................................................................................................560

Presentation File Module Test Function ..................................................................568Operating Environment........................................................................................568Creating Files Required for Using the Presentation File Module Test Function569Using the Presentation File Module Test Function.............................................573COBPRTST Dialog Box.........................................................................................577

Appendix A. Compiler Options..................................................................................581

List of Compiler Options ..........................................................................................581

Compiler Option Specification Formats ..................................................................584

Appendix B. I-O Status List .......................................................................................611

Appendix C. Global Optimization..................... .......................................................619

Optimization ..............................................................................................................619Removing a Common Expression........................................................................620Shifting an Invariant................................................................................ ..............621

Optimizing an Induction Variable .......................................................................622Optimizing a PERFORM Statement.................................. ...................................622

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 22/783

xxii COBOL85 User’s Guide

Integrating Adjacent Moves .................................................................................623Eliminating Unnecessary Substitutions ...............................................................623

Notes...........................................................................................................................624

Appendix D. Intrinsic Function List .........................................................................627

Appendix E. Special Registers Used with Screen and Form Functions ...............631

EDIT-MODE ..........................................................................................................631EDIT-STATUS........................................................................................................632EDIT-COLOR.........................................................................................................633EDIT-OPTION .......................................................................................................633EDIT-CURSOR ......................................................................................................634

Appendix F. Message Lists...................................................... ...................................635

Messages Output by WINCOB and Compile Commands................... ..............635Messages Produced by the COBOL85 Compiler ................................................637Messages Produced by the COBOL85 Run-time System ...................................639System Error Codes...............................................................................................682

Appendix G. Writing Special Literals.......................................................................685

Program Name Literal ..........................................................................................685Text Name Literal..................................................................................................685File-Identifier Literal .............................................................................................686

Appendix H. High-Speed File Processing................................................................689

Specification Methods...........................................................................................689Notes.......................................................................................................................690

Appendix I. GS-series Function Comparison ..........................................................691

Checking Program Operation...............................................................................701Notes.......................................................................................................................703

Appendix J. Command Formats.................................................................................705

Compiler Commands.............................................................................. ..............705Linker Commands................................................................................... ..............712

Appendix K. FCB Control Statement ........................................................................723

Appendix L. Indexed File Recovery ..........................................................................725

Indexed File Recovery Function............................................................. ..............725

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 23/783

COBOL85 User’s Guide xxiii

Indexed File Simple Recovery Function ..............................................................728Notes.......................................................................................................................730Examples of Calling from COBOL......................................................... ..............730Codes and Messages .............................................................................................733

Appendix M. Using Other File Systems...................................................................735

Btrieve File .............................................................................................................735

RDM File ................................................................................................................743

Appendix N. A COBOL-Supported Subroutine......................................................747

Subroutine for Receiving the Window Handle................ ...................................747Notes.......................................................................................................................748Subroutine for Receiving the Instance Handle....................................................750

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 24/783

xxiv COBOL85 User’s Guide

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 25/783

Chapter 1. Overview of COBOL85

This chapter explains the functions of COBOL85 and itsoperating environment. If you are unfamiliar with COBOL85,you should read this chapter before using the product.

This chapter also details how to establish a developmentenvironment, set environment variables, and outlines theprocedure for developing a program.

2 Chapter 1. Overview of COBOL85

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 26/783

COBOL85 Functions

This section explains the COBOL functions and the various

utilities provided by COBOL85.

COBOL Functions

COBOL85 has the following COBOL functions:

• Nucleus

• Sequential file

• Relative file

• Indexed file

• Inter-program communication

• Sort-merge

• Source text manipulation

• Presentation file

• Database (SQL)

• System program description (SD)

• Screen handling

• Command line argument handling

• Environment variable operation

• Report writer

• Built-in function

• Floating-point number

Chapter 1. Overview of COBOL85 3

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 27/783

For information about how to write COBOL statements to usethese functions, refer to the “COBOL85 Reference Manual.”

Programs and Utilities Provided by COBOL85

COBOL85 provides the following programs and utilities fordeveloping programs under Windows 95, Windows NT orWindows 3.1.

Table 1. COBOL85 programs and utilities

Name PurposeCOBOL85 compiler Compiles a described program using

COBOL85.

COBOL85 run-time system Executes a COBOL85 application.COBOL85 interactive debugger Allows you to debug a COBOL85

application.PROGRAMMING-STAFF (P-STAFF)

The COBOL85 developmentenvironment.

COBOL85 FILE UTILITY Processes a COBOL85 file.COBOL presentation file moduletest (16)

Activates a COBOL presentation filemodule test function.

WINCOB command Activates the COBOL85 compiler.WINLINK command Activates the linker.WINEXEC command Activates a COBOL85 application.WINMSG command (16) Activates the error search function.Simplified inter-applicationcommunication

Exchanges data between applications.

An overview of the programs and utilities follows.

4 Chapter 1. Overview of COBOL85

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 28/783

COBOL85 Compiler 

The COBOL85 compiler compiles a COBOL source program tocreate an object program. The compiler provides the followingservice functions:

• Output compiler listings

• Checks standards and specifications

• Global optimization

• The tag-jump between a compile message and the editor(error search function)

• Provides linkage with FORM (screen and form descriptors)and Power FORM (form descriptors)

Specify these functions in accordance with the compiler options.

COBOL85 Run-time System

When you execute an application program created withCOBOL85, the COBOL run-time system is called and operated.

COBOL85 Interactive Debugger 

You debug COBOL85 applications created under Windows 95,

Windows NT or Windows 3.1 with the COBOL85 interactivedebugger. The debugger is started by a simple operation from awindow, and can:

• Interrupt and restart program execution

• Reference and change the contents of a data area

• Interrupt when changing the value of a data area

• Display the execution route of a program (16)

Chapter 1. Overview of COBOL85 5

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 29/783

• Display the call route of a program

• Rerun the debugging operation

PROGRAMMING-STAFF (P-STAFF)

PROGRAMMING-STAFF (P-STAFF) provides a simple means ofediting, compiling, linking, executing, debugging, or maintainingprograms without switching windows.

6 Chapter 1. Overview of COBOL85

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 30/783

COBOL85 FILE UTILITY

The COBOL85 FILE UTILITY responds to utility commandswithout referencing the COBOL application.

COBOL Presentation File Module Test Function

Use the presentation file module to conduct a unit test on anapplication to execute interactive processing when developmentof an application is being used with the mainframe systemdesignated as the host (GS-series). Note: This applies only tousers of the GS-series.

WINCOB, WINLINK, and WINEXEC Commands

The WINCOB, WINLINK and WINEXEC commands activate theCOBOL85 compiler, linker, and COBOL85 application. Use thesecommands to enable the COBOL85 compiler, linker, and

application to be activated from a window.

WINMSG Command (16)

The WINMSG command opens a message file to be used withthe COBOL85 error search function. Only the Windows 3.1version supports this command.

Simplified Inter-Application Communication

Simplified inter-application communication provides a means forservers to exchange messages between user programs.

Chapter 1. Overview of COBOL85 7

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 31/783

COBOL85 Development Environment

The following figure provides an overview of the COBOL85

development environment.

Figure 1. The COBOL85 development environment

Applications created using the Windows 3.1 version of COBOL85are executed as 16-bit applications. Applications created usingthe Windows 95 and Windows NT version of COBOL85 are

executed as 32-bit applications.

8 Chapter 1. Overview of COBOL85

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 32/783

Setting Up Environment Variables

Set the following environment variables according to theCOBOL85 functions you want to use.

When using Windows 95, register in AUTOEXEC.BAT by usingthe text editor.

When using Windows NT, set the variables at the system controlpanel or command prompt. Refer to “Setting from the ControlPanel” and “Setting from the Command Prompt” in Chapter 5.

When using Windows 3.1, set the variables before activating

Windows.Table 2. Setting environment variable

Setup Timing EnvironmentVariable

Details Conditions

Common PATH COBOL85 installdirectory

FORM RTS installdirectory

When usingCOBOL85

When usingscreen and formdescriptors

Required

Required

TMP Workingdirectory name

When using P-STAFF

Required

TEMP Workingdirectory name

When using P-STAFF

Required

At compilation(32)

SMED_SUFFIX Extension ofscreen and form

descriptors (anycharacter string)

When changingthe extension

PMD of screenand formdescriptors

Optional

FORMLIB Directory nameof the file storingscreen and formdescriptors

When usingscreen and formdescriptors

Optional

Chapter 1. Overview of COBOL85 9

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 33/783

Table 2. Setting environment variables (cont.)

Setup Timing EnvironmentVariable

Details Conditions

At compilation(32)

FFD_SUFFIX Extension of filedescriptor (anycharacter string)

When changingthe extension FFDof the file

descriptor

Optional

FILELIB Directory nameof file storing thefile descriptor

When using thefile descriptor

Optional

At linking LIB COBOL85 installdirectory.Directory nameof the file to becombined when

linking

When linking Required

TMP Workingdirectory name tobe used at linking

When linking Required

At execution BSORT_TMPDIR Workingdirectory name

When using thesort/mergefunction

Optional

When using theCOBOL85 FILEUTILITY

Optional

MEFTDIR Directory nameof windowinformation fileand printerinformation file

When usingscreen and formdescriptors

Optional

TEMP Workingdirectory name

When using thesort/merge

function

Required

When using theCOBOL85 FILEUTILITY

Required

10 Chapter 1. Overview of COBOL85

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 34/783

When Using Screen and Form Descriptors (32)

SMED_SUFFIX=NONE

Specifying 'None' indicates there is no extension.

FORMLIB=E:\FORM

Specifies the storage location for screen and form descriptors.

When Using the File Descriptor (32)

FFD_SUFFIX = NONE

Specifying 'None' indicates there is no extension.

FILELIB = E:\FILE

Specifies the storage location for the file descriptor.

Related Products

COBOL85 supports the following products.

Table 3. Related products

Name of Product FunctionFORM Design screen and form layoutsPower FORM Design form layoutsFORM overlay option Design overlay pattern descriptorsFORM RTS Process input/output of screens and forms

An overview of each product is given below.

FORM and Power FORM

FORM designs screens and forms to be displayed and printed bythe COBOL program. Use FORM interactively to design thelayout of screens and forms.

Chapter 1. Overview of COBOL85 11

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 35/783

Power FORM designs the forms to be printed by the COBOLprogram. Use Power FORM interactively to design the layout offorms.

FORM Overlay Option

The FORM overlay option is a FORM product for designing theoverlay pattern to be printed by a COBOL program. You caninteractively design the layout of the overlay pattern.

FORM RTS

FORM RTS (sometimes referred to as MeFt) is used implicitlywhen a program that reads and writes screens and forms isexecuted. FORM RTS edits the format after receiving a screen orform I-O request from the program.

12 Chapter 1. Overview of COBOL85

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 36/783

Developing a Program

The standard procedure for developing a program using P-STAFF is explained in the following figure.

Figure 2. Developing a program with P-STAFF

1) Describe the COBOL source program.

2) Activate P-STAFF.

3) Edit the program after P-STAFF has been activated. ((16):PowerFRAMEVIEW editor/(32): P-STAFF editor)

4) Execute WINCOB to compile the program. Refer to Chapter3, “Compiling Programs.”

5) Use the error search function to correct a COBOL statementwhere a compile error has occurred. Refer to “Correcting a

Compile Error” in Chapter 3.

Chapter 1. Overview of COBOL85 13

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 37/783

6) Execute WINLINK to link a program. Refer to Chapter 4,“Linking Programs.”

7) Execute WINEXEC to execute a program. Refer to Chapter 5,“Executing Programs.”

8) When the program does not execute as expected, or when the

unit test is being executed on a program (16) , debug aprogram with the interactive debugger. Refer to the “FujitsuCOBOL Debugging Guide” for more details.

9) When an application consists of several programs, use theproject management function for developing and maintainingthe application. Refer to Chapter 6, “Project ManagementFunction.”

10) When a program contained within a project-managedapplication has been corrected, re-create the application. Inthis case, execute the rebuild command. Refer to Chapter 6,“Project Management Function.”

11) To process a COBOL file, execute the COBOL85 FILEUTILITY. Refer to “COBOL85 FILE UTILITY” in Chapter 7.

COMPILE and LINK can be done without relying on P-STAFF.Refer to “Using Commands to Compile,” in Chapter 3, “UsingCommands to Link,” in Chapter 4, and Appendix J, “CommandFormats.”

14 Chapter 1. Overview of COBOL85

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 38/783

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 39/783

Chapter 2. Creating and Editinga Program

This chapter explains how to create and edit a program, how tocreate library text and the program format, and describescompiler directing statements.

16 Chapter 2. Creating and Editing a Program

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 40/783

Creating the Program

You create COBOL source programs and library text witheditors. This section explains how to create the COBOL sourceprogram and library text.

Creating and Editing a COBOL Source Program

Simply, you create a COBOL source program by:

•Activating the editor

• Creating and entering text

• Storing the program

Activating the Editor 

To display the edit screen, activate the editor.

Creating and Editing the Program

You format COBOL source programs using the COBOL referenceformat. Enter the line number, COBOL statement and procedure-name in the positions stipulated in the reference format.

Chapter 2. Creating and Editing a Program 17

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 41/783

Enter the line number, COBOL statement, and procedureidentifier in the edit screen, as shown in the following example.

  (1) (2)(3) (4)

Column position 12345678901234567890000001 IDENTIFICATION DIVISION. (5)000002 PROGRAM-ID. PROG1.

::000012 01 A PIC X(5) VALUE "AB D". (6)

::

000021 DISPLAY A.

(1) Sequence number area (columns 1 to 6)Specify the line number in the sequence number area. Theline number can be omitted.

(2) Indicator area (column 7)Use the indicator area when continuing a line or to change aline to a comment line. In all other cases, be sure to enter aspace.

(3) Area A (columns 8 to 11)Normally, COBOL divisions, sections, paragraphs and endprogram headers are described in this area. Data items whoselevel-number is 77 or 01 are also described in this area.

(4) Area B (column 12 and on)Normally, COBOL statements, comment-entries and dataitems whose level-number is not 77 or 01 are described in thisarea.

(5) Line feed character (end of line)Enter a line feed character at the end of each line.

(6) TAB characterA TAB character can be specified as the nonnumeric literal ina COBOL source program. The TAB character takes up 1 bytewithin the non-numeric literal.

18 Chapter 2. Creating and Editing a Program

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 42/783

Storing the Program and Quitting the Editor 

After creating and editing the source program, store the programin a file, then quit (exit) the editor. Normally, you affix theextension COB or CBL to the name of the file.

When using Windows 95 or Windows NT, you can also use theextension COBOL. Affixing the extension COB, CBL or COBOLfacilitates specification of the file name when compiling theprogram.

Creating Library Text

You create library text, fetched by the COBOL source programwith COPY statements, in the same manner as you createCOBOL source programs. However, the reference format (fixed,variable or free) for the library text does not have to be the sameas the format of the COBOL source program that fetches thelibrary text.

As with the COBOL source program, you specify compileroptions to set up the reference format for the library text.However, when a single program fetches several library texts,the reference formats for all the library texts must be identical.

Normally, append the extension CBL or COB to the name of thefile in which the library text is to be stored. When using

Windows 95 or Windows NT, the extension COBOL can be used.

Screen and form descriptors can use any method of referenceformat.

Chapter 2. Creating and Editing a Program 19

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 43/783

Program Format

Each line in the COBOL source program is delimited with a linefeed character, in accordance with the rules governing thereference format.

There are three types of reference formats: fixed, variable andfree. You specify the type with a compiler option beforecompiling the program.

The line feed character that delimits each line is not regarded aspart of the line.

Fixed Format

In a fixed format, each line in the COBOL source program has afixed length of 80 bytes.

 (Column position)

 1 6 7 8 12 72 73 80Sequence number area * Area A Area B *** Indicator area** Program identification number area

Variable Format

In a variable format, each line in the COBOL source program canbe up to 251 bytes long.

 (Column position) 1 6 7 8 12 < 251Sequence number area * Area A Area B* Indicator area

20 Chapter 2. Creating and Editing a Program

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 44/783

Free Format

In a free format, you do not need to distinguish between thesequence number area, the indicator area, Area A, Area B, or theprogram identification number area. Each line can be up to 251bytes long.

 (Column position) 1 < 251

Compiler Directing Statement

A compiler directing statement indicates the compiler options.Normally, compiler options are specified in the CompilerOptions dialog box of the WINCOB window that runscompilation, but the options can also be defined within thesource program.

The description format for the compiler directing statement is

shown below.@OPTIONS [compiler-option [,compiler-option]...]

• Enter "@OPTIONS" starting at column 8.

• Enter at least one space between "@OPTIONS" and thecompiler options.

• Each compiler option must be delimited by a comma.

• A compiler directing statement indicates the starting positionof each separately compiled program. The compiler optionsspecified in the compiler directing statement apply only tothe corresponding separately compiled programs in thecompiler directing statement.

Chapter 2. Creating and Editing a Program 21

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 45/783

For example:

000100 @OPTIONS MAIN, APOST000200 IDENTIFICATION DIVISION.  :  :

Do not use a tab as a separator in an @OPTIONS compiler

directing statement.The compiler option values that can be specified in the compilerdirecting statement are restricted. For details, refer to AppendixA, “Compiler Options.”

22 Chapter 2. Creating and Editing a Program

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 46/783

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 47/783

Chapter 3. Compiling Programs

This chapter explains how to compile programs, using thesample programs provided as examples. It describes theresources required for compilation, and gives a samplecompilation procedure. This chapter also explains how to correctcompile errors and use commands to run the compiler.

24 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 48/783

Compiling Sample Programs

This section explains the steps required to compile the sampleprograms located in the SAMPLES directory (in the directory

where the COBOL85 compiler is installed). Each sample file isstored separately.

Windows 95 and Windows NT

In the following explanation, it is assumed the sample program

is stored in:C:\FSC\PCOBOL32\SAMPLES\SAMPLE1\SAMPLE1.COB

Start PROGRAMMING-STAFF by clicking on Start, Programs,Fujitsu COBOL and Programming-Staff 32.The PROGRAMMING-STAFF (P-STAFF) window opens.

Select WINCOB [Compile] from the Tools menu in the P-STAFFwindow. The WINCOB window opens.

Click on the Browse button, and navigate to the directory wherethe sample program is stored. Alternatively, you can specify thefile name in the edit box by entering it directly.

 

Figure 3. The WINCOB window

Chapter 3. Compiling Programs 25

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 49/783

Click on the Options button of the WINCOB window. TheCompiler Options dialog box is displayed.

Figure 4. The Compiler Options dialog box

Click on the Add button. The (Add) Compiler Options dialogbox, containing a list of available options, is displayed.

Figure 5. The (Add) Compiler Options dialog box

26 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 50/783

Select MAIN in the Compiler Options list box and click on theAdd button. The (Details) Compiler Option dialog box isdisplayed. Note: The main program must be defined in order todistinguish it from the subprograms.

Figure 6. The (Details) Compiler Option dialog box

Select Compile program as main program and click on the OK

button. The (Details) Compiler Options dialog box is redisplayed.Since there are no more options to be added, click on the Cancelbutton. The (Add) Compiler Options dialog box closes. TheCompiler Options dialog box is redisplayed.

Figure 7. The Compiler Options dialog box with MAIN specified

Verify that MAIN appears in the Compiler Options list box of theCompiler Options dialog box, then click on the OK button. The

Chapter 3. Compiling Programs 27

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 51/783

Compiler Options dialog box closes and the WINCOB window isdisplayed.

Click on the Compile button in the WINCOB window.Compilation starts, and a window showing compilation progressis displayed.

Figure 8. The compilation progress dialog box

28 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 52/783

Compilation ends. Compiler messages are displayed in the P-STAFF window.

Figure 9. The PROGRAMMING-STAFF window

Verify that compilation completed normally and then click on theCancel button in the WINCOB window. The WINCOB windowcloses. Click on Exit in the File menu to close the P-STAFFwindow.

Compilation of the sample program is now complete. Verify thatthe object program (SAMPLE1.OBJ) was created in the same

directory (C:\FSC\PCOBOL32\SAMPLES\SAMPLE1 in thisexample) as the directory where the sample program was stored.

If compilation does not complete normally, the program may nothave been installed properly. Verify that the program wasinstalled properly.

Chapter 3. Compiling Programs 29

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 53/783

Windows 3.1

In the following explanation, it is assumed the sample programis stored in:

C:\FSC\PCOBOL16\SAMPLES\SAMPLE1\SAMPLE1.COB

Double-click on the PROGRAMMING-STAFF icon. ThePROGRAMMING-STAFF (P-STAFF) window opens.

Select WINCOB from the Utility menu in the P-STAFF window.The WINCOB window opens.

Click on the Browse button, and navigate to the directory where

the sample program is stored. Alternatively, you can specify thefile name in the edit box by entering it directly.

Figure 10. The WINCOB window

Select Options in the WINCOB window. The Compiler Optionsdialog box is displayed.

30 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 54/783

Figure 11. The Compiler Options dialog box

Click on the Add button. The (Add) Compiler Options dialogbox, containing a list of available options, is displayed.

Figure 12. The (Add) Compiler Options Dialog Box

Select MAIN in the Compiler Options list box and click on theAdd button. The (Details) Compiler Option dialog box isdisplayed.

Chapter 3. Compiling Programs 31

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 55/783

Figure 13. The (Details) Compiler Option dialog box

Select Compile program as main program and click on the OKbutton. The (Details) Compiler Options dialog box is redisplayed.

Since there are no options to be added, click on the Exit button.

The (Details) Compiler Options dialog box closes. The CompilerOptions dialog box is redisplayed.

Figure 14. The Compiler Options dialog box with MAIN specified

Verify that MAIN appears in the Compiler Options list box of theCompiler Options dialog box, then click on the OK button. TheCompiler Options dialog box closes and the WINCOB window isdisplayed.

32 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 56/783

Click on the Compile button in the WINCOB window.Compilation starts, and a window showing compilation progressis displayed.

Figure 15. The compilation progress window

Compilation ends. Compiler messages are displayed in thePowerFRAMEVIEW Editor.

Chapter 3. Compiling Programs 33

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 57/783

Figure 16. The PowerFRAMEVIEW Editor 

Verify that compilation completed normally and then select Exitin the WINCOB window. The WINCOB window closes.

Compilation of the sample program is now complete. Verify that

the object program (SAMPLE1.OBJ) was created in the samedirectory (C:\FSC\PCOBOL16\SAMPLES\SAMPLE1 in thisexample) as the directory where the sample program was stored.

If compilation does not complete normally, the program may nothave been installed properly. Verify that the program wasinstalled properly.

34 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 58/783

Resources Necessary for Compilation

This section explains the files used by the COBOL85 compilerand the information that it produces.

Files Used by the COBOL85 Compiler 

The COBOL85 compiler uses the following files:

Figure 17. Files used by the COBOL85 compiler 

*1 A compile message is written in the editor when compilation terminates.

Chapter 3. Compiling Programs 35

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 59/783

The following table lists the files used by the COBOL85 compiler.

Table 4. Files used by the COBOL85 compiler 

File Contents File Name Format I/O Condition Option1 Source

programsAny (Normally, usethe extension COB,CBL or COBOL)

 I Required

2 Library text library-text-name.CBL(*1)

 I Follow thespecificationmethod whencompiling a sourceprogram that uses

the COPY statement⇒ (*3)

 LIB

3 Screen andformdescriptors

screen-and-form -descriptor.PMD (*2)

 I Follow thespecificationmethod whencompiling a sourceprogram that usesscreen and formdescriptors ⇒ (*4)

FORMLIBFORMEXT

4 File descriptor file-descriptor.FFD(*2)

 I Follow thespecificationmethod whencompiling a sourceprogram that uses afile descriptor ⇒(*4)

FILELIBFILEEXT

36 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 60/783

Table 4. Files used by the COBOL85 compiler (cont.)

File Contents File Name Format I/O Condition Option5 Character-

stringsindicatingcompileroptions

DEFAULT.CBI orAny name (Refer toAppendix J)

 I When specifyingcompiler options stored in a fileusing the WINCOBwindow or

COBOL32 command O When compiler

options are set up inthe CompilerOptions dialog boxfor the WINCOBwindow

6 Informationused by theCOBOL85compiler

COBOL85.CBI I/O Created in thedirectory whichCOBOL85 wasinstalled

7 Objectprogram

source-file-name.OBJ

 O When the sourceprogramcompilationcompletes normally

 OBJECT

8 Debugginginformation

source-file-name.SVD

 O When the compileroption TEST is

specified

 TEST

9 Compilerlistings

source-file-name.LST

 O When compilerlistings is output

 PRINT

10 Compilemessage

Is displayed

Notes:

(*1) The extension COB or COBOL may be used instead of CBL.

The system searches the extension for the file to be compiled inthe following order:

• CBL

• COB

• COBOL (32)

Chapter 3. Compiling Programs 37

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 61/783

(*2) Each extension can be changed to any character string byusing the compiler option (FORMEXT/FILEEXT) or environmentvariable (SMED_SUFFIX/FFD_SUFFIX).

Refer to “Setting Up Environment Variables” in Chapter 1 andAppendix A, “Compiler Options.”

 (*3) When COPY statements have been entered without IN/OFin the COBOL source program either:

• Specify the directory of the library text file in compiler optionLIB.

• Store the library text file in the current directory. (32)When compiling from the WINCOB window, the current

directory is the directory where the COBOL source programis stored.

• Store the library text files in the same directory as the sourcefile. (16)

When COPY statements have been entered with IN/OF in theCOBOL source program:

• Associate the storage directory of the library text file with thelibrary specified by IN/OF. Failure to create an associationwith the library causes a compile error to occur duringcompilation.

(*4) Specify the directory of the file (screen and formdescriptors/file descriptor) in the compiler option(FORMLIB/FILELIB).

• Specify the directory of the file (screen and formdescriptors/file descriptor) in the environment variable(FORMLIB/FILELIB). (32)

• Store the file (screen and form descriptors/file descriptor) inthe current directory. (32)When compiling from the WINCOB window, the current

38 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 62/783

directory is the directory where the COBOL source programis stored.

• Store the file (screen and form descriptors/file descriptor) inthe same directory as the source file. (16)

Information Provided by the COBOL85 Compiler 

The COBOL85 compiler reports program compilation results as adiagnostic message. The diagnostic message appears in thewindow when compilation terminates.

To store the message in a file, either save the displayed messageas a file or specify the compiler option PRINT before compiling.

Specifying the compiler option MESSAGE writes option andstatistical information listings for separately compiled programs.These lists indicate the compiler options and provide informationon compiled programs. These lists are also called compilerlistings.

The formats of the compiler listings written when compiler

option PRINT and MESSAGE specified are shown below.

Option Information Listing

The numbers in parentheses () correspond to the notes thatfollow these examples.

COBOL85 V30L10 TUE JAN 30 19:00:45 1996 0001  (1) (2) ** OPTIONS SPECIFIED **MAINMESSAGETERM (3)** OPTIONS ESTABLISHED **ALPHAL LINECOUNT(60) SDS (4)BINARY(WORD, MLBON) LINESIZE(136) NOSOURCE: : :: : :

Chapter 3. Compiling Programs 39

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 63/783

Diagnostic Message Listing

COBOL85 V30L10 program-name TUE JAN 30 19:00:45 1996 0002 (5)  ** DIAGNOSTIC MESSAGE ** (program-name)  C:\TEST.COB 4: JMN2503I-S USER WORD 'A' IS UNDEFINED. (6)

Compile Unit Statistical Information Listing

COBOL85 V30L10 program-name TUE JAN 30 19:00:45 1996 0003  ** STATISTICS **  FILE NAME = C:\TEST. COB  DATE AND TIME = TUE JAN 30 1996 19:00:45  SOURCE STATEMENTS = 5 RECORDS (7)  PROGRAM SIZE (CODE) = 0 BYTES (8)  CONTROL LEVEL = 1 LEVEL (9)  CPU TIME = 4.72 sec. (10)  HIGHEST SEVERITY CODE = S (11)

Notes:

(1) Indicates the compilation date.

(2) Indicates the page number.

(3) Indicates the compiler options specified by the user.

(4) Indicates a list of compiler options established by theCOBOL85 compiler.

(5) Indicates the program name.

(6) Indicates the diagnostic message output by the COBOL85compiler. For details on the format of the diagnostic message,refer to Appendix F, “Message Lists.”

(7) Indicates the number of records in the source program inputby the COBOL85 compiler. When a library has been fetched,the number of fetched records is included.

(8) Indicates the size of the object program. When thecompilation operation was completed normally and theobject program has been output, the DATA size is also

output.

40 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 64/783

(9) Indicates the level of the compiler used.

(10) Indicates the time required for compilation.

(11) Indicates the highest severity code among output diagnosticmessage codes.

Compiling a COBOL Source Program

There are two methods to compile a COBOL source program.One method involves running WINCOB commands from awindow, and the other method involves running the compilerfrom the command line. This section explains the procedure for

compiling the program using the WINCOB window.

For details on how to compile the program using the commands,see “Using Commands to Compile.”

A source program containing several compilation units withinone file cannot be compiled.

Compiling a Single Source File

To compile files:

1. Activate the WINCOB window. See “Activating the WINCOBWindow.”

2. Specify the name of the source file to be compiled in the FileName edit box. See “Specifying a File Name” (for singlecompilation).

3. Establish the compiler options. See “Setting Up CompilerOptions.” Specify the name of the source file beforeestablishing the compiler options.

4. Establish the library name. See “Setting a Library Name.”

Chapter 3. Compiling Programs 41

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 65/783

5. Start compilation. See “Starting and Quitting Compilation.”

6. Correct any compile errors. When compilation terminates, acompile message appears in the window of P-STAFF editor.When a compile error is detected, correct the program byusing the error search function, then restart compilation. See“Correcting a Compile Error.”

7. Quit compilation. See “Starting and Quitting Compilation.”

• To continue compilation, close the message and repeat theoperation from Step 2.

• To quit compilation, click on the Cancel button (32) or selectExit (16) in the WINCOB window.

When a compile ends normally, an object program is created.The object program has to be linked before it can be executed.Linking is explained in Chapter 4, “Linking Programs.”

Compiling Several Source Files

To compile several files consecutively with WINCOB:

1. Activate the WINCOB window. See “Activating the WINCOBWindow.”

2. Specify continuous compilation. See “Specifying ContinuousCompilation.”

3. Specify the names of the source files to be compiled in the

WINCOB (Continuous Compilation mode) List box. See“Specifying a File Name” (for continuous compilation).

4. Establish the compiler options. See “Setting Up CompilerOptions.” Select and establish compiler options and a libraryname separately for each directory of files selected from thelist box.

42 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 66/783

5. Establishing a library name. See “Setting a Library Name.”Select and establish compiler options and a library nameseparately for each directory of files selected from the list box.When running continuous compilation, the same compileroptions must be specified for source files in the samedirectory. To specify different compiler options, enter acompiler directing statement within the COBOL sourceprogram. Refer to “Compiler Directing Statement” in Chapter2.

6. Specify the main program. See “Specifying the MainProgram.” The options set up at this step have priority overoptions specified at the dialog box even if MAIN wasspecified.

7. Start compilation. When compilation of one file ends, startcompilation of the next file. See “Starting and QuittingCompilation.”

8. Correct any compile errors. When compilation ends, acompile message appears in the window. When a compileerror is detected, a compile message for all files appears in

the window after continuous compilation ends. Correct theprogram by using the error search function, then restartcompilation. See “Correcting a Compile Error.”

9. Quit compilation. See ‘Starting and Quitting Compilation.”

• To continue compilation, close the message and repeatcompilation from Step 3.

• To quit compilation, click on the Cancel button (32) or selectExit (16) in the WINCOB window.

If no errors are found in the COBOL source program andcompilation ends normally, an object program is created.

The object program cannot be run as it is. The object programmust be linked to make it executable.When compilation ends,

Chapter 3. Compiling Programs 43

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 67/783

link the program. For details on linking, refer to Chapter 4,“Linking Programs.”

WINCOB Window

The WINCOB window runs compilation. This section explainsthe WINCOB window. For further details about using thewindow, refer to the online help.

Activating the WINCOB Window (32)

The WINCOB window can be started by either:• Selecting WINCOB from the Tools menu of the P-STAFF

window

or

• Executing “WINCOB.EXE”.

The WINCOB (Standard Compilation mode) window isdisplayed.

Figure 18. The WINCOB window in Standard Compilation mode

The WINCOB window contains the following elements:

Mode

44 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 68/783

Specify whether a single program (standard) or multipleprograms (continuous) are to be compiled.

Help

Access the online help.

Source file edit box

Specify the COBOL source file to be compiled.

Browse button

Click to browse directories to select a COBOL source file.

OK button

Click to start compilation.

Cancel button

Click to close the WINCOB window.

Options button

Click to specify compile options.

Compile button

Click to start compilation.

Specify the COBOL source program to be compiled by eitherentering it in the source file edit box, or by using the Browsebutton to select a file.

Specifying Continuous Compilation

To compile more than one program, select Continuouscompilation from the Mode menu in the WINCOB window. TheWINCOB window expands to include the continuouscompilation options. Specify the file names to compile in theWINCOB (Continuous Compilation mode) window.

Chapter 3. Compiling Programs 45

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 69/783

Figure 19. The WINCOB window in Continuous Compilation mode

The WINCOB (Continuous Compilation mode) window containsthe following elements:

Mode

Specify whether a single program (standard) or multipleprograms (continuous) are to be compiled.

Help

Access the online help.

Source file edit box

Specify the COBOL source file to be added to the List.

List (list box)

List of COBOL source files to be compiled.Browse button

Click to browse directories to select a COBOL source file.

Add button

Click to add the Source File to the List.

46 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 70/783

Delete button

Click to remove the selected file(s) from the List.

Main button

Click to indicate that the selected file is a main program.

Sub button

Click to indicate that the selected file is a sub program.

OK button

Click to start compilation.

Cancel button

Click to close the WINCOB window.Options button

Click to specify compile options.

Compile button

Click to start compilation.

Specifying a File Name

The method of specifying a file name differs for singlecompilation and continuous compilation. Both methods areexplained below.

To specify the file name to be used for standard (single)compilation:

Specify the name of the file to be compiled in the Source Fileedit box either by entering it directly from the keyboard orselecting it using the Browse button.

Chapter 3. Compiling Programs 47

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 71/783

• To specify the file names to be used for continuous (multiple)compilation:

− As with single compilation, specify the name of each file tobe compiled in the Source File edit box.

− Click on the Add button.

Setting Compiler Options

You specify compiler options by selecting the Options buttonand setting the options in the displayed Compiler Options dialogbox. See “Compiler Options Dialog Box.”

Specify the source file name before setting up the compileroptions.

Specifying the Main Program

To specify a main program, the compiler option MAIN must bespecified.

There are levels of priority for the compiler option MAIN,depending on whether the option was selected for single orcontinuous compilation.

The priority for compiler option MAIN is as follows:

1. Specified by a compiler directing statement

2. Specified by clicking on the Main button

3. Specified in the Compiler Options dialog box

To specify the main program for single compilation, specify thecompiler option MAIN from the (Add) Compiler Options dialogbox.

48 Chapter 3. Compiling Programs

To specif the main program for continuous compilation select

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 72/783

To specify the main program for continuous compilation, selectthe Main button in the WINCOB (Continuous Compilationmode) window:

1. Select the file name to be compiled as the main program fromthe Compilation list box. Multiple files can be selected.

2. Click on the Main button. The small icon next to the selected

file turns red.

The setting of Main or Subprogram in the WINCOB (ContinuousCompilation mode) window takes priority over the setting in theOptions dialog box.

When selecting files from the compilation list, failure to click onthe Main button causes the selected file name to be regarded as a

subprogram. Be sure to set up the file as the main program byclicking on the Main button.

Chapter 3. Compiling Programs 49

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 73/783

Starting and Quitting Compilation

To start compilation, click on the Compile button. Compilationstarts, and a window showing compilation progress is displayed.

Figure 20. The compilation progress window

Note: The countdown begins at number 9.

Click on the Quit button to interrupt the compile.

When compilation ends, a compile message appears in thewindow of P-STAFF editor. If a compile error is detected, correctthe program by using the error search function. See “Correcting aCompile Error.”

To quit compilation, click on the Cancel button to close theWINCOB window.

50 Chapter 3. Compiling Programs

Compiler Options Dialog Box

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 74/783

Compiler Options Dialog Box

This section explains how to set the compiler options and librarynames. You must define the source file name to be compiled inthe WINCOB window before setting the compiler options.

To set compiler options, click on the Options button in theWINCOB window to open the Compiler Options dialog box,then set the options. When necessary, open the Library Namesdialog box from the Compiler Options dialog box and define thelibrary names.

For details on the compiler options that can be set, refer toAppendix A, “Compiler Options.” For additional details on howto use the windows, refer to the online help.

Setting Compiler Options

Set the compiler options from the Compiler Options list box orthe Other Compiler Options edit box.

When setting compiler options in the Compiler Options list box,use the Add, Change and Delete buttons. When setting compileroptions in the Other Compiler Options edit box, enter thecompiler options as character strings directly from the keyboard.

Chapter 3. Compiling Programs 51

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 75/783

Figure 21. The Compiler Options dialog box

The Compiler Options dialog box contains the followingelements:

Option File display field

Displays the file in which option settings will be saved.

Compiler Options list box

Displays compiler options selected by the Add button.Add button

Click to select from a list of compiler options.

Change button

Click to change the setting of the selected compiler option(s).

Delete button

Click to remove the select compiler option(s) from the listbox.

Other Compiler Options edit box

Allows the compile options to be keyed in directly.

52 Chapter 3. Compiling Programs

OK button

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 76/783

OK button

Click to confirm the compiler option settings or changes.

Cancel button

Click to cancel any compiler option settings or changes andreturn to the state before the dialog box was opened.

Library Names button

Click to specify the library text files.

Help button

Click to access the online help.

Previously specified compiler options, as well as those you add,

are displayed in the compiler options list field.

Adding a Compiler Option

To set a compiler option that is not shown in the CompilerOptions list box:

1. Click on the Add button. The (Add) Compiler Options dialogbox appears.

2. Select the compiler option to be added from the CompilerOptions list box and click on the Add button. The (Details)Compiler Option dialog box then appears.

3. Specify the details to be set for the compiler option. The

details in the (Details) Compiler Option dialog box differdepending on the compiler option. Refer to the online help or“Compiler Options” in Appendix A for more information.

4. Click on the OK button in the (Details) Compiler Optiondialog box. The (Details) Compiler Options dialog box closesand the (Add) Compiler Options dialog box is redisplayed.To delete a compiler option setup, click on the Cancel button.

Chapter 3. Compiling Programs 53

5. To continue adding compiler options, repeat the procedure

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 77/783

g p p p pfrom Step 2.

6. When all the compiler options to be added are set, click onthe Cancel button. The (Add) Compiler Options dialog boxcloses and the Compiler Options dialog box is displayed.

7. The compiler options which were set are listed in the

Compiler Options list box in the Compiler Options dialogbox.

Changing a Compiler Option

To change the details of a compiler option listed in the CompilerOptions list box:

1. Select the compiler option whose setup details are to bechanged from the Compiler Options list box, then click on theChange button. The (Details) Compiler Options dialog box isdisplayed.

2. Change the settings.

3. After all modifications have been made, click on the OKbutton. To cancel the change to the compiler setup, click onthe Cancel button. The Compiler Options dialog closes.

4. The changed details of the compiler option are listed in theCompiler Options list box in the Compiler Options dialogbox.

54 Chapter 3. Compiling Programs

D l ti C il O ti

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 78/783

Deleting a Compiler Option

To delete a compiler option that appears in the Compiler Optionslist box:

1. Select the compiler option to be deleted from the Compiler

Options list box2. Click on the Delete button.

Setting a Library Name

When compiling a COBOL source program containing COPY

statements that specify library names, use the Library Namesbutton to associate the library names with the directories wherethe library files are kept.

When compiling a COBOL source program containing COPYstatements that do not specify library names, specify thedirectory where the libraries are kept in the compiler option LIB.

To associate a library name with a directory, click on the LibraryNames button in the Compiler Options dialog box, then set thelibrary details in the Library Names dialog box.

Chapter 3. Compiling Programs 55

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 79/783

Figure 22. The Library Name dialog box

The Library Name dialog box contains the following elements:

Library Name list box

Displays the library text files and associated directories that

have already been specified.Add button

Click to enter a library name and associated directory.

Change button

Click to change the directory associated with the selected

library.Delete button

Click to remove the selected library from the list box.

OK button

Click to confirm the library settings or changes.

Cancel buttonClick to cancel any library settings or changes and return tothe state before the dialog box was opened.

Help button

Click to access the online help.

56 Chapter 3. Compiling Programs

Adding a Library Name

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 80/783

To specify a library name that does not appear in the LibraryName list box:

1. Click on the Add button. The Add Library Name dialog boxis displayed.

2. Specify the library name entered in the COPY statement ofthe COBOL source program and the directory name of thelibrary storage file.

Figure 23. The Add Library Name dialog box

3. Click on the OK button. To cancel the specified details, clickon the Cancel button. The Add Library Name dialog closes.Closing the dialog box without clicking on the OK buttonlooses the specified details.

4. The specified library name, and associated directory, appearsin the Library Names list box in the Library Name dialog box.

Chapter 3. Compiling Programs 57

Changing a Library Name

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 81/783

Changing a Library Name

To change the directory associated with a library displayed in theLibrary Name list box:

1. Select the library, for which the associated directory is to be

changed, from the Library Name list box, then click on theChange button. The Modify Library’s Directory dialog box isdisplayed.

Figure 24. The Modify Library’s Directory dialog box

2. Change the directory name.

3. After changing the directory name, click on the OK button.The Modify Library’s Directory dialog box closes.

4. The new directory name is displayed in the Library Name listbox in the Library Name dialog box.

Deleting a Library Name

To delete a library name displayed in the Library Name list box:

1. Select the library name to be deleted from the Library Namelist box.

2. Click on the Delete button.

58 Chapter 3. Compiling Programs

Quitting Library Name Setup

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 82/783

When setup of a library name is completed, click on the OKbutton in the Library Name dialog box. The Compiler Optionsdialog box is redisplayed.

Storing Setup Options

When setup of compiler options and library names arecompleted, click on the OK button in the Compiler Optionsdialog box to save the details in the options file.

The options file creates the file name "DEFAULT.CBI" in thesame directory as the source file specified in the WINCOB

window. If the file "DEFAULT.CBI" already exists, the file isupdated with the new details.

To cancel setup before new options have been stored, click on theCancel button, or close the dialog without clicking on the OKbutton.

When running continuous compilation, the same compiler

options must be specified for source files being stored in thesame directory. To specify different compiler options, enter acompiling directive statement within the COBOL sourceprogram. Refer to “Compiler Directing Statement” in Chapter 2.

Chapter 3. Compiling Programs 59

C ti C il E

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 83/783

Correcting a Compile Error 

If a compile error is detected after compilation is activated fromthe WINCOB window, a compile message (diagnostic message)

is displayed in the relevant window of the P-STAFF editor whencompilation terminates.

The error search function causes the display to tag-jump from thediagnostic message displayed in the message window to the linewhere the compile error was detected in the edit window of theCOBOL source program.

The edit window of the COBOL source program automaticallyopens at the first tag-jump, so you do not have to activate theeditor beforehand.

Using the error search function automates the search for faultystatements, making program correction highly efficient.

Compile Messages

When compilation terminates, a compile message appears in thewindow of the P-STAFF editor (32) or the WINMSG window(16). To save the compile message as a file, save the file from thewindow.

When compiler option MESSAGE has been specified, the compile

message consists of the option information listing, the diagnosticmessage listing, and the compile unit statistical listing.

60 Chapter 3. Compiling Programs

Using Error Search

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 84/783

Using Error Search

This section explains how to use error search and the P-STAFFeditor.

Error Search Procedures

1. Compile from the WINCOB or P-STAFF editor window.

2. When compilation has ended, a message appears on the P-STAFF editor. If the message already exists, open the P-STAFF editor to display the message.

3. Move the cursor to the line of the diagnostic message andpress the F11 key or select Tag Jump from the Search menu.The COBOL source program is displayed, and the cursormoves to the line causing the message.

Figure 25. The P-STAFF editor 

Chapter 3. Compiling Programs 61

4. Correct the program in the edit window. To switch from theedit window to the message window, press the Shift and F11

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 85/783

g , pkeys or select Back Tag Jump from the Search menu.

The error search function is effective only for compile messages.This function cannot be activated from messages written to thecompiler listings (when PRINT has been specified as the

compiler option).Error search cannot be used when the compiler option NUMBERhas been specified.

If the total length (underlined portion) of the file name, spacesand line numbers in the diagnostic message exceeds 63 bytes, thefirst part of the file name is truncated and the message is written

as 63 bytes. This means error search cannot be used.For example:

C:\TEST.COB 4: JMN25031-S USER WORD "A" ISUNDEFINED.

Using the P-STAFF Editor 

The error search function displays the COBOL85 P-STAFF editwindow of the COBOL source program.

This section describes the functions of each item in the P-STAFFeditor menu bar. The menu bar used in the P-STAFF editor hasthree items: File, Edit and Find. Refer to the online help fordetails.

 [File]

Opens, saves and closes a file, specifies the font, and setscompiler options and runs compilation (valid only for currentlyopen files).

62 Chapter 3. Compiling Programs

[Edit]Allows you to cut and paste, copy and delete, specify a range,

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 86/783

y p py p y gand control the line number.

[Find]

Finds and replaces, moves the cursor, and controls tag-jump andback tag-jump.

When the line number is renumbered, the new numberoverwrites any characters in the first six columns.

Alternative Editors

You can direct P-STAFF to use an editor other than the P-STAFF

editor. To do this:

1. From the File menu, click Customize Editor and click Setfrom the cascading menu. The Customize Editor dialog box isdisplayed.

2. Enter the command line of the editor to be used and click theOK button. Note: All open P-STAFF editor windows will be

closed when the customize editor function is selected. Thereason for this is to provide a clean break from using the P-STAFF editor to using the newly configured editor.

3. To return to using the P-STAFF editor, click on CustomizeEditor in the File menu and click on Reset from the cascadingmenu.

Compiler messages created by the Project Make function or bycompiling using WINCOB are displayed using the editorspecified with the Customize Editor function.

Note: When other editors are selected, the error message searchfunction of P-STAFF cannot be used. The presence of the tag- jump function depends on the function of the selected editor.

Chapter 3. Compiling Programs 63

Using Commands to Compile

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 87/783

COBOL32 Commands

With COBOL32 commands, you can compile from the commandprompt.

Specification Example and Output Format

COBOL32 commands return compilation information such as theresults of compilation and diagnostic messages to the command

prompt screen.For details on the format of COBOL32 commands and theavailable options, refer to Appendix J, “Command Formats.”

The following example shows how to compile with a COBOL32command, and the output.

General FormatA compile end message is normally written if compile optionMESSAGE has not been specified. If a compile error occurs, thecorresponding diagnostic message is generated.

Figure 26. The compile end message

64 Chapter 3. Compiling Programs

Output InformationWhen the compiler option MESSAGE has been specified, the

i i f i li i d il i i i l

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 88/783

option information listing and compile unit statisticalinformation listing are written. If a compile error occurs, thecorresponding diagnostic message is written.

Figure 27. Listings when the compiler option MESSAGE is specified

Differences in Compilation Run from WINCOB

Compilation operations run by COBOL32 command differ fromcompilation operations run from WINCOB in the followingways:

• No compile progress screen is displayed when compilation isrun from COBOL32 commands.

• To interrupt compilation, follow the same method as for DOS

commands.

Chapter 3. Compiling Programs 65

Return Codes for COBOL32 Commands

Th t d f COBOL32 d t di t

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 89/783

The return codes for COBOL32 commands are set according tothe highest severity code when the program is compiled. Therelation between the highest severity code and the return code isshown below.

Highest Severity

Code

 Return

Code  I

  0  W  E 1  S 2  U 3

66 Chapter 3. Compiling Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 90/783

Chapter 4. Linking Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 91/783

This chapter describes the resources required for linking,program structure, linkage procedures, how to use windows forlinking, linking with link commands, and link messages.

68  Chapter 4. Linking Programs

Linking Sample Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 92/783

Compilation creates an object program that must be linked beforeit can be executed.

Windows 95 and Windows NT

This section shows how to use WINLINK to link the Sample 1program. This section assumes the file containing the objectprogram to be:

C:\FSC\PCOBOL32\SAMPLES\SAMPLE1\SAMPLE1.OBJ

To perform a link:

• Select WINLINK [Link] from the P-STAFF Tools menu.The WINLINK [Linking Files] window appears.

Chapter 4. Linking Programs 69

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 93/783

Figure 28. The WINLINK [Linking Files] window

• Select EXE in the Type box.

• Use the Browse button to locate and select the object file to

link in the Link File edit box.• Click on the Add button. The object name is displayed in the

list box. The executable program to be created is displayed inthe Target edit box.

• Click on the Link button. The system displays a commandprompt screen showing the linker messages.

• The system completes linking. The command promptwindow displays a message stating that the system hascompleted linking. Make sure that linking has completedsuccessfully, then close the command prompt window.

70  Chapter 4. Linking Programs

Windows 3.1

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 94/783

This section shows how to use WINLINK to link the Sample 1program. This section assumes the file containing the objectprogram to be:

C:\FSC\PCOBOL16\SAMPLES\SAMPLE1\SAMPLE1.OBJ

The section describes how to link the example dynamically.

1. Select WINLINK from the Utilities menu in the P-STAFFwindow. The WINLINK [Linking Files] window appears.

Figure 29. The WINLINK [Linking Files] window

2. Set the required information.

Select EXE in the Target box. Enter the object file.

Click on the Add button. The object name is displayed in thelist box. The executable program to be created by linking isdisplayed.

Enter the module definition file. Click on the Add button.

Chapter 4. Linking Programs 71

3. Click on the Build button in the WINLINK [Linking Files]window.

A link message is displayed in the message window.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 95/783

g p y g

4. The system completes linking.

A message stating that the system completed linking isdisplayed in the message box. Make sure that linking has

completed successfully, then close the message box.

This completes linking of the sample program. Make sure that anexecutable program (SAMPLE1.EXE) is created in the directorycontaining the sample program (in this example,C:\FSC\PCOBOL16\SAMPLES\SAMPLE1).

Resources Required for Linking

Object programs compiled from COBOL source programs areusually linked using WINLINK. WINLINK allows you to createlibraries, import libraries, dynamic link libraries (DLLs), andexecutable files through simple screen operations. This sectionbriefly describes the files required for linking.

You must take into account the type of link required and theprogram structure. See “Linkage Types and Program Structure.”

Before linking using WINLINK, the work disk drive must be setin environment variable TMP.

This following examples illustrate the files used and created byWINLINK.

72  Chapter 4. Linking Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 96/783

Figure 30. Building COBOL libraries with WINLINK

Figure 31. Linking files (creating an Import Library and DLL) with WINLINK

Chapter 4. Linking Programs 73

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 97/783

Figure 32. Linking files (creating an .EXE) with WINLINK

Notes on the above figures:

*1 The module definition file is generated automatically and isnot specified in the WINLINK window.

*2 Standard libraries can be built using the WINLINK BuildingCOBOL Libraries function.

*3 Import libraries are required for the dynamic link structure.The DLL/Import library should be made beforehand.

74  Chapter 4. Linking Programs

The following table describes the files used by WINLINK.

Table 5. Files used by WINLINK

File Contents File Name I/O Condition to Use or

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 98/783

File Contents File NameFormat

I/O Condition to Use orCreate

1 Object file Source-file-name. OBJ

I Use the object programcompiled from a COBOL

source program

2 Moduledefinitionstatement(Required forsubprograms )

Optional-name. DEF

I [16] Required to create animport library, export file,or DLL[32] Required to create animport library, DLL orEXE

 O Created automatically ifomitted in the WINLINKwindow

3 Standardlibrary (Objectcode library )

Optional-name. LIB

 I Define when required tocreate a DLL or executablefile

O Created by the WINLINK

Building COBOL Librariesfunction.

Chapter 4. Linking Programs 75

Table 5. Files used by WINLINK (cont.)

FileContents

File NameFormat

I/O Condition to Use or Create

4 Import Optional I Specif to create an

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 99/783

4 Importlibrary

Optional-name. LIB

  I Specify to create anexecutable file having thedynamic link structure.

  O [16] Created when DLL is

selected in WINLINK[Linking Files] and checkedby selecting BuildingImport Libraries.[32] Created automaticallywhen DLL is selected inWINLINK Linking Files

5 Dynamic

link library(DLL)

Object-file-

name.DLLor Optional-name. DLL

  O Created when linking has

completed successfully.

6 Executableprogram

Object-file-name.EXEor Optional-name. EXE

  O Created when linking hascompleted successfully.

Executable Files

The executable files created are Microsoft Windows applicationsand will run in the following environments:

• Microsoft Windows 95 operating system

• Microsoft Windows NT Workstation operating system

Version 3.51(or above) , Microsoft Windows NT ServerNetwork operating system Version 3.51(or above).

• Microsoft Windows 3.1 operating system

76  Chapter 4. Linking Programs

DLLs

DLL t bl d l t i i f ti ll d t

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 100/783

DLLs are executable modules containing functions called toperform any processing from Windows applications. A DLL islinked with an application at run time, instead of during linking.

A DLL allows multiple applications to use the same library. In amultitasking environment such as Windows, DLLs are veryefficient because multiple applications can share the same DLL.

Import Library

The import library contains information used to set a dynamiclink between an active application and a DLL during applicationexecution. This library is required to create an executable filehaving a dynamic link structure.

The system copies information indicating where a requiredlibrary is stored from the import library to the executableprogram. In other words, the import library provides an interface

between the application and the DLL.

Module Definition File

The contents of the module definition file depend on whetheryou are using Windows 95 and Windows NT or Windows 3.1.

Module Definition File Contents (32)

The module definition file is required to create the import library.Create the file with a text editor.

Chapter 4. Linking Programs 77

Even if a module definition file is not specified in the WINLINK[Linking Files] window, it is created automatically duringlinking.

The module definition file is used indirectly to create an

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 101/783

The module definition file is used indirectly to create anexecutable file having a dynamic link structure, because theimport library created from information in the file must bespecified.

The module definition statements in the module definition filedefine the contents of the DLL and requirements to the system.

The following table lists the module definition statements thatcan be used.

Table 6. Module definition statements (32)

ModuleStatement

Description

NAME Defines the module name of an application.LIBRARY Specifies the module name of a dynamic link library.DESCRIPTION Describes the modules briefly.STACKSIZE Specifies the stack size in bytes.SECTIONS Sets the attribute of a specific section.EXPORTS Specifies the PROGRAM-ID and ENTRY names.

VERSION Embeds the version number.The module definition file must contain the following statements:

• LIBRARY

• EXPORTS

When the file is created automatically, the specified object nameis set as EXPORTS.

78  Chapter 4. Linking Programs

The following figure shows the contents of the module definitionfile created from the WINLINK [Linking Files] window.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 102/783

Figure 33. A module definition file created by WINLINK

Module Definition File Contents (16)

The module definition file used under Windows 3.1 is requiredfor linking. Create the file with a text editor.

Even if no module definition file is specified in the WINLINK[Linking Files] window, it is created automatically duringlinking.

The module definition statements in the module definition file

define the contents of the application or DLL and requirementsto the system.

Chapter 4. Linking Programs 79

The following table lists the module definition statements thatcan be used.

Table 7. Module definition statements (16)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 103/783

ModuleStatement

Description

NAME Defines the module name of an application.LIBRARY Specifies the module name of a dynamic link library.

DESCRIPTION Describes the modules briefly.CODE Defines the attribute of the code segment.DATA Defines the attribute of the data segment.STACKSIZE Specifies the local stack size in bytes.STUB Specifies the MS-DOS executable file used to display an

alarm message when any application is ran outside theWindows environment.

EXPORTS Specifies the module functions that will be called by

Windows or other applications.IMPORTS Specifies functions of other applications that will be

called from this module.HEAPSIZE Specifies the local heap size in bytes.PROTMODE Sets the executable program to run in Windows

protected mode only (standard or 386 extended).EXETYPEWINDOWS 3.0

Sets applications to run under the Windowsenvironment. This statement must not be omitted

Different formats are used for the module definition filedepending on whether you create an application or DLL.

The following examples show the module definition files createdin the WINLINK [Linking Files] window for applications andDLL. Information in the module definition file was set with themodule definition file templates.

80  Chapter 4. Linking Programs

Module Definition File for Applications

  NAME 'SAMPLE1' (1)EXETYPE WINDOWS 3 1 (2)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 104/783

  EXETYPE WINDOWS 3.1 (2)  STUB 'COBSTUB'  PROTMODE (3)  DATA MULTIPLE MOVEABLE  PRELOAD  CODE MOVEABLE  PRELOAD DISCARDABLE  HEAPSIZE 1024  STACKSIZE 8192 (4)

(1) Set the program name.

(2) Set the application to run under Windows.

(3) Set protected mode.

(4) Set required sizes.

Module Definition File for DLLs

LIBRARY 'INSATSU' (1)EXETYPE WINDOWS 3.1STUB 'COBSTUB' (2)

PROTMODEDATA SINGLE MOVEABLE PRELOADCODE MOVEABLE PRELOADDISCARDABLEEXPORTS (3)WEP (4)INSATSU

(1) Define the module name of the DLL.

(2) Display an alarm message if you run a Windows applicationunder DOS.

(3) Set the Windows End Procedure (WEP) callback functionwhich processes the DLL before unloading the library. TheWEP is required and must not be omitted.

(4) Set the specified object name.

Chapter 4. Linking Programs 81

Linkage Types and Program Structure

This section describes the structure of an executable programd b li ki

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 105/783

created by linking.

There are two types of linkage, static and dynamic.

Static Linkage

The calling program and called program are all linked duringlinking.

Dynamic Linkage

The called program is linked to the calling program at run time.

The following shows the relationship of the program structurescreated by static and dynamic linkage. Throughout this section,the main program is the program initially run and thesubprogram is the program called from the main program. Aprogram called from a subprogram is also called a subprogram.

Simple Structure

Simple structure means that multiple object programs are linkedto a single executable program by a static linkage. Therefore, the

82  Chapter 4. Linking Programs

main program and subprograms are all loaded to virtual storageat the beginning of execution, thus allowing programs to callsubprograms efficiently.

You need all subprograms during linking when you create anl l h l

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 106/783

executable file having a simple structure.

Dynamic Link Structure

Dynamic link structure means that the main program objectprogram and the import library containing subprograminformation are dynamically linked to a single executableprogram.

Unlike the simple structure, no subprograms are linked to the

executable file for the dynamic link structure. Subprograms areloaded to virtual storage when the main program is loaded.

Programs are loaded by the dynamic linker of the system usingsubprogram information created in the executable file duringdynamic linking. To create an executable file having the dynamiclink structure, the import library containing all subprogramscalled by the program is required during linking.

Dynamic Program Structure

Dynamic program structure uses only the main program objectprogram as an executable program in a dynamic link. Therefore,unlike the dynamic link structure, no subprogram information isincluded in the executable program.

With dynamic program structure, subprograms are loaded bythe calling program from the COBOL85 run-time system. For thisreason, the loading function of the system is used.

The program structure is determined by the format of the CALLstatement, options specified at compilation, and type of link. Thefollowing table lists the relationship between the program

Chapter 4. Linking Programs 83

structure, CALL statement, compiler options, and link types. Forcompiler option DLOAD, refer to Appendix A, “CompilerOptions.”

Table 8. Relationship between program structure, CALL statement,il ti d li k t

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 107/783

compiler options, and linkage types

ProgramStructure

Call Statement CompilerOption

Linkage Type

Simplestructure

CALL "program-name" NODLOAD Static linkage

Dynamic linkstructure

CALL "program-name" NODLOAD Dynamiclinkage

Dynamicprogramstructure

CALL data-name ___________ Dynamiclinkage

CALL "program-name"CALL data-name(coexisting)

DLOAD

CALL "program-name" DLOAD

84  Chapter 4. Linking Programs

Link Procedures

Obj il d f COBOL

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 108/783

Object programs compiled from COBOL source programs(COBOL object programs) can be linked through windowoperation with the WINLINK command, or from the command

prompt with link commands.

This section describes the procedures for linking with theWINLINK command. Linking with commands is explained in“Using Commands to Link.”

Linking a Single Object Program

To create an executable program that does not call anysubprograms:

• Activate the WINLINK [Linking Files] window. See“Activating the WINLINK Window.”

• Select EXE in the Type box.

• Enter the target name. See “Entering the Target Name.”

• Enter the other files (object file, module definition file)required for linking in the File Names list box. See “EnteringFiles.”

• Set linker options. See “Setting Linker Options.”

• Start linking. See “Starting and Quitting Linking.”

• Quit linking. See “Starting and Quitting Linking.”

Chapter 4. Linking Programs 85

Creating a DLL

To create a DLL by linking a subprogram object program:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 109/783

• Activate the WINLINK [Linking Files] window. See“Activating the WINLINK Window.”

• Select DLL in the Type box.

• Enter the target name. See “Entering the Target Name.”Do not enter any object files created by specifying compileroption MAIN during compilation.

• Enter the other files (object file, module definition file)required for linking in the Link File list box. See “Entering

Files.”

• Set linker options. See “Setting Linker Options.”

• Start linking. See “Starting and Quitting Linking.”

• Quit linking. See “Starting and Quitting Linking.”

Creating an Executable Program with a Simple Structure

The COBOL object program must be compiled from a COBOLsource program containing no dynamic CALL statements (thoseusing data names to specify the called program name), or becompiled after specifying the compiler option NODLOAD.

To create an executable program having a simple structure bylinking a COBOL object program that calls a subprogram:

• Create the subprogram as an object program or library. See“Procedures for Creating a Library.”

• Activate the WINLINK [Linking Files] window. See“Activating the WINLINK Window.”

86  Chapter 4. Linking Programs

•Select EXE in the Type box.

• Enter the target name. See “Entering the Target Name.”

• Enter the other files required for linking in the File Names listbox. See “Entering Files.”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 110/783

− Object file

Module definition file− Subprogram created in Step 1

− Object file (when the subprogram is an object program)

− Library (when the subprogram is a library)

• Set linker options. See “Setting Linker Options.”

• Start linking. See “Starting and Quitting Linking.”

• Quit linking. See “Starting and Quitting Linking.”

Creating an Executable Program with a Dynamic LinkStructure

The COBOL object program must be compiled from a COBOLsource program containing no dynamic CALL statements (thoseusing data names to specify the called program name), or becompiled after specifying the compiler option NODLOAD.

To create an executable program having a dynamic link structureby linking a COBOL object program that calls a subprogram:

• Activate the WINLINK [Linking Files] window. See“Activating the WINLINK Window.”

• First create a DLL from the subprogram:

− Select DLL in the Type box.

− Enter the target name. See “Entering the Target Name.”

Chapter 4. Linking Programs 87

Enter the other files required to link the subprogram in theFile Names list box. See “Entering Files.”

− Object file (Subprogram)

− Module definition file (Subprogram)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 111/783

• Set linker options. See “Setting Linker Options.”

Create an import library (16).For Windows 3.1, check "Building Import Libraries" in theCommand menu.

• Start linking the subprogram. See “Starting and QuittingLinking.” The DLL, the import library (DLL name.LIB) andexport file of the subprogram are created.

If the import library already exists a message will bedisplayed.

Then create the executable for the main program:

• Select EXE in the Type box.

• Enter the target name. See “Entering the Target Name.”

• Enter the other files required to link the main program in theFile Names list box. See “Entering Files.”

− Object file (Main program)

− Module definition file

− Import library (created when you started linking theprogram)

• Set linker options. See “Setting Linker Options.”

• Start linking. See “Starting and Quitting Linking.”

• Quit linking. See “Starting and Quitting Linking.”

88  Chapter 4. Linking Programs

Creating an Executable Program with a DynamicProgram Structure

The COBOL object program used here must be compiled from a

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 112/783

The COBOL object program used here must be compiled from aCOBOL source program containing CALL statements in dataname specification, or be compiled after specifying the compiler

option DLOAD.

To create an executable program having a dynamic programstructure by linking a COBOL object program that calls asubprogram:

• Create the subprogram as a DLL.

•Activate the WINLINK [Linking Files] window. See“Activating the WINLINK Window.”

• Select EXE in the Type box.

• Enter the target name. See “Entering the Target Name.”

• Enter the other files (object file(main program)) required forlinking in the Link File list box. See “Entering Files.”

• Set linker options. See “Setting Linker Options.”

• Start linking. See “Starting and Quitting Linking.”

• Quit linking. See “Starting and Quitting Linking.”

Chapter 4. Linking Programs 89

Creating a Library

To create a library by linking object programs of multiplesubprograms:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 113/783

p g

• Activate the WINLINK [Linking Files] window. See

“Activating the WINLINK Window.”• Switch to the WINLINK [Building COBOL Libraries]

window. Select Building COBOL Libraries from theCommands menu.

• Enter the COBOL library name. See “Entering a TargetLibrary Name.” If an existing file name is entered, theexisting file is deleted and a new file is created.

• Enter the other files to be included in the library in the ObjectFile list box. See “Entering Files.”

• Start library building. See “Starting and Quitting LibraryBuilding.”

• Quit library building. See “Starting and Quitting Library

Building.”

Creating an Import Library

WINLINK also creates an import library when it creates a DLL.To create an import library:

• Create the subprogram as a DLL.

• Specify creation of an import library. (16)For Windows 3.1, check "Building Import Libraries" from thecommand menu. For Windows 95 and Windows NT, theimport library is created automatically.

• Start linking. After linking, the following files are created:

90  Chapter 4. Linking Programs

− DLL

− Import library of subprogram (DLL-name.LIB)

− Export file (32)

If an import library already exists, an alarm message isdi l d

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 114/783

displayed.

WINLINK

WINLINK is a utility that links programs compiled by COBOL85to create executable programs and DLLs, libraries, and importlibraries. WINLINK provides two windows.

• WINLINK [Linking Files] window:

Creates import libraries, DLLs, and executable programs.

• WINLINK [Building COBOL Libraries] window:

Creates libraries.

Switch these windows by selecting the Commands menu on the

menu bar in each window. For details about how to use thewindows, refer to the online help.

Activating the WINLINK Window

To activate the WINLINK window, do one of the following:

• Select WINLINK from the Tools menu in P-STAFF (32).

• Select WINLINK.EXE in the File Manager directory window(16).

Chapter 4. Linking Programs 91

WINLINK [Linking Files] Window

The WINLINK [Linking Files] window is used to create importlibraries, DLLs, and executable programs by linking.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 115/783

Use the menu bar to exit the window, set linker options, orswitch between windows.

Select the target type as either EXE or DLL.

The following sections describe how to use the window.

Figure 34. The WINLINK window

The WINLINK window contains the following elements:

Commands

Switches the window between linking files mode andbuilding COBOL libraries mode.

92  Chapter 4. Linking Programs

Help

Access the online help.

Target edit box

Specify the name of the file to be created.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 116/783

Type radio buttons

Specify whether an EXE or DLL file should be created.Link File edit box

Specify the name of a file to be added to the List.

Link Object List

Displays a list of the input files to the link.

Browse button

Click to select a file to be included in the link.

Add button

Click to add the file in the Link File edit box to the List.

Delete button

Click to remove the selected file(s) from the List.

OK button

Click to start the link and close the WINLINK window.

Cancel button

Click to close the WINLINK window without performing a

link.

Options button

Click to specify the link options.

Chapter 4. Linking Programs 93

Link buttonClick to start the link and keep the WINLINK window openfor further links.

Entering the Target Name

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 117/783

The name of the file to be created by linking can be entered in theTarget edit box using one of two methods.

Method 1

1. Select whether the target should be EXE or DLL in the Typebox.

2. Enter, or browse and select, an object file in the Link File edit

box.

3. Click the Add button. The object file name is added to theLink Object List. A target name is automatically created bycombining the extension specified in the Type box with thebase of the object file name.

Method 2Enter the name of the file to be created directly in the Target editbox.

If the Type is selected after a file name is entered in the Targetedit box, the extension of the entered file name will change to theextension of the file selected by the option button.

Entering Files

Enter the names of files required to link in the Link Object Listbox by following the procedures below.

94  Chapter 4. Linking Programs

1. Click on the Browse button, then select the files required tolink from the Browse Files dialog box. Files required to linkinclude:

− Object file

− Module definition file [(16): required] [(32): when creating]

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 118/783

a DLL]

− Library− Import library (when creating an executable program

having a dynamic link structure)

2. Click on the OK button. The selected file names are displayedin the Link File edit box. Alternatively the file name(s) can bekeyed directly into the Link File edit box.

3. Click on the Add button. The file names are added to the FileNames list box.

4. Repeat Steps 1 to 3 until all files to link are entered.

Building an Import Library

In Windows 95 and Windows NT, an import library and anexport file are automatically created when a DLL is created.

To create an import library under Windows 3.1, check "BuildingImport Library" in the WINLINK [Linking Files] Commandmenu.

Setting Linker Options

Different Linker Options screens are used for (32) Windows 95and Windows NT and (16) Windows 3.1.

Chapter 4. Linking Programs 95

Windows 95 and Windows NT

Linker options are set using the Linker Options dialog boxdisplayed by clicking the Options button in the WINLINK[Linking Files] window.

A main link option (Debugging is excluded) is automatically set.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 119/783

See the LINK command options table in Appendix J.

Figure 35. The Linker Options dialog box

The Linker Options dialog box contains the following elements:

Linker Options edit box

Enter link options.

Delimit multiple options with one or more spaces.

Debug  buttonClick to include linker debug options in the Linker Optionsedit box.

OK button

Click when finished specifying linker options.

Cancel buttonClick to cancel any linker option settings or changes andreturn to the state before the dialog box was opened.

Help button

Click to access the online help.

96 

Chapter 4. Linking Programs

Windows 3.1

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 120/783

Figure 36. The Linker Options dialog box

The Linker Options dialog box contains the following elements:

CO

Prepares for debugger operation. Use this option whencompiler option TEST was specified during compilation of

source programs.

NOD

Restricts the linker to use only standard libraries. Always usethis option when linking object programs compiled by theCOBOL85 compiler.

NOE

Disables the library extended dictionary.

M

Outputs a list of public symbols to the map file.

Options

Allows direct key entry of other linker options.OK button

Click when finished specifying linker options.

Cancel button

Chapter 4. Linking Programs 97

Click to cancel any linker option settings or changes andreturn to the state before the dialog box was opened.

Starting and Quitting Linking

After all information required for linking has been set, start

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 121/783

After all information required for linking has been set, startlinking. To start linking, select the Link button.

The system brings up a command prompt window that displaysthe linker messages. (32)

A link message is displayed in the message window. (16)

A link exit message is displayed in the command promptwindow. Make sure that linking has completed successfully, thenclose the command prompt window. (32)

A link exit message is displayed in the message window. Makesure that linking has completed successfully, then close themessage box. (16)

If a link error occurs, see “Linker Messages” and take action.

To continue linking, repeat the procedure from the entering a

target name step.To quit linking, click on the Cancel button in the WINLINK[Linking Files] window. This closes the window.

Please note the following points as they are causes of commonlink errors:

• Always use the linker corresponding to the object.

• Do not create an executable program only from objectprograms containing the compiler option NOMAIN (that is,no compiler option MAIN was used during compilation).

• Do not create an executable program from multiple programscontaining the compiler option MAIN.

98  Chapter 4. Linking Programs

WINLINK [Building COBOL Libraries] Window

Use the WINLINK [Building COBOL Libraries] window to linkmultiple object programs to a library.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 122/783

Figure 37. The WINLINK [Building COBOL Libraries] window

The WINLINK [Building COBOL Libraries] window contains thefollowing elements:

Commands

Switches the window between linking files mode andbuilding COBOL libraries mode.

Help

Accesses the online help.

Chapter 4. Linking Programs 99

COBOL Library File edit boxSpecify the name of the library file to be created.

[COBOL Library File] Browse button

Click to select the name of a library file to be created.

Object File edit box

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 123/783

Object File edit box

Specify the name of a file to be added to the List.Do not enter programs containing compiler option MAIN.

Link Object List

Displays a list of input files to include in the link.

[Link Object] Browse button

Click to select a file to be included in the link.Add button

Click to add the file in the Object File edit box to the List.

Delete button

Click to remove the selected file(s) from the List.

OK buttonClick to start the link and close the WINLINK [BuildingCOBOL Libraries] window.

Cancel button

Click to close the WINLINK [Building COBOL Libraries]window without performing a link.

Build button

Click to start the link and keep the WINLINK [BuildingCOBOL Libraries] window open for further links.

The following sections describe how to use the window to buildlibraries.

100  Chapter 4. Linking Programs

Entering a Target Library Name

Enter the name of a target library in the COBOL Library File editbox by using either of the procedures below.

Method 1

E t th f bj t fil i Obj t Fil Th t d fil

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 124/783

Enter the name of an object file in Object File. The entered file

name having the extension LIB is displayed in the COBOLLibrary File edit box.

Method 2

Enter the name of the target file in the COBOL Library File editbox.

If an existing library name is entered here, the library is deletedand a new library is created.

Entering Files

Enter the names of object files to be linked in the Link Object Listwith the procedures below.

1. Click on the [Link Object] Browse button, then select requiredfiles from the Browse Files dialog box.

2. Click on the Open button. The selected file names aredisplayed in the Object File edit box. Alternatively the filename(s) can be keyed directly into the Object File edit box.

3. Click on the Add button. The file names are added to the

Link Object List.

4. Repeat Steps 1 to 3 until all object files to be linked areentered.

Chapter 4. Linking Programs 101

Starting and Quitting Library Building

After all information required for linking has been set, startbuilding the libraries. To start building, click on the Build button.

 Windows 95 and Windows NT: The system brings up acommand prompt window that displays the linker messages.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 125/783

 Windows 3.1: A building library message is displayed in themessage window.

 Windows 95 and Windows NT: A building library end messageis displayed in the command prompt window. Make sure thatlinking has completed successfully, then close the commandprompt window.

 Windows 3.1: A building library exit message is displayed in the

message window. Make sure that linking has completedsuccessfully, then close the message window.

To continue building, repeat the procedure from the “entering atarget library name” step.

To quit building, click on the Cancel button in the WINLINK[Building COBOL Libraries] window. This closes the window.

Using Commands to Link

Object programs can also be linked with commands. This sectiondescribes link operation with commands.

There are two commands, the LINK command and the LIBcommand.

102  Chapter 4. Linking Programs

LINK Command (32)

In Windows 95 and Windows NT, the LINK command performsthe link operation. Refer to “LINK Command” in Appendix J fordetails of the format of the command.

When executing the LINK command, the following libraries

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 126/783

must be specified:

• F3BICIMP.LIB

• LIBC.LIB

• KERNEL32.LIB

• USER32.LIB

Some examples of how to use the LINK command follow.

LIB Command (32)

In Windows 95 and Windows NT, the LIB command performsthe creation of standard libraries and import libraries. Refer to“LIB Command” in Appendix J for details of the format of thecommand.

Examples of Using the LINK and LIB commands (32)

Some examples of using the LINK command and the LIBcommand are shown here.

When Linking an Object Program

LINK A.OBJ F3BICIMP.LIB LIBC.LIB KERNEL32.LIB USER32.LIB/OUT:A.EXE

Chapter 4. Linking Programs 103

When Creating a DLL

 To create an export file:

LIB /DEF:SUB.DEF /OUT:SUB.LIB /MACHINE:IX86 SUB.OBJ

 To create a DLL:

LINK SUB OBJ SUB EXP F3BICIMP LIB LIBC LIB KERNEL32 LIB

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 127/783

LINK SUB.OBJ SUB.EXP F3BICIMP.LIB LIBC.LIB KERNEL32.LIB

USER32.LIB /DLL /OUT:SUB.DLL

When Creating an Executable Program with a Dynamic LinkStructure

 To create an import library:

LIB /DEF:BBB.DEF /OUT:BBB.LIB /MACHINE:IX86 BBB.OBJ

 To create a DLL:

LINK BBB.OBJ BBB.EXP F3BICIMP.LIB LIBC.LIB KERNEL32.LIB USER32.LIB /DLL/OUT:BBB.DLL

 To create an executable program:

LINK AAA.OBJ F3BICIMP.LIB LIBC.LIB KERNEL32.LIB USER32.LIB BBB.LIB

/OUT:AAA.EXE

LINK Command (16)

Windows 3.1 provides the LINK, LIB, and IMPLIB commandsfor linking.

104  Chapter 4. Linking Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 128/783

Figure 38. Files used by the LINK command

Files or libraries 1) to 6) correspond to 1) to 6) in Table 5. Files 7)and 8) are explained below.

• F1BCARMV.LIB of 7): Arithmetic library provided byCOBOL85. Always specify this library when linking COBOLprograms.

• F1BCOWEP.LIB of 7): Library provided by COBOL85.Always specify this library when building DLLs by linkingCOBOL programs.

• F1BCCIMP.LIB and LIBW.LIB of 8): Run-time systemprovided by COBOL85 and import library of Windows 3.1.Specify these files when linking COBOL programs.

Chapter 4. Linking Programs 105

Linker Messages

This following sections describe linker messages displayedduring COBOL85 operation in Windows 95 and Windows NT(32) and Windows 3.1 (16).

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 129/783

Windows 95 and Windows NT

The following linker messages may be displayed in Windows 95and Windows NT.

LNK1104

Explanation:There is not enough space on the disk or root folder.Operator response:Delete files to make space.

LNK1123

Explanation:

An attempt was made to link Microsoft Windows operatingsystem Version 3.1 objects with the 32 bit linker.Operator response:Use 32 bit Objects.

LNK1561

Explanation:

An attempt was made to create an executable program (EXE) bycompiling the main program without the compiler option MAIN.Operator response:Specify the compiler option MAIN before compiling the mainprogram.

106  Chapter 4. Linking Programs

LNK2001

Explanation:- No internal name of the export routine is defined in theEXPORTS definitions in the module definition file.- No internal name of the export routine is set in the library orobject file.Operator response:M k th t th t i th EXPORTS t t t f th

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 130/783

Make sure that the export name in the EXPORTS statement of themodule definition file is set in the library or object file.

LNK2005

Explanation:Tried to make a single executable file from two or moreprograms compiled with the MAIN option.

Operator response:Specify only the MAIN compiler option for the main program.

LNK4006

Explanation:- EXPORTS is duplicated in the module definition file.- The internal name of existent data was found in the library or

object file.Operator response:Make sure that the export name in the EXPORTS statement of themodule definition file is duplicated in the library or object file.

Chapter 4. Linking Programs 107

Linker Messages (16)

The following linker messages may be displayed in Windows 3.1:

L1052

Explanation:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 131/783

p

Too many libraries were linked.Operator response:- Link libraries to reduce the number of libraries.- Use a module requiring less libraries.

L1081

Explanation:

There is not enough space on the disk or root directory.Operator response:- Delete files to make space.- Move files to make space.

L1082

Explanation:The directory containing COBSTUB.EXE was not set in theenvironment variable PATH.Operator response:Set the install directory of the COBOL system in the environmentvariable PATH.

L1101

Explanation:An attempt was made to link Windows NT objects with theWindows 3.1 linker.Operator response:Use the Windows NT linker.

108  Chapter 4. Linking Programs

L2022

Explanation:- No internal name of the export routine is defined in theEXPORTS definitions in the module definition file.- No internal name of the export routine is set in the library orobject file.Operator response:Make sure that the export name in the EXPORTS statement of the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 132/783

Make sure that the export name in the EXPORTS statement of themodule definition file is set in the library or object file.

L2023

Explanation:- EXPORTS is duplicated in the module definition file.- The internal name of existent data was found in the library or

object file.Operator response:Make sure that the export name in the EXPORTS statement in themodule definition file is duplicated in the library or object file.

L4038

Explanation:

An attempt was made to create an executable program (EXE) bycompiling the main program without the compiler option MAIN.Operator response:Specify the compiler option MAIN before compiling the mainprogram.

Chapter 5. Executing ProgramsThis chapter describes the procedures for executing programs,setting run-time environment information, and operatingwindows for execution.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 133/783

110 Chapter 5. Executing Programs

Executing Sample Programs

This section shows how to execute the program in Sample 1 withWINEXEC in Windows 95/Windows NT and Windows 3.1.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 134/783

Windows 95 and Windows NT

Throughout this section, assume the run-time information to be:

C:FSC\PCOBOL32\SAMPLES\SAMPLE1\SAMPLE1.EXE

Select WINEXEC from the Tools menu of the P-STAFF window.

The WINEXEC window appears.

Figure 39. The WINEXEC window

Chapter 5. Executing Programs 111

• Enter the name of the file to execute (SAMPLE1.EXE) in the

Command Line edit box.

• Click on the Execute button. The Run-time EnvironmentSetup window is displayed.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 135/783

Figure 40. The Run-time Environment Setup window

• For Sample 1, there is no information to set. Click on the OKbutton in the Run-time Environment Setup window. Thesystem starts executing the program.

• For Sample 1, the system inputs or outputs data using theCOBOL ACCEPT/DISPLAY function. A console window isdisplayed.

112 Chapter 5. Executing Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 136/783

Figure 41. The COBOL85 console window

• Enter a lowercase letter, then press the ENTER key. Alowercase letter is displayed along with corresponding text.In the following example, cobol85 is displayed based on thespecified letter "c".

Chapter 5. Executing Programs 113

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 137/783

Figure 42. The COBOL85 console window and message window

• Check the results, then click on the OK button in the messagewindow. The message window and console window close.

This completes execution of the sample program.

Windows 3.1

Throughout this section, assume the run-time information to be:

C:FSC\PCOBOL16\SAMPLES\SAMPLE1\SAMPLE1.EXE.

Select WINEXEC from the Utilities menu in the P-STAFF

window. The WINEXEC window appears.

114 Chapter 5. Executing Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 138/783

 Figure 43. The WINEXEC window

Enter the name of the file to execute (SAMPLE1.EXE) in theCommand Line edit box.

• Click on the Execute button. The Run-time EnvironmentSetup window is displayed.

Figure 44. The Run-time Environment Setup window

Chapter 5. Executing Programs 115

• For Example 1, there is no information to set. Click on the

Run button in the Run-time Environment Setup window. Thesystem starts executing the program.

• For Example 1, the system inputs or outputs data using theCOBOL ACCEPT/DISPLAY function. A console window isdisplayed. Enter a lowercase letter, then press the ENTER key.A lowercase letter is displayed along with corresponding text.

I th f ll i l b l85 i di l d b d th

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 139/783

In the following example, cobol85 is displayed based on thespecified letter "c".

Figure 45. The COBOL85 console window

116 Chapter 5. Executing Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 140/783

Figure 46. The COBOL85 console window and message window

• Check the results, then click on the OK button in the messagewindow. The message window and console window close.

This completes execution of the sample program.

Chapter 5. Executing Programs 117

Execution Procedures

Executable programs compiled and linked from COBOLprograms can be executed in the same manner as normalWindows applications(*) with the WINEXEC command. This

section describes how to run COBOL programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 141/783

section describes how to run COBOL programs.(*) The applications work with:

• Windows 95

• Windows NT Version 3.51 (both server and workstationversions)

Windows 3.1

Before Executing COBOL Programs

Before executing COBOL programs, you must set run-timeenvironment information.

COBOL85 calls resources and data to be assigned for executingCOBOL program run-time environment information. Forinformation about setting the run-time environment, see “SettingRun-time Environment Information.”

Before Executing COBOL Programs (16)

Before executing a COBOL program under Windows 3.1, ensurethat SHARE was loaded in MS-DOS command mode to enabled.This allows file sharing and exclusive systems to be includedbefore running Windows. The format of the SHARE command isshown below.

SHARE /L:50 /F:2048

118 Chapter 5. Executing Programs

The L option: sets exclusive control option for files and records.

Use the value determined from the following expression asstandard when executing a COBOL program.

When executing multiple COBOL programs at the same time(also for different execution units), add the value determined foreach program:

Value to be entered = 20 + number of files opened

concurrently (Number of files * 2 for index files only) +

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 142/783

concurrently. (Number of files 2 for index files only) +number of records exclusively controlled (or locked)

The F option: sets the number of files to be opened. To openmany files concurrently, enter a large value. To execute COBOLprograms, specify a value of 2048 or more, depending on thelength of the path name of files to be opened.

Once loaded, the SHARE command cannot be selected again. Ifany SHARE option must be changed, restart the system, thenexecute the SHARE command with the revised command line.

Executing COBOL Programs

COBOL programs can be executed from the WINEXEC windowor with a batch file. This section describes how to use theWINEXEC window to execute COBOL programs.

1. Activate the WINEXEC window. See “Activating theWINEXEC Window.”

2. Enter the name of the file to be executed in the CommandLine edit box. See “Entering a File Name.”

3. When any argument is specified, directly type it in theCommand Line edit box in the same command line form.

4. Start execution by selecting the Execute button in theWINEXEC window.

Chapter 5. Executing Programs 119

5. To re-execute a program already executed, double-click on

the file name displayed in the History list box.

6. Set the run-time environment information. When a COBOLprogram is executed, the Run-time Environment Setupwindow appears. Set run-time environment information ifnecessary, then close the Run-time Environment Setupwindow. See “Run-time Environment Setup Window”.

7. Quit execution. To quit execution and close the WINEXECi d l E i i h WINEXEC i d

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 143/783

7. Quit execution. To quit execution and close the WINEXECwindow, select Exit in the WINEXEC window.

Setting Run-time Environment Information

This section explains the relationship between the types of run-time environment information and setup procedures, and how toset each item in the run-time environment.

Types of Run-time Environment Information

Information required to execute COBOL applications is calledrun-time environment information.

There are two types of run-time environment information,environment variable information and entry information.Environment variable information includes items such as theconsole window size, console font, and file identifier.

Entry information includes the dynamic program structure.

The following table lists the types of run-time environmentinformation. For details on run-time environment information,see “Format of Run-time Environment Information.”

120 Chapter 5. Executing Programs

Table 9. Types of run-time environment information

Run-timeEnvironmentInformation

Description Run-timeEnvironmentInformation

Description

Environment variable information @AllFileExclusive Set exclusive controlof files

@GOPT Set run-time options @CBR_CIINF Set the logicaldestination definitionfile

@MGPRM Set the GS-series @CBR_ENTRYFILE(3 Set the entry

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 144/783

format run-timeparameter

(2)

yinformation file

@IconDLL Set the DLL-name ofan icon resource

@CBR_PSFILE_xxx Set the connected-product-name usedfrom the presentationfile

@IconName Set the identifier of

an icon resource

@NoMessage Set to suppress run-

time message@ScrnSize Set the size of thelogical screen forscreen handling

File-identifier Set the name of the fileused by the program

@MessOutFile Set the messageoutput file

File-identifier Set the information fileused by the program

@CnslWinSize Set the size of consolewindow

SYSIN-access-name Set the input file forthe ACCEPT/DISPLAY function

@CnslBufLine Set the buffers countfor the consolewindow

SYSOUT-access-name

Set the output file forthe ACCEPT/DISPLAY function

@WinCloseMsg Set a display messagewhen the windowcloses

TERMINATOR Set the function keysfor screen handling

Chapter 5. Executing Programs 121

Table 9. Types of run-time environment information (cont.)

Run-time EnvironmentInformation

Description Run-timeEnvironmentInformation

Description

@EnvSetWindow Set whether theRun- timeEnvironment Setupwindow is used

FCBxxxx Set FCB controlstatements

@PrinterFontName Set the font used for

print files

FOVLDIR Set the directory

containing forml

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 145/783

overlay patterns@CnslFont Set the console

window fontOVD_SUFFIX Set the extension of

the form overlaypattern file

@ScrnFont Set the font used forscreen handling

FOVLTYPE Set the format ofthe form overlaypattern file

@ODBC_Inf Set the ODBCinformation file @PRN_FormName_xxx(32) Form name

@CBR_PrintTextPosition(32)

Method ofcalculating characterarrangementcoordinates

@DefaultFCB_Name Name of defaultFCB

@CBR_TextAlign(32) Matching the topand bottom when

arranging characterlines

@CBR_PrinterANK_Size(32)

Size of ANKcharacter

@SQL_CLI (16) Set database linkagesoftware

@SequeLink_Inf(16) Set the SequeLinkinformation file

@ODBC_Inf (16) Set the ODBCinformation file

Entry information

Subprogram-name DLL-file-name Secondary-entry-point-name

Subprogram-name

Subprogram-name2 Subprogram-name

Windows 95 and Windows NT can have run-time environmentinformation as environment variables, you can set up COBOLenvironment variable information directly in the userenvironment variables.

122 Chapter 5. Executing Programs

Windows NT can also use COBOL run-time environment

variables and user environment variables for COBOL executionwith the initialization file and the Run-time Environment Setupwindow. Information in the initialization file is reflected in user’senvironment variables upon execution of a COBOL program,then reset when the program ends.

How to Set Run-time Environment Information

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 146/783

Run-time environment information can be set as follows:

• By editing AUTOEXEC.BAT with a text editor. (Windows 95)or from the System control panel. (Windows NT)

• From the command prompt in the same manner as normal

environment variables. (32)• In the initialization file.

• In the Run-time Environment Setup window.

• From the command line.

If run-time environment information is duplicated, precedence is

given in the following order:1. Run-time Environment Setup window

2. Command line

3. Initialization file

4. Command prompt (32)

5. AUTOEXEC.BAT/ System of Control Panel (Windows NT)

Chapter 5. Executing Programs 123

Setting in AUTOEXEC.BAT (Windows 95)

Environment variables can be set when the operating systemstarts by editing AUTOEXEC.BAT. Each variable is set on aseparate line by entering:

environment-variable=value

Where the environment-variable is one of the strings from theprevious table and value is the value to be set

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 147/783

previous table, and value is the value to be set.

Setting from the Control Panel (Windows NT)

Set environment variables common to multiple applications bythe Control Panel before execution. For details about setting fromthe Control Panel, refer to the online help.

Setting from the Command Prompt (32)

Use the SET command to set environment variables from theCommand Prompt before executing programs.

A batch file can also be used. Environment information set hereis effective only within the specific command prompt sessionused.

Setting in the Initialization File

Use an initialization file to set application-specific informationrequired every time you run an application.

Create the initialization file in the directory containing theprograms using the file name "COBOL85.CBR." If any other filename is given, you must enter the initialization file name in thecommand line upon execution.

124 Chapter 5. Executing Programs

The contents of the initialization file can be modified with an

editor or by saving the contents set in the Run-time EnvironmentSetup window. Programs can be executed even if no initializationfile is available.

Contents of the Initialization File

There are two types of sections in initialization files, one forsetting environment variable information, and the other for entry

information. The section is identified by using a section nameenclosed in brackets ("[ ]") A section continues until the next

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 148/783

enclosed in brackets ( [ ] ). A section continues until the nextsection name is found.

The format of the initialization file is shown below:

[program-name] ...(1)run-time environment information = ...(2)entered contents

[program-name.ENTRY] ...(3)run-time environment information = ...(4)entered contents

1) Section name of run-time environment information:This indicates the start of environment variable information.Set the name of the program to execute as the section name ofenvironment variable information. Run-time environmentinformation set in the section is effective for the programdefined as the section name as well as for programs calledfrom the defined program.

2) Environment variable information:This defines environment variable information. For theformat of each environment variable information, see

“Environment Variables Information.” Only one environmentvariable can be defined on each line.

3) Entry information section name:This indicates the start of entry information. Define theprogram name plus ".ENTRY" as the section name of entryinformation.

Chapter 5. Executing Programs 125

4) Entry information:

This defines entry information. For the format of each entryinformation, see “Entry Information.” Only one entry can bedefined on a single line.

Entry Example of the Initialization File

 [PROG1]@EnvSetWindow=USE@CnslWinSize=(80,24)

@CnslBufLine=100@WinCloseMsg=ON@ CO 85

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 149/783

@IconName=COB85EXE

[PROG1.ENTRY]SUB1=SUB1.DLLENTRY1=PROG1

Do not insert any spaces between the brackets and section name.

Saving the information set in the Run-time Environment Setupwindow modifies the contents of the initialization file.

Setting in the Run-time Environment Setup Window

Setting run-time environment information in the Run-timeEnvironment Setup window allows you to easily change

information for every test. See “Run-time Environment SetupWindow”.

If the information is not saved in the initialization file, the run-time environment information set in the Run-time EnvironmentSetup window is only effective for that execution of the program.

Setting from the Command Line

This approach specifies run-time environment information asarguments of a command when starting a program from thecommand prompt. You can specify the run-time parameter in theGS-series (M-host) format (run-time environment information

126 Chapter 5. Executing Programs

name @MGPRM), initialization file, and run-time options (run-

time environment information name @GOPT).The format is shown below:

executable-file-name [run-time parameter] [-CBR initialization file-name] [-CBL run-time option]

-CBR and -CBL can be in any order.

Specifying the Run-time Parameter in the GS-series Format

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 150/783

The first argument following the command name is the GS-seriesformat run-time parameter. For example:

PROG1.EXE "ABCDE"

ABCDE is specified as the GS-series format run-time parameter.

Note: This method is applicable only to users of the GS-series.

Specifying the Initialization File Name

• When COBOL is the main program

Specify the initialization file following identifier -CBR or/CBR.

• When C is the main program

Call the following function immediately after JMPCINT2 iscalled:

int JMPCINTC (int 0, void &param)

Chapter 5. Executing Programs 127

(*1) Pointer to a NULL terminated string containing the

initialization file name including path name (may be omitted).The maximum length of the string which can be specified is 127

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 151/783

g g pcharacters (including the terminator).

 JMPCINTC return value Meaning 0 Normal termination-1 Insufficient work area / Non-call of JMPCINT2

/ Specified mistake of function code.1 Multiple calls: i.e. JMPCINTC was called after it

had already been called. The effectiveinitialization file name is that specified in thefirst execution of JMPCINTC.

• When Visual Basic is the main program

Make the declarations described below.Call JMPCINTB immediately after the call to JMPCINT2.

Description in DECLARE phrase:

Private Declare Sub JMPCINT2 Lib "F3BIPRCT.DLL" ()Private Declare Sub JMPCINT3 Lib "F3BIPRCT.DLL" ()Private Declare Function Sub JMPCINTB Lib "F3BIPRCT.DLL"(*)Alias "JMPCINTB@8" (ByVal a As Long, ByVal D As String) As long

(*) Note this line is continued in the next line, and is actuallyonly a single line.

Example of calling JMPCINTB:

Static DATA As String * 14Dim ans As Long

Data = "c:\test.cbr" & chr(0)ans = JMPCINTB(0, DATA)

128 Chapter 5. Executing Programs

Where the meaning of the arguments and return value of

 JMPCINTB are as follows. JMPCINTB argument value Meaning First argument value Function code. (Change of CBR name,

0 is set.)Second argument value Add Initialization file name string

(Chr(0) terminator) for execution. Themaximum length of the string whichcan be specified Is 127 characters

(including the terminator).

JMPCINTB l M i

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 152/783

 JMPCINTB return value Meaning 0 Normal termination-1 Insufficient work area / Non-call of

 JMPCINT2 / Specified mistake offunction code.

1 Multiple calls: i.e. JMPCINTB was

called after it had already been called.The effective initialization file name isthat specified in the first execution of JMPCINTB.

Do not call JMPCINT2 / JMPCINT3 / JMPCINTC / JMPCINTBmore than once in the same application. Behavior cannot beguaranteed on second and subsequent calls.

Specifying Run-time Options in the Command Line

Run-time options are specified following identifier -CBL or/CBL. For the format of the run-time options, see “Format ofRun-time Options.” For example:

PROG1.EXE -CBL r20 c20

r20 and c20 are specified as run-time options.

Chapter 5. Executing Programs 129

Format of Run-time EnvironmentInformation

This section describes the format of run-time environmentinformation. The parameters for some fields can be case-sensitive

so be sure to enter values for the parameters as shown.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 153/783

Environment Variables

The following table lists environment variable information. Thenumbers refer to the detailed descriptions that follow the table.

Table 10. Environment Variable Information

Function Environment VariableInformation

No.

Environment Variables Related to Run-time OptionsSet run-time options @GOPT 1Set the GS-series format run-time parameter @MGPRM 2Environment variables related to windows

Set the DLL-name of an icon resourceSet the identifier of an icon resourceSet the size of the logical screen for screen handlingSet the size of the console windowSet the buffer count for the console window

@IconDLL@IconName@ScrnSize@CnslWinSize@CnslBufLine

34578

Environment variables related to messagesSet the message output fileSet a display message when the window closesSet to suppress run-time messages

@MessOutFile@WinCloseMsg@NoMessage

6920

Environment variables related to fontsSet the console window fontSet the font used for screen handlingSet the font used for print files

@CnslFont@ScrnFont@PrinterFontName

121314

130 Chapter 5. Executing Programs

Table 10. Environment Variable Information (cont.)

Function Environment VariableInformation

No.

Environment variables related to files / related to SQLSet exclusive control of filesSet the logical destination definition fileSet the entry information file (32)Set the file used by the program

Set the input file for the ACCEPT/DISPLAY functionSet the output file for the ACCEPT/DISPLAY functionSet the directory containing form overlay patterns

@AllFileExclusive@CBR_CIINF@CBR_ENTRYFILEFile-identifier

SYSIN-access-nameSYSOUT-access-nameFOVLDIR

11171826

282932

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 154/783

Set the directory containing form overlay patternsSet the extension of the form overlay pattern fileSet the format of the form overlay pattern file

FOVLDIROVD_SUFFIXFOVLTYPE

323334

Environment variables related to presentation filesSet the connected product name used from thepresentation file (by destination)

Set the information file used by the programSet the connected product name used from thepresentation file (by file)

@CBR_PSFILE_xxx

File-identifierFile-identifier

19

2727

Environment variables related to printingSpecify method of calculating character arrangementcoordinates (32)Specify alignment of print characters with either top orbottom of line (32)Specify paper size (32)

Specify default FCB nameSpecify ANK character size (32)

@CBR_PrintTextPosition

@CBR_TextAlign

@PRN_FormName_xxx

@DefaultFCB_Name@CBR_PrinterANK_Size

21

22

23

2425

Environment variables related to databaseSet the ODBC information fileSet the database type linkages software(16)

@ODBC_Inf@SQL_CLI

1516

Other environment variablesSet if the Run-time Environment Setup window is usedSet the function key for screen handlingSet FCB control statements

@EnvSetWindowTERMINATORFCBxxxx

103031

Chapter 5. Executing Programs 131

1 @GOPT (Set Run-time Options)

@GOPT= list of run-time options

Specify run-time options as a list of run-time options. For theformat of the run-time options, see “Format of Run-timeOptions.” For example:

@GOPT=r20 c20

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 155/783

2 @MGPRM (Set the GS-series Format Run-time Parameter)

@MGPRM= "string of run-time parameter"

Specify a string passed from the program in quotation marks (").The specified string is passed to other programs in the samemanner as the program is executed on the system of the GS-Series.

For more information about the GS-Series format run-timeparameter, see Appendix I, ”GS-series Function Comparison.”For example:

@MGPRM="A2042CDE"

3 @IconDLL (Set the DLL name of an Icon Resource)

@IconDLL= DLL-name of icon resource

Specify the DLL name of an icon resource if no icon resource isincluded in the executable file. For using an icon provided byCOBOL85, also set the following file:

- F3BIICON.DLL

132 Chapter 5. Executing Programs

4 @IconName (Set the Identifier of an Icon Resource)

@IconName= icon resource identifier

Specify the identifier of an icon resource when changing the icon.COBOL85 provides "COB85EXE". SDK is required when youcreate icons.

5 @ScrnSize (Set the Size of the Logical Screen for Screen Handling)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 156/783

@ScrnSize=[{(columns, lineage) | (80, 24)}]

Specify the logical screen size of the window used by the screenhandling function. Specify columns and lineage in the rangefrom 1 to 999. If (columns + 1) * lineage exceeds 16250, an erroroccurs upon execution of the program.

6 @MessOutFile (Set the Message Output File)

@MessOutFile= file-name

Specify the name of the file containing the contents displayed inthe message box as file name. When a file name is specified, nomessage box is displayed.

7 @CnslWinSize (Set the Size of the Console Window)

@CnslWinSize=[{(columns, lineage) | (80, 24)}]

Specify the size of the console window used for theACCEPT/DISPLAY function. Specify the number of columnsand lines in the range from 1 to 999. The minimum andmaximum values of the window size are the system values. If a

Chapter 5. Executing Programs 133

value outside the system value range is specified, it is adjusted to

the system minimum or maximum value.

8 @CnslBufLine (Set the Buffer Count for the Console Window)

@CnslBufLine=[{buffer-lines | 100}]

Specify the number of buffers for the console window used by

the ACCEPT/DISPLAY function. Specify buffer lines in therange from 1 to 9999.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 157/783

If (console window columns + 1) * (buffer lines) exceeds 65000,the specified value is decreased. For example, buffer-lines can beup to 802 when the console window columns is 80; and 706 when91.

9 @WinCloseMsg (Set a Display Message When the Window Close)

@WinCloseMsg={ON | OFF}

Specify whether a confirmation message is displayed (ON) or not(OFF) when the console window used by the

ACCEPT/DISPLAY function or the window used by the screenhandling function closes.

10 @EnvSetWindow (Set if Run-time Environment Setup Window isUsed)

@EnvSetWindow=[{USE | UNUSE}]

Specify whether the Run-time Environment Setup window isdisplayed (USE) or not (UNUSE) when a program is executed. Tochange to USE once UNUSE is set, modify the contents of theinitialization file.

134 Chapter 5. Executing Programs

11 @AllFileExclusive (Set Exclusive Control of Files)

@AllFileExclusive={YES | NO}

Specify whether all files are exclusively controlled (YES) or not(NO) when a program is executed. When YES is selected, filesused by the program cannot be accessed from any other program(open error). File exclusive control can reduce file access time.

12 @CnslFont (Set the Console Window Font)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 158/783

@CnslFont= (font-name, font-size)

Specify the font of the console window used for theACCEPT/DISPLAY function.

13 @ScrnFont (Set the Font Used for Screen Handling)

@ScrnFont= (font-name, font-size)

Specify the font used for screen handling.

14 @PrinterFontName (Set the Font Used for Print Files)

@PrinterFontName= (Minchou-font-name, Gothic-font-name)

Specify the font used for print files.

Specify the printer font name using up to 32 single-bytealphanumeric characters.

• Spaces before and after the printer font name are included inthe printer font name.

− Minchou font name: Specify the font name used forprinting the data item that is specified MINCHOU or

Chapter 5. Executing Programs 135

MINCHOU-HANKAKU font in a PRINTING MODE

clause. If omitted, "CourierNew" is assumed.− Gothic font name: Specify the font name used for printing

the data item that is specified G, GOTHIC or GOTHIC-HANKAKU font in a PRINTING MODE clause. Ifomitted, "CourierNew" is assumed.

15 @ODBC_Inf (Set the ODBC Information File)

@ODBC Inf= ODBC information file name

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 159/783

@ODBC_Inf= ODBC-information-file-name

Specify the name of the file containing information required bythe run-time system to use ODBC. Information in this file ismainly used to connect the client and server (with the

CONNECT statement).

16 @SQL_CLI (Set the Type of Database Linkage Software) (16)

@SQL_CLI= database-linkage-software-name

Specify the linkage software name.

• RDB2 When the linkage software is RDBII Esql-COBOL

This environment variable is used only when “RDBII Esql-COBOL” is specified as

the database access mode. (It is specified either at installation or within P-STAFF).

136 Chapter 5. Executing Programs

17 @CBR_CIINF (Set the Logical Destination Definition File)

@CBR_CIINF= definition-file-name

Specify the name of the file containing the logical destinationdefinition when using the simplified inter-applicationcommunication facility.

18 @CBR_ENTRYFILE (Set the Entry Information File) (32)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 160/783

@CBR_ENTRYFILE= entry information file-name

To specify entry information other than the entry descriptionsection of the initialization file (COBOL85.CBR) create an entry

information file and specify it in the run-time environment@CBR_ENTRYFILE entry. See “Entry Information.”

The order of precedence for entry information is as follows:

1. Specification in the Run-time Environment Setup window.

2. Specification in the initialization file.

3. Specification in the entry information file.

19 @CBR_PSFILE_xxx (Set the Connected Product Name Used fromthe Presentation File (by Destination))

@CBR_PSFILE_xxx= connected-product-name

For xxx, specify the destination name described in theSYMBOLIC DESTINATION clause of the presentation file. xxxcan be one of the following: DSP/PRT/ACM/APL.

Chapter 5. Executing Programs 137

For the connected-product-name enter a string indicating the

associated product name to be used. The following table showsthe strings that can be specified.

Table 11. Supported @CBR_PSFILE strings

Specification inSYMBOLICDESTINATION Clause

Product Used String Specified

DSP or SYMBOLIC

DESTINATION clause may

FORM RTS MEFT or omitted

be omitted MeFt/NET MEFTNETPRT FORM RTS MEFT or omitted

MeFt/NET MEFTNET

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 161/783

MeFt/NET MEFTNETACM BS*NET ACM

RDB/7000Server for Windows NT

ACM

APL IDCM IDCM or omitted

If a connected product name is specified as a file identifier in thepresentation file (refer to No. 26), the specified connected productname is not effective.

If no connected product name is specified in the run-timeenvironment information and "ACM" is specified, an errormessage is displayed during execution.

If the SYMBOLIC DESTINATION clause is omitted, alwaysspecify "DSP."

20 @NoMessage (Set to Suppress Run-time Messages)

@NoMessage= YES

Suppresses the following run-time messages:

• Run-time messages other than U level

• Run-time messages not requiring operator response

138 Chapter 5. Executing Programs

To suppress the message displayed when the window closes,

specify "@WinCloseMsg=OFF" (refer to No. 9).

21 @CBR_PrintTextPosition (Specify method of calculating character arrangement coordinates) (32)

  TYPE1@CBR_PrintTextPosition=

  TYPE2

Specify the method of calculating coordinates (x,y) for arrangingprinted characters when the FORMAT clause is omitted from the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 162/783

pfile control entry.

An effective range of this specification is in the execution unit.

You specify whether (TYPE2) or not (TYPE1) to correct the

character arrangement coordinates.

• TYPE1

The x coordinate is calculated by dividing the DPI (dots perinch) by the CPI (characters per inch) and then multiplyingthe remainder (which is rounded down) by the line number.The y coordinate is calculated by dividing the DPI by the LPI

(lines per inch) and then multiplying the remainder (which isrounded down) by the line number. Note: Errors caused byrounding down the remainder may cause thePrintTextPosition to shift.

• TYPE2

The x coordinate is calculated by multiplying the line number

by a defined constant, then dividing by the CPI, thenmultiplying by the DPI and then dividing the remainder bythe defined constant. The y coordinate is calculated bymultiplying the line number by a defined constant, thendividing by the LPI, then multiplying by the DPI, and thendividing the remainder by the defined constant. Note: As

Chapter 5. Executing Programs 139

with TYPE1, the remainder is rounded down. However, in

this case, the error is corrected every one inch and actualPrintTextPosition does not shift.

22 @CBR_TextAlign (Specify alignment of print characters with either top or bottom of line) (32)

  TOP

@CBR_TextAlign=  BOTTOM

Specify the alignment of print characters in a line when the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 163/783

p y g pFORMAT clause is omitted from the file control entry. When theprinter line height is greater than the character height, you canspecify alignment of the printed characters to the top of the lineor the bottom of the line.

23 @PRN_FormName_xxx (Specification of paper size) (32)

Dynamically specify the paper size to be used at run-time whenthe FORMAT clause is omitted from the file control entry and theI control record is used for printing (refer to “Using Print File 2”

in Chapter 8). In the I control record, the FSIZE field is set to auser-defined string of three characters or less. The user-definedstring replaces "XXX".

Environment variable @PRN_FormName_xxx is set equal to thestring that defines the paper size. The values for the paper sizestrings are found in the Windows system printer defaults.

 Windows 95:Use the information in the Paper tab of the printer Propertiesdialog box to obtain paper sizes. Click on the Start button andselect SettingsàPrinters. Highlight the target printer and selectProperties from the File menu. Available paper sizes are shown

140 Chapter 5. Executing Programs

as icons. Click on an icon to display the specifications (following

Paper Size).The following figure shows the printer Properties dialog box.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 164/783

Figure 47. A Windows 95 printer Properties dialog box

 Windows NT:

Use the information in the Forms dialog box to obtain papersizes. Activate Print Manager and select Forms from the Printermenu. Available paper sizes are listed in the Forms on this

Chapter 5. Executing Programs 141

Computer list box. Click on a paper size and the specifications

are displayed in the [Form Description] Name edit box.Note: The range of support differs between printers. Be sure toconfirm that the paper size is supported by the target printerdriver.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 165/783

Figure 48. Windows NT Forms dialog box

For example:

Specification of SIZE field on I control record: ABC

Environment variable name after xxx is substituted:@PRN_FormName_ABC

Association of environment variable name and paper size:

@PRN_FormName_ABC=Letter 8 ½ x 11 in

24 @DefaultFCB_Name (Specification of default FCB name)

@DefaultFCB_Name=Default FCB name

142 Chapter 5. Executing Programs

Specify the default FCB name to be used when the FCB name is

set to spaces in the I control record. The example belowdemonstrates setting the default FCB name to "6LPI" which has aline interval of 6 lines per inch, 66 lines per page, starts printingat line 1, and is 11 inches long. The default FCB name in thisexample is "FCB6LPI".

For example:

 @DefaultFCB_Name=FCB6LPI

 FCB6LPI=LPI((6,66)),CH1(1),SIZE(110) (*1) FCB8LPI=LPI((8,88)),CH1(1),SIZE(110) FCBA4LD=LPI((12)),CH1(1),FORM(A4,LAND) (*1)

(*1) Other FCB names are accessed by using the FCB field in the I

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 166/783

(*1) Other FCB names are accessed by using the FCB field in the Icontrol record. Refer to “Using Print File 2” in Chapter 8 foradditional details.

25 @CBR_PrinterANK_Size (Specification of ANK character size) (32)

  TYPE-M@CBR_PrinterANK_Size= TYPE-PC  TYPE-G

Specify the ANK character size in the cases where the following

are NOT defined in the program:• CHARACTER TYPE phrase

• PRINTING POSITION phrase

• print file FORMAT clause

Settings are:

• TYPE-M : Default ANK character size is brought close to thesize in the GS-series. Print size is 9.6 points.

• TYPE-PC : Default ANK character size is assumed to be a PCstandard size. Print size is 10.5 points.

Chapter 5. Executing Programs 143

• TYPE-G : Default ANK character size is brought close to the

size in the SX/G-series. Print size is 10.8 points.If this environment variable is omitted, the print size is 7.0points.

26 File identifier (Set the File Used by the Program)

File-identifier= file-name [,access-type or file-system-type]

Specify the file identifier entered in the ASSIGN clause of theCOBOL source program as the file identifier, and the name of thef l b d f l

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 167/783

file to be processed as file name.

This environment variable assigns the file in the program withthe file to be processed. Specify run-time environment

information in uppercase letters even if the file identifier wasdefined in lowercase letters in the program.

For example:

• Description of the ASSIGN clause in the COBOL sourceprogram

ASSIGN TO OUTFILE

• Name of file processed

F:\WORK.DAT

• Run-time environment information

OUTFILE=F:\WORK.DAT

Access type or file system type can be the following stringsdepending on the type used.

• BSAM: Provides fast file processing

• RDM: Processes the RDM file(RDB/7000 Server for Windows NT)

144 Chapter 5. Executing Programs

• BTRV: Processes the Btrieve file

27 File Identifier (Set the Information File Used by the Program)(Set the Connected Product Name Used from the Presentation File(by File))

File-identifier= [information-file-name] [,connected-product-name]

Specify the file identifier entered in the ASSIGN clause of theCOBOL source program. When using FORM RTS, specify theFORM RTS window information file name or printer information

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 168/783

file name used as data file name.

Specify a string indicating the connected product name actuallyused as the connected product name (refer to No. 20). If omitted,

the value specified in @CBR_PSFILE_xxx is effective. If theconnected product name in the run-time environmentinformation is also omitted, the default destination in thepresentation file is assumed.

Specify run-time environment information in uppercase letterseven if the file identifier was entered in lowercase letters inprograms.

For example:

• Description of the ASSIGN clause in the COBOL sourceprogram

ASSIGN TO GS-DSPFILE

• SYMBOLIC DESTINATION clause

SYMBOLIC DESTINATION IS "DSP"

• Name of file data actually used

F:\WORK.WRC

• Connected product actually used

Chapter 5. Executing Programs 145

FORM RTS

• Run-time environment information

DSPFILE=F:\WORK.WRC,MEFT

28 SYSIN Access Name (Set the Input File for the ACCEPT/DISPLAYFunction)

SYSIN-access-name= file-name

Specify the environment variable name specified in the compileroption SSIN as SYSIN access name. Specify the name of the file

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 169/783

p p yused as the data input destination when the ACCEPT statementof the ACCEPT/DISPLAY function is run.

For example:

• Compiler option SSIN

SSIN(INFILE)

• Name of input file of ACCEPT statement

A:\INDATA.TXT

•Run-time environment informationINFILE=A:\INDATA.TXT

29 SYSOUT Access Name (Set the Output File for theACCEPT/DISPLAY Function)

SYSOUT-access-name= file-name

Specify the environment variable name specified in the compileroption SSOUT as SYSOUT access name. Specify the name of thefile used as the data output destination when the DISPLAYstatement of the ACCEPT/DISPLAY function is run.

146 Chapter 5. Executing Programs

For example:

• Compiler option SSOUT

SSOUT(OUTFILE)

• Name of output file of DISPLAY statement

A:\OUTDATA.TXT

• Run-time environment information

OUTFILE=A:\OUTDATA. TXT

30 TERMINATOR (Set the Function Keys for Screen Handling)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 170/783

TERMINATOR= [!] keyword [[,[!] keyword ] ... ]

Specify the PF1 to PF24 keys in keywords in the form of PFmm -PFnn (a range from mm to nn, where nn represents 01 to 24 and01 to 09 equal to 1 to 9.) "!" indicates that the function keysspecified in the keyword are disabled as input.

For example:

TERMINATOR=PF1-PF3, !PF4-PF24

31 FCBxxxx (Set FCB Control Statements)

FCBxxxx= FCB-control-statement

Specify the FCB name specified in the I control record in xxxxand an FCB control statement in FCB control statement. For theformat of the FCB control statement, refer to Appendix K, “FCBControl Statement.”

Chapter 5. Executing Programs 147

32 FOVLDIR (Set the Directory Containing Form Overlay Patterns)

FOVLDIR=directory-name

Specify the directory containing form overlay patterns by usingan absolute path name. If omitted, no form overlay patterns areprinted. Only one directory can be specified in directory name.

33 OVD_SUFFIX (Set the Extension of the Form Overlay Pattern File)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 171/783

OVD_SUFFIX= extension

Specify an extension string in extension if the default extension ofthe form overlay pattern file "OVD" is not used. When the file

name has no extension, specify "None".

34 FOVLTYPE (Set the Format of the Form Overlay Pattern File)

FOVLTYPE= format

Specify the first four characters of the form overlay pattern filename if they are not "KOL5" (default).

Entry Information

Information about program entry points is required only forprograms having dynamic program structure. Entry informationcan be placed in either:

• The initialization file for execution (COBOL85.CBR).

• A file whose name is given in the @CBR_ENTRYFILEenvironment variable.

148 Chapter 5. Executing Programs

See “Environment Variables” for details on the@CBR_ENTRYFILE variable.

Entry Information for Separately Linked Subprograms

Subprogram-name=DLL-file-name

Relates the name used in the COBOL CALL statement to thename of the DLL file containing the subprogram.

Entry statements are grouped under the tag:

[main-program.ENTRY]

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 172/783

For example:

Entry Information for Secondary Entry Points

When a subprogram contains multiple entry points, thesecondary entry points need to be associated with the primaryentry point. The format is:

Secondary-entry-name=Primary-entry-name

The secondary-entry-name is the name defined in the ENTRYstatement of the COBOL source program. The primary-entry-name is the name defined in the PROGRAM-ID paragraph.

Chapter 5. Executing Programs 149

For example:

If i f i i ifi d h dd h

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 173/783

If entry information is not specified, the system adds theextension DLL to the program name specified in the CALLstatement as the DLL file name.

Entry Information for Subprograms Linked in the Same DLL

When subprograms are linked together in a single DLL, the firstprogram name is mapped to the DLL file name (as documentedabove), and the subsequent programs are mapped to the firstprogram. The format is:

Sub-program-name-2=Sub-program-name

Where sub-program-name is the PROGRAM-ID name of the firstprogram in the DLL, and sub-program-name-2 is thePROGRAM-ID name of a subsequent program linked in thesame DLL.

150 Chapter 5. Executing Programs

For example:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 174/783

Notes on Canceling Subprograms:

The DLL containing the program that is the target of theCANCEL statement is deleted from the virtual memory space.

In the above example, if any of B1,B2, or B3 is specified in theCANCEL statement, B.DLL is deleted from the virtual memoryspace.

Note: Files opened in subprograms may not be closed if thesubprogram is not explicitly canceled (CANCEL). In thesecircumstances you must make sure your programs close theaffected files before a CANCEL is performed. The following threeexamples illustrate this concept.

Chapter 5. Executing Programs 151

Example 1: When a canceled subprogram does a static call.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 175/783

Example 2: When a canceled subprogram is in a DLL containing

other subprograms.

152 Chapter 5. Executing Programs

Example 3: When a canceled subprogram does a dynamic call.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 176/783

WINEXEC

WINEXEC is used for program execution. This section describesthe WINEXEC window. For further details on how to use thewindow, refer to the online help.

Activating the WINEXEC Window (32)

In P-STAFF, select WINEXEC from the Tools menu to activatethe WINEXEC Window.

Chapter 5. Executing Programs 153

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 177/783

Figure 49. The WINEXEC window

The WINEXEC window contains the following elements:

Help

Access the P-STAFF online help.

Command Line edit boxSpecify the name of the file to be executed.

Browse button

Click to select a file to be included in the link.

List list box

Displays a list of the most recently executed programs.

Delete button

Click to remove the selected file(s) from the List.

154 Chapter 5. Executing Programs

OK button

Click to start execution and close the WINEXEC window.

Cancel button

Click to close the WINEXEC window without performing anexecution.

Execute button

Click to start execution, and keep the WINEXEC windowopen for further execution.

Activating the WINEXEC Window (16)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 178/783

Activate the WINEXEC window for Windows 3.1 by one of the

following methods:• Select WINEXEC from the Utilities menu of P-STAFF.

• Select WINEXEC.EXE in the File Manager directory window.

• Define WINEXEC.EXE as an icon, then double-click on theicon.

Select the Execute command from Program Manager or FileManager, then enter the WINEXEC command in the propercommand form.

The following sections describe how to use the WINEXECwindow.

Entering a File Name

Enter the name of the file to execute in the Command Line editbox using either of the following methods:

• Enter or use the Browse button to select the name of the file toexecute.

Chapter 5. Executing Programs 155

• Select the name of the file to execute from the List to re-execute a program that was already executed.

The List displays up to the last ten files that were executed.

Starting and Quitting Execution

To start execution, click on the Execute button. After execution

starts, the system may display the Run-time Environment Setupwindow for COBOL programs. Set information where necessary.

For details about setting run-time environment information, see“Run-time Environment Setup Window (16).”

Aft ti i l t d li k th C l b tt i th

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 179/783

After execution is completed, click on the Cancel button in theWINEXEC window to close the window.

Run-time Environment Setup Window (32)

The Run-time Environment Setup window is used to set run-time environment information that is displayed when a COBOLprogram is executed. The Run-time Environment Setup window

displays run-time environment information defined in theinitialization file as initial values.

Information set in the Run-time Environment Setup window canalso be saved in the initialization file. To prevent display of theRun-time Environment Setup window at run-time, define"@EnvSetWindow=UNUSE" in the initialization file.

Note: "UNUSE" must be in upper case.

156 Chapter 5. Executing Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 180/783

Figure 50. The Run-time Environment Setup window (32)

The Run-time Environment Setup window contains the followingelements:

Command

Provides the functions available on the Set, Delete, Save andOK buttons, and the option to configure the Console, Screenand Printer fonts.

Section Selection

Switches the display between environment variables andentry information.

Environment Setup

Provides access to lists of the current environment variables,COBOL environment variables and printer names. Valuescan be selected from these lists for inclusion in theEnvironment Variables Information.

Chapter 5. Executing Programs 157

Help

Access the online help.Environment Variables Information edit box

Information is entered and edited in this box then set into thelist of environment variables to be used for this execution.

List list box

Displays the environment variables that will be used in thisexecution.

Set button

Click to register the contents of the edit box in the List.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 181/783

Delete button

Click to remove the currently selected item(s) from the List.

Save button

Click to save the information in the List to the initializationfile (COBOL85.CBR) for use in multiple executions.

OK button

Click to continue execution.

Cancel button

Click to discontinue execution.

158 Chapter 5. Executing Programs

Setting Environment Variable Information

Environment information is set using the Environment VariablesInformation edit box of the Run-time Environment Setupwindow.

Adding Environment Variable Information

To add specified or new environment variables, use theprocedures that follow.

Adding Currently Set Environment Variables

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 182/783

g y

1. Select Environment Variables from the Environment Setupmenu in the Run-time Environment Setup window. TheEnvironment Variables List dialog box is displayed.

 

Figure 51. The Environment Variables List dialog box

2. Select the environment variable to add from the list box, thenclick on the Selection button. The selected variable isdisplayed in the Environment Variables Information edit box.

3. If necessary, modify the contents of the selected variable.

Chapter 5. Executing Programs 159

4. Click on the Set button. The changed information is added tothe Environment Variables Information list box.

Adding New Environment Variables

1. Select Keyword from the Environment Setup menu in theRun-time Environment Setup window. The COBOLEnvironment Variables (Keywords) dialog box is displayed.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 183/783

Figure 52. The COBOL Environment Variables (Keywords) dialog box

2. Select the environment variable to add from the list box, then

click on the Selection button. The selected information isdisplayed in the Environment Variables Information edit box.

3. Complete the information required by the environmentvariable.

4. Click on the Set button. The changed information is added tothe Environment Variables Information list box.

160 Chapter 5. Executing Programs

Changing Environment Variable Information

To change the environment variable information or environmentvariables displayed in the Environment Variables Information listbox:

1. Select the environment variable information or environmentvariables to change from the list box. The selected

information is displayed in the Environment VariablesInformation edit box.

2. Change the contents.

3. Click on the Set button. The changed environment variableinformation or environment variables are displayed in the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 184/783

information or environment variables are displayed in theEnvironment Variables Information list box.

Deleting Environment Variable Information

To delete environment variable information or environmentvariables from the Environment Variables Information list box:

1. Select the environment variable information or environmentvariables to delete from the list box.

2. Click on the Delete button. The selected environment variableinformation or environment variables are deleted from thelist box.

Setting Entry Information

Select Section Information from the Section Selection menu in theRun-time Environment Setup window. The Entry Informationlist box is displayed. Enter the required entry information andadd it to the List by clicking on the Set button.

Chapter 5. Executing Programs 161

Entry information can also be set without using the Run-timeEnvironment Setup window. Create an entry information file and

specify the entry information file name in the environmentvariable @CBR_ENTRYFILE.

For the format, see “Format of Run-time EnvironmentInformation.”

Saving to the Initialization File

When the Save button is clicked, the information in the list box issaved in the initialization file. Saving in the initialization filemeans that the same run-time environment information can beused the next time the program is executed.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 185/783

Saving modifies the existing information.

Setting Printers

When using a printer, printer information can be set. SelectPrinter from the Environment Setup menu of the Run-timeEnvironment Setup window, then set required information in the

Printer Name Selection dialog box.

Figure 53. The Printer Name Selection dialog box

162 Chapter 5. Executing Programs

Exiting the Run-time Environment Setup Window

Click on the OK button to close the Run-time Environment Setupwindow and start the program. Run-time environmentinformation set in the Run-time Environment Setup window iseffective for the program only if it is not saved in theinitialization file.

Run-time Environment Setup Window (16)

The Run-time Environment Setup window is used to set run-time environment information that is displayed when a COBOL

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 186/783

program is executed. The Run-time Environment Setup windowdisplays run-time environment information defined in theinitialization file as initial values.

Contents set in the Run-time Environment Setup window canalso be saved in the initialization file.

To prevent display of the Run-time Environment Setup windowat run-time, define "@EnvSetWindow=UNUSE" in theinitialization file.

This section describes the Run-time Environment Setup window.For details on the format of defined run-time environmentinformation, see “Format of Run-time EnvironmentInformation.” For details about how to use the window, refer tothe online help.

Chapter 5. Executing Programs 163

Figure 54. The Run-time Environment Setup window (16)

You can select the operation or font from the Command menu

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 187/783

You can select the operation or font from the Command menu.The Section menu allows you to switch between environment

variable information and entry information.

Setting Environment Variable Information

Run-time environment variable information is set using theEnvironment Variables Information edit box in the Run-time

Environment Setup window.

Adding Environment Variable Information

To set environment variable information not displayed in the listbox:

1. Directly enter run-time environment information in the editbox.

2. Click on the Set button. The environment variablesinformation is added to the Environment VariablesInformation list box.

164 Chapter 5. Executing Programs

Changing Environment Variable Information

To change run-time environment information displayed in theEnvironment Variables Information list box:

1. Select the run-time environment information to change fromthe list box. The selected information is displayed in theEnvironment Variables Information edit box.

2. Change the contents.

3. Click on the Set button. The changed run-time environmentinformation is displayed in the list box.

Deleting Environment Variable Information

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 188/783

To delete run-time environment information displayed in the

Environment Variables Information list box:

1. Select the run-time environment information to delete fromthe list box .

2. Click on the Delete button. The selected run-timeenvironment information is deleted from the list box.

Setting Entry Information

Select Section Information from the Section menu in the Run-timeEnvironment Setup window. The Entry Information list box isdisplayed in the window. Select the required entry information.

Chapter 5. Executing Programs 165

Figure 55. The Run-time Environment Setup window with changed EntryInformation

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 189/783

Saving to the Initialization File

Click on the Save button to save current information (informationdisplayed in the list box) in the initialization file. Becauseinformation is saved in the initialization file, the same run-timeenvironment information can be used when executing theprogram at another time.

Saving modifies the existing information.

Exiting from the Run-time Environment Setup Window

Clicking on the Run button causes the system to close the Run-time Environment Setup window and start executing theprogram. Run-time environment information set in the Run-timeEnvironment Setup window is effective for the program only if itis not saved in the initialization file.

166 Chapter 5. Executing Programs

Format of Run-time Options

Run-time options specify information or operations to COBOLprograms at run-time.

Define run-time options depending on the functions used in theCOBOL program or the options specified when compiling theCOBOL source program. Run-time options can be entered:

• in the text editor (Windows 95)

• in the control panel system (Windows NT)

• in the initialization file

• in the Run-time Environment Setup window

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 190/783

• or from the command line

The following table lists the available functions and formats ofthe run-time options. When multiple run-time options aredefined, they must be delimited by a comma (,).

Table 12. Run-time options

Function FormatSet the number of trace data [r count]Set the process count at errordetection

[c count | noc]

Set the external switch value [s value]

[r COUNT]

Set this option to change the amount of trace informationproduced by the TRACE function. Specify the amount of trace

information in the range from 1 to 999999.This option is effective in programs defined with the -Dr optionor the compiler option TRACE during compilation.

Chapter 5. Executing Programs 167

[c COUNT | NOC]

Set this option to change the process when an error is detected bythe CHECK function. Specify the process count in the range from9 to 999999.

A value of 0 assumes no limit. A value of noc suppresses theCHECK function.

This option is effective only in the program defined with the -Dk

option or the compiler option CHECK during compilation.[s VALUE]

Set this option to set a value for external SWITCH-0 to SWITCH-7, specified in the SPECIAL-NAMES paragraph in the COBOLprogram. Enter eight consecutive switch values from SWITCH-0sequentially

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 191/783

sequentially.

The values can be 0 or 1. If omitted, "S00000000" is assumed.

SWITCH-8 is equivalent to SWITCH-0. When SWITCH-8 is used,therefore, the switch values correspond to SWITCH-8, SWITCH-1to SWITCH-7 from the left.

168 Chapter 5. Executing Programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 192/783

Chapter 6. Project Management

This chapter describes the project management function, detailsresources needed for the function, and explains procedures forusing it. Additionally, this chapter describes the project window.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 193/783

170  Chapter 6. Project Management Function

What is the Project Management Function?

This section outlines the project management function.

PROGRAMMING-STAFF provides a project managementfunction for COBOL85 application development andmaintenance. The project management function manages target

COBOL85 applications consisting of multiple files (COBOLsource programs and libraries) as a single project.

Information on dependent files is stored in the project file, andthe compiler and linker options are saved in the option file. If theproject file or option file managed under the project is updated,the project management function can automatically recompile

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 194/783

p j g y p

and relink files dependent on the updated file. This operation iscalled "building" or "making".

The project manager can also recompile and relink all programsregistered in the project to renew applications, called"rebuilding".

Use the project management function:

• To process all steps from compilation to execution of aprogram in one operation

• To call a subprogram or use a program library

Sample programs using the project management function areprovided with COBOL85. For compiling, linking, and executingsample programs using the project management function, refer

to “Getting Started with Fujitsu COBOL.”

Chapter 6. Project Management Function 171

Resources Required for ProjectManagement

Project management uses the following files:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 195/783

Figure 56. Files used by the Project Management function

172  Chapter 6. Project Management Function

Table 13. Files used by the Project Management function

File Contents File NameFormat

I/O Condition to Use or Create

1 Information forproject management- Dependent files

project-name.PRJ

I Information saved in the project file isreferenced for building or rebuilding

- Target-names- Source-file-names- Library-names

- Other-required file-  names

O This file must be created for projectmanagement

2 Compiler options project-name.CBI

I Used to compile source programsduring building or rebuilding

O Created when compiler options are setby project management

3 Linker options project-name.LNI

I Used to link object programs duringbuilding or rebuilding

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 196/783

name.LNI building or rebuilding

O Created automatically for projectmanagement4 COBOL source

programoptional-name.COB

I Used to compile source programsduring building or rebuilding

5 Library text library-text-name.CBL

I Used to compile source programsduring building or rebuilding

6 Standard libraries(object code libraries)

optional-name.LIB

I Used to link object programs duringbuilding or rebuilding

7 Module definition

statement (requiredfor subprograms )

target-

name.DEF

I Required to link during building or

rebuilding

Required to create the import library orDLL during building or rebuilding

O Created automatically if omitted8 Object program source-file-

name.OBJI Used to link object programs during

building or rebuildingO Created when source programs are

compiled successfully

Chapter 6. Project Management Function 173

Table 13. Files used by the Project Management function (cont.)

File Contents File NameFormat

I/O Condition to Use or Create

9 Import library target-name.LIB I Used to create an executable file savingthe dynamic link structure

O Created when building or rebuilding10 Dynamic link

library(DLL)target-name.DLL

I Used to create an executable programwith a dynamic link structure

O Created when building or rebuilding

11 Executable program target-name.EXE

O Created when building or rebuilding

Project Management Procedures

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 197/783

This section describes the procedures for project management.1. Select Open from the Project menu in the P-STAFF window.

The Open Project dialog box is displayed.

2. Enter the project file name. See “Creating the Project File.” Tocreate a new project file, the Target Files dialog box isdisplayed. If an existing project file is opened, the Projectwindow appears. To change project information, select abutton in the Project window. See “Project Window.”

3. Register the target file name to be created by the project thenclick on the OK button. See “Registering Target Files.” TheDependent Files dialog box is displayed.

4. Register a source program managed under the project. See“Registering Source Files.”

5. Select the main program from source programs registered inStep 4. See “Setting the Main Program.” If you are creating aDLL, do not select a main program.

6. Register libraries. See “Registering Library Files.”

174  Chapter 6. Project Management Function

7. Register any other required files. See “Registering OtherRequired Files.”

8. End registration. After all registration has been completed,click on the OK button in the Dependent Files dialog box.Registered file names are displayed in the Project window.

9. Set compiler options. See “Setting Compiler Options.”

10. Set linker options. See “Setting Linker Options.”

11. Build or rebuild the project. See “Building and Rebuilding theProject.”

12. If an error is detected, modify the file contents. The contentsof the files registered to a program (COBOL source programs,library text, and module definition statements) can bemodified by using an editor. Double-clicking on a file namedisplayed in the Project window opens the P STAFF editor

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 198/783

displayed in the Project window opens the P-STAFF editor

edit screen. See “Modifying File Contents.”

13. Execute the program. Click on the Execute button to executethe created application program from the Project window.See “Executing Application Programs.”

Chapter 6. Project Management Function 175

Project Window

The Project window is displayed when the project file is opened.In the Project window, you can:

• Edit the project file (Register files, set compiler options, andset linker options)

• Build and rebuild the project

• Edit registered files

• Execute created application programs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 199/783

Figure 57. The Project window

File names registered in the project are displayed. Each file ismarked with a small icon that indicates its designated category.

176  Chapter 6. Project Management Function

The Project Window contains the following elements:

Files buttonEdit the dependent files list.

Compiler Options button

Display, enter and edit the compiler options.

Linker Options button

View and edit the linker options.Build button

Start a build of all the programs in the project.

Rebuild button

Start a rebuild of all the programs in the project.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 200/783

Execute button

Start an execution of the project program.

Creating the Project File

The project file registers information for project management.One project file is required per project. To create the project file:

1. Start P-STAFF. The P-STAFF window is displayed.

2. Select Open from the Project menu. The Open Project dialogbox is displayed.

3. Enter the name of project file in the File Name edit box.

4. Click on the OK button. The project file is created. Aftercreation, the Target Files dialog box automatically appears toenter the target name. After creating the project file, registerthe files.

Set project-name.PRJ as the project file name.

Chapter 6. Project Management Function 177

Registering Files

For project management, files managed under the project mustbe registered. Information on registered files is saved in theproject file. Register the following files for the project:

• Target file

• Source files

• Library files

• Other required files

Registering Target Files

Target files are registered in the Target Files dialog box. Multiple

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 201/783

target files can be registered. To register target files:1. When a new project is created, create the project file, and the

Target Files dialog box is displayed with project-name.EXEdisplayed in the File edit box.

For an existing project file, select the Files button in theProject window. The Dependent Files dialog box is displayed.

Click on the Set button and the Target Files dialog box isdisplayed.

178  Chapter 6. Project Management Function

Figure 58. The Target Files dialog box

2. Enter a name in the File edit box and click on the Add button.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 202/783

To update, select a target name to update from the TargetFiles list box, enter the file name in the File edit box, and clickon the Update button.

3. Repeat Step 2 until all target files have been registered.

4. After all target files have been registered, click on the OKbutton. The Dependent Files dialog box is displayed.

Registering Source Files

Source files are registered in the Dependent Files dialog box. Toregister source files:

1. For a new project, click on the OK button in the Target Files

dialog box. For an existing project file, click on the Filesbutton on the Project window.

Chapter 6. Project Management Function 179

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 203/783

Figure 59. The Dependent Files dialog box

2. Select a file from Targets.

3. Click on the Browse button; the Browse Files dialog box is

displayed and you can select the source files required for thetarget.

4. Click on the OK button. The selected source file is displayedin the File edit box of the Dependent Files dialog box.

5. Click on the Add button. The selected source file is added tothe Dependent Files list box.

6. When the added source file is the main program, set the mainprogram. See “Setting the Main Program.”

7. Repeat Steps 2 to 6 for all targets.

180  Chapter 6. Project Management Function

Setting the Main Program

When the source file registered is the main program, the filemust be set as the main program. To set the main program, selectthe file to be used as the main program from the files in theDependent Files list box, then click on the Main Program button.The small icon next to the selected file turns red.

Registering Library Files

Source file libraries are registered in the Library Files dialog box.To register a library file:

1. Select the source file of the program defining the library fromthe Dependent Files list box of the Dependent Files dialog

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 204/783

box.2. Click on the Libraries button. The Library Files dialog box is

displayed.

Chapter 6. Project Management Function 181

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 205/783

Figure 60. The Library Files dialog box

3. Click on the Browse button, the Browse Files dialog box isdisplayed. Select the library required by the dependentsource file selected in Step 1.

4. Click on the OK button. The library file name is displayed inthe File edit box of the Library Files dialog box.

5. Click on the Add button. The library file name is added to theLibrary Files list box.

6. After all library files are registered, click on the OK button.The Dependent Files dialog box is redisplayed.

7. Repeat Steps 1 to 6 for all source programs using the library.

182  Chapter 6. Project Management Function

Registering Other Required Files

Other required files are registered in the Dependent Files dialogbox. The file selection process in the Dependent Files dialog boxis the same as for source files.

Register required files to the project after determining the type oflink and program structure.

The following files can be registered to the project:• Module definition file

Required when creating a DLL. See “Creating the ModuleDefinition File.”

• Object file

Obj fil d i COBOL h l b

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 206/783

Object files created in COBOL or other language can bespecified.

• Import library

An import library created by the project is required whenexecutable programs have a dynamic link structure. Theimport library must have the name DLL-name.LIB. When a

DLL is created, an import library (target-name.LIB) is created.If this file already exists, the existing file is replaced with anew one.

• Other libraries

Other libraries (excluding libraries provided by COBOL85)can be specified.

Quitting Registration

After registration is completed, click on the OK button in theDependent Files dialog box. The Dependent Files dialog box

Chapter 6. Project Management Function 183

closes; control is then returned to the project window. The Projectwindow then displays all registered files by target.

• The Project window is displayed outside the P-STAFFwindow. (32)

• The Project window is displayed inside the P-STAFF window.(16)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 207/783

Figure 61. The Project window

Setting Compiler Options

Compiler options are set before compiling source files managedunder the project. Saved compiler options are saved in the optionfile (project-name.CBI). To set compiler options:

1. Click on the Compiler Options button on the Project window.The Compiler Options dialog box is displayed. Refer to

“Compiler Options Dialog Box” in Chapter 3 for more details.

2. Set the required information.

3. Click on the OK button.

184  Chapter 6. Project Management Function

Figure 62. The Compiler Options dialog box

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 208/783

In this example, the compiler option MAIN is not effective evenwhen specified because MAIN in the main program takesprecedence.

When using libraries, always set the compiler option LIB.

The same compiler option must be set for all registered targets.

Compiler options set here are effective in the project only. Thesecompiler options are not effective when programs are compiledfrom the WINCOB window.

Chapter 6. Project Management Function 185

Setting Linker Options

Different linker option screens are provided for Windows95/Windows NT and Windows 3.1. For details on the LinkerOptions dialog box, refer to “Setting Linker Options” in Chapter4.

The linker options are saved in the option file (project-

name.LNI).1. Click on the Linker Options button on the Project window.

The Linker Options dialog box is displayed.

2. Set the required information.

3. Click on the OK button.

When the compiler option TEST is specified linker options aret ti ll t I thi li k ti f d b i d

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 209/783

When the compiler option TEST is specified, linker options areautomatically set. In this case, linker options for debugging neednot be set. (32)

Creating the Module Definition File

The module definition file can be created by building or

rebuilding the project. The procedures to follow differ dependingon whether you are using Windows 95/Windows NT andWindows 3.1.

Module Definition File (32)

The module definition file is required to create the import library.To create the module definition file templates:

1. Select Create Module-Definition Files from the Project menuin the P-STAFF window.

186  Chapter 6. Project Management Function

2. Build or rebuild the project. A module definition file havingthe DLL-name.DEF is created in the same folder as DLL and

is added to the project file.Assign the name target-name.DEF to module definition files.

The EXPORTS module definition statement in the DLL isautomatically set with the file name of the source file and objectfile depending on the target excluding their extension. If theprogram identifier differs from the file name, modify the value of

EXPORTS.

Module Definition File (16)

The module definition file used under Windows 3.1 is requiredfor linking. The template for a module definition file can becreated when using the project. To create the module definition

file:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 210/783

file:1. Select Create Module-Definition Files from the Project menu

in the P-STAFF window.

2. Select Template of Module-Definition File from the Projectmenu in the P-STAFF window.

3. Select the target as EXE or DLL. A dialog for creating

templates appears.

4. Set the required information.

5. Build or rebuild the project. A module definition filecontaining the contents specified in Step 4 and with a target-name.DEF is added to the project file.

Assign the name target-name.DEF to module definition files.The EXPORTS module definition statement in DLL isautomatically set with the file name of the source file and objectfile depending on the target excluding their extension. If the

Chapter 6. Project Management Function 187

program identifier differs from the file name, modify the value ofEXPORTS.

Building and Rebuilding the Project

You must either build or rebuild the project when any fileregistered to the project is updated, or when you changecompiler or linker options.

To build or rebuild the project, click on the Build or Rebuildbutton in the Project window. Compile errors can be corrected by jumping to the editor from the message window.

The following table lists system processing executed with Build.Rebuilding means that the system recompiles and relinks allregistered programs.

Table 14. Build processing

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 211/783

p g

Update Contents Building  COBOL source program 1) Recompile the updated program

2) Relink dependent on the updatedLibrary file 1) Recompile all programs defining the

  library2) Relink all programs dependent on the  programs recompiled in 1)

Compiler option Recompile and relink all programsLinker option Relink all programs

Modifying File Contents

Contents of files registered to programs (COBOL sourceprograms, library text, and module definition statements) can bemodified by using an editor.

To open the editor, double-click on a file name displayed in theProject window.

Refer to “Using the P-STAFF Editor” in Chapter 3.

188  Chapter 6. Project Management Function

Executing Application Programs

To execute created application programs from the Projectwindow:

1. Select an application to execute. When multiple applicationsare created, select the appropriate application from the

project window.2. When a run-time parameter is defined, select Argument at

Execution from the Project menu in the P-STAFF window,then enter the parameter in the edit box.

3. Click on the Execute button. If the program is a COBOLapplication, the Run-time Environment Setup window may

be displayed. Set the required information and startexecution Refer to “Run time Environment Setup Window”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 212/783

p y qexecution. Refer to Run-time Environment Setup Windowin Chapter 5.

Chapter 7. File Processing

This chapter explains how to read and write data files. Amongthe topics covered in Chapter 7 are file organization types, usingrecord and line sequential files, using relative and indexed files,error processing, file processing, and the COBOL85 FILEUTILITY.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 213/783

190 Chapter 7. File Processing

File Organization TypesThis section explains file organization types and characteristics,and details how to design records and process files.

File Organization Types and Characteristics

The following files can be processed by using sequential, relative,and indexed file functions:

Table 15. File types

Sequential file function Record sequential filesLine sequential filesPrint files

Relative file function Relative files

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 214/783

Indexed file function Indexed files

The following table lists the characteristics of each file.

Table 16. File organization types and characteristics

File Types Record-Sequential

File

Line-Sequential

File

Print File Relative File Indexed File

Recordprocessing

Record storage sequence Relativerecordnumber

Record keyvalue

Usable datamedium

Hard diskFloppy disk

Hard diskFloppy disk

Printer Hard diskFloppy disk

Hard diskFloppy disk

Usageexample

Saving dataWork file

Text file Printing data Work file Master file

File organization is determined when a file is generated, andcannot be changed. Before generating a file, therefore, fullyunderstand the characteristics of the file and be careful to selectthe file organization that most agrees with its use. Each fileorganization is explained below.

Chapter 7. File Processing 191

Record Sequential Files

Figure 63 Record sequential files

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 215/783

Figure 63. Record sequential files

In a record sequential file, records are read and updated in order,starting with the first record in the file.

A record sequential file is the easiest to create and maintain.Record sequential files are generally used to store data

sequentially and maintain a large amount of data.

192 Chapter 7. File Processing

Line Sequential Files

Figure 64. Line sequential files

Records can also be read from the first record in the physical

order they are placed in a line sequential file.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 216/783

Line feed characters are used as record delimiters in a linesequential file.

For example, a line sequential file can be used when handling afile created by an editor.

Print Files

A print file is used for printing with the sequential file function;there is no special file name for a print file. For details of a printfile, refer to Chapter 8, “Printing.”

Chapter 7. File Processing 193

Relative Files

Figure 65. Relative files

Records can be read and updated by specifying their relativerecord numbers (the first record is addressed by relative recordnumber 1) in a relative file.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 217/783

For example, a relative file can be used as a work file accessed byusing relative record numbers as key values.

194 Chapter 7. File Processing

Indexed Files

Figure 66. Indexed files

Records can be read and updated by specifying the values of

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 218/783

p y p y gitems (record keys) in an indexed file. Use an indexed file as amaster file when retrieving information associated with thevalues of items in a record.

Designing Records

This section explains the types and characteristics of recordformats and the record keys of indexed files.

Chapter 7. File Processing 195

Record Formats

There are two types of record formats, fixed length and variablelength.

• Fixed length record

In a fixed length record, all records in a file contain the samenumber of character positions.

• Variable length record

In a variable length record, records contain a varying numberof character positions. The record size is determined when arecord is placed in a file. Because each record can be writtenwith the required size, the variable length record format isuseful if you want to minimize the file capacity.

Record Keys of Indexed Files

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 219/783

When designing a record in an indexed file, a record key must bedetermined. Multiple record keys can be specified for an item inthe record.

There are primary record keys (primary keys) and alternaterecord keys (alternate keys). Records in the file are stored in theascending order of primary record keys.

Specifying a primary or alternate key determines which record isprocessed in the file. In addition, records can be processed inascending order, starting from any record.

To process the same file with multiple record organization,

primary keys must be at the same position and of the same sizein each record organization.

In the variable length record format, the record key must be setat a fixed position.

196 Chapter 7. File Processing

Processing Files

There are six types of file processing:

• File creation: Writes records to files.

• File extension: Writes records after the last record in a file.

• Record insertion: Writes records at arbitrary positions infiles.

• Record reference: Reads records from files.

• Record updating: Rewrites records in files.

• Record deletion: Deletes records from files.

File processing depends on the file access mode. There are threetypes of access modes:

• Sequential access: Allows serial records to be processed in afixed order.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 220/783

• Random access: Allows arbitrary records to be processed.

• Dynamic access: Allows records to be processed in sequentialand random access modes.

Chapter 7. File Processing 197

The following table indicates the processing available with eachfile type.

Table 17. File organization types and processing

File Access Processing  

Types Mode Creation Extension Insertion Reference Updating Deletion

Recordsequentialfile

Sequential o o x o o x

Linesequential

file

Sequential o o x o x x

Print file Sequential o o x x x x

Relativefile

Sequential o o x o o o

Indexedfile

Random o x o o o o

Dynamic o x o o o o

o: Can be processed. x: Cannot be processed.

Disable access by locking records in use. This is called exclusivecontrol of files. For details of exclusive control of files, see“Exclusive Control of Files.”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 221/783

Exclusive Control of Files.

198 Chapter 7. File Processing

Using Record Sequential Files

This section explains how to define record sequential files, andprocess and define records.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 222/783

Chapter 7. File Processing 199

Defining Record Sequential Files

This section explains the file definitions required to use recordsequential files in a COBOL program.

File Name and File-Reference-Identifier 

Determine file names in conformance to the rules of COBOLuser-defined words, then write them in the SELECT clause.

Determine a file-reference-identifier, then write them in theASSIGN clause. For the file-reference-identifier, specify a file-identifier, file-identifier-literal, data-name, or character stringDISK.

Use the file-reference-identifier to associate the file name

specified in the SELECT clause with the file of the actual input-output medium.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 223/783

How you associate the file name in the SELECT clause to the fileof the actual input-output medium depends on what is specifiedfor the file-reference-identifier.

The recommended method to determine what to specify for the

file-reference-identifier is:

• When the file name of the input-output medium isdetermined at COBOL program generation and is notsubsequently changed, specify a file-identifier-literal orcharacter string DISK.

• When the file name of the actual input-output medium is

undetermined at COBOL program generation, or todetermine the file name at every program execution, specify afile identifier.

200 Chapter 7. File Processing

• To determine the file name in a program, specify a dataname.

• If the file is temporary and will be unnecessary after theprogram terminates, specify character string DISK.

Files can be processed at high speed in record sequential or linesequential files. For the specification method, refer to AppendixH, “High-speed File Processing.”

The following table lists description examples of SELECT and

ASSIGN clauses.

Table 18. Description examples of SELECT and ASSIGN clauses

Type of File-Reference-Name

Description Example Remarks

File-identifier SELECT file-1ASSIGN TO INFILE

Must be related to the actualinput-output medium atprogram execution.

Data-name SELECT file-2ASSIGN TO data name

The data name must bedefined in the WORKING-STORAGE section in the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 224/783

DATA DIVISIONFile-identifier literal SELECT file-3

ASSIGN TO "c.dat"DISK SELECT data1

ASSIGN TO DISKThe file name cannot bespecified with an absolutepath name

File Organization

Specify SEQUENTIAL in the ORGANIZATION clause. If theORGANIZATION clause is omitted, SEQUENTIAL is used asthe default.

Chapter 7. File Processing 201

Defining Record Sequential File Records

This section explains record formats, lengths, and organization.

Record Formats and Lengths

Record sequential files are either fixed or variable length.

The record length in the fixed length record format is the valuespecified in the RECORD clause, or the maximum value in therecord description entries if the RECORD clause is omitted.

In the variable length record format, the length when a record iswritten is the length of the record. The length of an output recordcan be set for the data name written in DEPENDING ON data-name in the RECORD clause.

You can obtain the record length when entering a record byusing this data name.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 225/783

g

Record Organization

Define the attribute, position, and size of data in a record in

record description entries.

202 Chapter 7. File Processing

The following are examples of record definitions:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 226/783

Processing Record Sequential Files

Use input-output statements to create, extend, reference, and

update record sequential files. This section explains the types ofinput-output statements used in record sequential fileprocessing, and outlines each type of processing.

Types of Input-Output Statements

OPEN, CLOSE, READ, REWRITE, and WRITE statements are

used for input and output.

Chapter 7. File Processing 203

Using Input-Output Statements

The section provides explanation and examples of how to useinput-output statements.

OPEN and CLOSE Statements

Execute an OPEN statement only once, at the beginning of fileprocessing, and a CLOSE statement only once at the end of fileprocessing.

The open mode specified in the OPEN statement depends on thekind of file processing. For example, for creation, use the OPENstatement in the OUTPUT mode (OUTPUT specified).

Other Statements

To read records in a file, use a READ statement. To update

records in a file, use a REWRITE statement. To write records to afile, use a WRITE statement.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 227/783

Execution Order of Input-Output Statements

The execution order of input-output statements for creating,extending, referencing, and updating are as follows:

For file creation:

OPEN OUTPUT file-name.Editing-recordsWRITE record-name ... .CLOSE file-name.

For file extension:

OPEN EXTEND file-name.Editing-recordsWRITE record-name ... .CLOSE file-name.

204 Chapter 7. File Processing

For record reference:

OPEN INPUT file-name.

READ 

file-name ... .CLOSE file-name.

For record updating:

OPEN I-O file-name.READ file-name... .Editing-recordsREWRITE record-name ... .CLOSE file-name.

Processing Outline

Creating

To generate a record sequential file, open a file in OUTPUTmode, then write records to the file with a WRITE statement.

If an attempt was made to generate a file that already exists the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 228/783

If an attempt was made to generate a file that already exists, thefile is regenerated and the original contents are lost.

Extending

To extend a record sequential file, open a file in EXTEND mode,then write records to the file with a WRITE statement. Recordsare added to the end of the last record in the file.

Referencing

To refer to records, open the file in INPUT mode, then readrecords in the file from the first record with a READ statement.

When OPTIONAL is specified in the SELECT clause in the filecontrol entry, the OPEN statement is successful even if the filedoes not exist during execution of the OPEN statement, and the

Chapter 7. File Processing 205

at end condition is satisfied upon execution of the first READstatement.

For information on the at end condition, see “Input-Output ErrorProcessing.”

Updating

To update records, open the file in I-O mode, read the recordsfrom the file by using a READ statement, then rewrite them by

using a REWRITE statement.

When a REWRITE statement is executed, records read by the lastREAD statement are updated.

The record length cannot be changed even in the variable-lengthrecord format.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 229/783

206 Chapter 7. File Processing

Using Line Sequential Files

This section explains how to define files and records, and processfiles.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 230/783

Defining Line Sequential Files

This section explains the file definitions required to use linesequential files in a COBOL program.

Chapter 7. File Processing 207

File Name and File-Reference-Identifier 

As with a record sequential file, specify a file name and file-reference-identifier for a line sequential file. For moreinformation about specifying these items, see “Defining RecordSequential Files.”

File Organization

Specify LINE SEQUENTIAL in the ORGANIZATION clause.

Defining Line Sequential File Records

This section explains record formats, lengths, and organization.

Record Formats and Lengths

Th l ti f th d f t d l th f li

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 231/783

The explanations of the record formats and lengths of linesequential files are the same as for record sequential files. See“Defining Record Sequential File Records” for more information.

Because a record is delimited by a line feed character in a line

sequential file, the end of a record is always a line feed characterregardless of the record format. A line feed character, however, isnot included in the record length.

Record Organization

Define the attribute, position, and size of record data in therecord description entries. You do not have to define line feedcharacters in the record description entries because they areadded when records are written.

208 Chapter 7. File Processing

The following is an example of record definitions in the variablelength records format:

  Text character-string : Line feed character

A text character string can be up to 80 alphanumeric characters.

FD text-file  RECORD IS VARYING IN SIZE FROM 1 TO 80 CHARACTERS  DEPENDING ON record-length.01 text-record.

  02 text-character-string.  03 character-data PIC X OCCURS 1 TO 80 TIMES  DEPENDING ON record-length.

::

WORKING-STORAGE SECTION.01 record-length PIC 9(3) BINARY.

Processing Line Sequential Files

In a line sequential file processing, creation, extension, andreference can be done with input-output statements. This section

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 232/783

reference can be done with input output statements. This sectionexplains the types and use of input-output statements in linesequential file processing, and outlines the processing.

Using Input-Output Statements

OPEN, CLOSE, READ, and WRITE statements are used in linesequential file processing.

OPEN and CLOSE Statements

Execute an OPEN statement only once at the beginning of file

processing, and a CLOSE statement only once at the end of fileprocessing.

Chapter 7. File Processing 209

The open mode specified in the OPEN statement depends on thekind of file processing. For example, for creation, use the OPENstatement in the OUTPUT mode (OUTPUT specified).

Other Statements

To read records in a file, use a READ statement. To write recordsto a file, use a WRITE statement.

Execution Order of Input-Output Statements

The execution order of input-output statements for creating,referencing, and extending are as follows.

For file creation:

OPEN OUTPUT file-name.Editing-recordsWRITE record-name ... .

CLOSE file-name.

For file extension:

OPEN EXTEND file name

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 233/783

OPEN EXTEND file-name.Editing-recordsWRITE record-name ... .CLOSE file-name.

For record reference:

OPEN INPUT file-name.READ file name ... .CLOSE file-name.

210 Chapter 7. File Processing

Processing Outline

Creating

To create a line sequential file, open a file in OUTPUT mode, thenwrite records to the file with a WRITE statement.

If an attempt was made to create a file that already exists, the file

is recreated and the original file are lost.

The contents of the record area and line feed character are writtenat record write.

Extending

To extend a line sequential file, open a file in EXTEND mode,then write records sequentially to the file with a WRITEstatement. Records are added to the end of the last record in thefile

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 234/783

file.

Referencing

To refer to records, open the file in INPUT mode, then readrecords in the file from the first record by using a READstatement.

When OPTIONAL is specified in the SELECT clause in the filecontrol entry, the OPEN statement is successful even if the filedoes not exist, and the at end condition is satisfied upon

execution of the first READ statement. For information on the atend condition, see “Input-Output Error Processing.”

If the size of a read record is greater than the record length, datawith the same length as the record length is set in the record areawhen a READ statement is executed. The continuation of the

Chapter 7. File Processing 211

data of the same record is then set in the record area when thenext READ statement is executed. If the size of data to be set issmaller than the record length, spaces are written to theremaining portions of the record area.

Using Relative Files

This section explains how to define and process files, and how todefine records for relative files.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 235/783

212 Chapter 7. File Processing

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 236/783

Defining Relative Files

This section explains file definitions required to use relative filesin a COBOL program.

Chapter 7. File Processing 213

File Name and File-Reference-Identifier 

As with a record sequential file, specify a file name and file-reference-identifier for a relative file. For more information abouthow to specify these items, see “Defining Record SequentialFiles.”

File Organization

Specify RELATIVE in the ORGANIZATION clause.

Access Mode

Specify one of the following access modes in the ACCESS MODEclause:

Sequential access (SEQUENTIAL): Enables records to beprocessed in ascending order of the relative record numbersfrom the beginning of the file or a record with a specificrelative record number.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 237/783

• Random access (RANDOM): Enables a record with a specificrelative record number to be processed.

Dynamic access (DYNAMIC): Enables records to beprocessed in sequential and random access modes.

214 Chapter 7. File Processing

Referencing records in sequential and random access modes isshown below.

 [Sequential access] [Random access]

Relative Record Numbers

Specify the data name where a relative record number is enteredin the RELATIVE KEY clause. In sequential access, this clause

can be omitted.The relative record number of the record for this data name isentered when the record is read, and the relative record numberof the record to be written is entered when the record is written

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 238/783

of the record to be written is entered when the record is written.

This data name must be defined as an unsigned numeric item inthe WORKING-STORAGE section.

Defining Relative File Records

This section explains record formats, lengths, and organization.

Record Formats and Lengths

The explanations of the record formats and lengths of relativefiles are the same as for record sequential files. See “DefiningRecord Sequential File Records” for more information.

Chapter 7. File Processing 215

Record Organization

Define the attribute, position, and size of record data in therecord description entries. You do not have to define the area toset the relative record number.

Processing Relative Files

In relative file processing, creation, extension, insertion,reference, updating, and deletion is done with input-outputstatements. This section explains the types of input-outputstatements used in relative file processing, and outlines each type

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 239/783

p g, ypof processing.

Using Input-Output Statements

OPEN, CLOSE, DELETE, READ, START, REWRITE, and WRITEstatements are used for input and output in relative fileprocessing.

OPEN and CLOSE Statements

Execute an OPEN statement only once at the beginning of fileprocessing and a CLOSE statement only once at the end of fileprocessing.

216 Chapter 7. File Processing

The open mode specified in the OPEN statement depends on thekind of file processing. For example, for creation, use the OPENstatement in the OUTPUT mode (OUTPUT specified).

Other Statements

To delete records from a file, use a DELETE statement. To readrecords in a file, use a READ statement. To indicate a record forwhich processing is to be started, use a START statement.

To update records in a file, use a REWRITE statement. To write

records to a file, use a WRITE statement.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 240/783

Chapter 7. File Processing 217

Execution Order of Input-Output Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 241/783

218 Chapter 7. File Processing

Enter the relative record number for the data-name specified inthe RELATIVE KEY clause, for example, MOVE 1 to data-name.

The execution orders of input-output statements for creation,extension, insertion, reference, updating, and deletion are asfollows:

Processing Outline

Creating (Sequential, Random, and Dynamic )

To create a relative file, open a file in OUTPUT mode, then writerecords to the file with a WRITE statement. Records are writtenwith the record length specified in the WRITE statement.

In sequential access, relative record numbers 1, 2, 3, ... are set in

the order the records are written.In random or dynamic access, records are written at the positionsspecified by the relative record numbers.

If an attempt is made to create a file that already exists, the file is

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 242/783

If an attempt is made to create a file that already exists, the file isrecreated and the original file is lost.

Extending (Sequential)

To extend a relative file, open a file in EXTEND mode, then writerecords sequentially with a WRITE statement. When writing tofiles in this mode, records are added to the end of the last recordin the file.

The relative record number of the record to be written isincremented by one from the maximum relative record numberin the file.

The file can be extended only in sequential access mode.

Chapter 7. File Processing 219

Referencing (Sequential, Random, and Dynamic)

To refer to records, open the file in INPUT mode, then readrecords with a READ statement.

In sequential access, specify the start position of the record to beread with a START statement, then read records sequentiallyfrom the specified record in order of the relative record numbers.

In random access, the record with the relative record number

specified at execution of the READ statement is read.

When OPTIONAL is specified in the SELECT clause in the filecontrol entry, the OPEN statement is successful even if the filedoes not exist. The at end condition is satisfied with theexecution of the first READ statement. For information on the atend condition, see “Input-Output Error Processing.”

If the record with the specified relative record number is notfound in random or dynamic access, the invalid key condition issatisfied. For information on the invalid key condition, see“Input-Output Error Processing.”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 243/783

Updating (Sequential, Random, and Dynamic)

To update records, open the file in I-O mode.

In sequential access, read records with a READ statement, thenupdate them with a REWRITE statement. Executing theREWRITE statement updates the records read by the last READstatement.

In random access, specify the relative record number of the

record to be updated, then execute the REWRITE statement.

If the record with the specified relative record number is notfound in random or dynamic access, the invalid key condition is

220 Chapter 7. File Processing

satisfied. For information on the invalid key condition, see“Input-Output Error Processing.”

The record length cannot be changed, even in the variable-lengthrecord format.

Deleting (Sequential, Random, and Dynamic)

To delete records, open the file in I-O mode.

In sequential access, read records with a READ statement, thendelete them with a DELETE statement. Executing the DELETEstatement deletes the records read by the last READ statement.

In random access, specify the relative record number of therecord to be deleted, then execute the DELETE statement.

If the record with the specified relative record number is notfound in random or dynamic access, the invalid key condition is

satisfied. For information on the invalid key condition, see“Input-Output Error Processing.”

Inserting (Random and Dynamic)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 244/783

To insert records, open the file in I-O mode.

Specify the relative record number of the insertion position, thenexecute a WRITE statement. The record is inserted at the positionof the specified relative record number.

If the record with the specified relative record number alreadyexists, the invalid key condition is satisfied. For informationabout the invalid key condition, see “Input-Output ErrorProcessing.”

Chapter 7. File Processing 221

Using Indexed Files

This section explains how to define and process files, and definerecords for indexed files.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 245/783

222 Chapter 7. File Processing

Defining Indexed Files

This section explains the file definitions required to use indexedfiles in a COBOL program.

File Name and File-Reference-Identifier 

As with a record sequential file, specify a file name and file-

reference-identifier for an indexed file. For more informationabout how to specify these items, see “Defining RecordSequential Files.”

File Organization

Specify INDEXED in the ORGANIZATION clause.

Access Mode

Specify one of the following access modes in the ACCESS MODE

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 246/783

clause:

• Sequential access (SEQUENTIAL): Enables records to be

processed in ascending key order from the beginning of thefile or a record with a specific key.

• Random access (RANDOM): Enables a record with a specifickey to be processed.

• Dynamic access (DYNAMIC): Enables records to beprocessed in sequential and random access modes.

Referencing records in sequential and random access modes isshown in the following examples.

Chapter 7. File Processing 223

Sequential Access

Data is read sequentially from employee number 200001.

 Random Access

KEY

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 247/783

Data corresponding to employee number 200021 is fetched.

Primary and Alternate Keys

Keys are classified into primary record keys (primary keys) andalternate record keys (alternate keys). The number of keys,positions in records, and sizes are determined during filecreation, and cannot be changed once determined.

Records in the file are in logical ascending order of the primarykeys, and specific records can be selected with the primary keyvalues. When defining an indexed file, specify the name of a dataitem as the primary key in the RECORD KEY clause.

224 Chapter 7. File Processing

As with the primary key, an alternate key is the information usedto select specific records in the file. Specify the name of a dataitem to use as the alternate key in the ALTERNATE RECORD

KEY clause as required.

Multiple data items can be specified in the RECORD KEY andALTERNATE RECORD KEY clauses. When multiple data itemsare specified in the RECORD KEY clause, the primary keyconsists of these data items. Data items specified in the RECORDKEY clause need not be contiguous.

Multiple records can have the same key value (duplicate keyvalue) by specifying DUPLICATES in the RECORD KEY andALTERNATE RECORD KEY clauses. An error occurs if the keyvalue is duplicated when DUPLICATES is not specified.

Defining Indexed File Records

This section explains record formats, lengths, and organization.

Record Formats and Lengths

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 248/783

The explanations of the record formats and lengths of indexedfiles are the same as for record sequential files. See “Defining

Record Sequential File Records.”

Record Organization

Define the attributes, positions, and sizes of keys and data otherthan keys in records in the record description entries.

To process an existing file, the number of items, item positions,and sizes to be specified for the primary or alternate keys mustbe equal to those defined at file creation. The specification orderand the number of primary keys must be the same as for thealternate keys.

Chapter 7. File Processing 225

When writing two or more record description entries for a file,write the primary key data item in only one of these recorddescription entries. The character position and size defining the

primary key are applied to other record description entries.

In the variable length records format, the key must be set at thesame fixed part (position from the beginning of the record isalways the same).

The following is an example of record definitions in the variablelength records format:

Primary key Alternate key

Employeenumber

Full-name Section

6-digit number 20 characters Up to 32 characters

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 249/783

226 Chapter 7. File Processing

Processing Indexed Files

Use input-output statements to create, extend, insert, reference,update, and delete indexed files. Some processing may not beused, depending on the access mode.

This section explains the types and input-output statements usedin indexed file processing, and outlines each type of processing.

Using Input-Output Statements

OPEN, CLOSE, DELETE, READ, START, REWRITE, and WRITEstatements are used to process indexed files.

OPEN and CLOSE Statements

Execute an OPEN statement only once at the beginning of fileprocessing and a CLOSE statement only once at the end of fileprocessing.

The open mode specified in the OPEN statement depends on thekind of file processing. For example, for creation, use the OPEN

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 250/783

statement in the OUTPUT mode (OUTPUT specified).

 Other StatementsTo delete records from a file, use a DELETE statement. To readrecords in a file, use a READ statement. To indicate a record forwhich processing is to be started, use a START statement.

To update records in a file, use a REWRITE statement. To writerecords to a file, use a WRITE statement.

Chapter 7. File Processing 227

Execution Order of Input-Output Statements

The execution order of input-output statements for creating,extending, referencing, updating, deleting, and inserting are asfollows:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 251/783

228 Chapter 7. File Processing

Processing Outline

Creating (Sequential, Random, and Dynamic)

To create an indexed file, open a file in the OUTPUT mode, andwrite records to the file with a WRITE statement.

If an attempt is made to create a file that already exists, the file isrecreated and the original file is lost.

Before writing a record, the primary key value must be set. Insequential access, records must be written so that the primarykeys are in ascending order.

The following tasks are useful for collecting data to create indexfiles:

• Create data with the editor, read the data with the line

sequential file function, then write it to an indexed file, asshown in the following example.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 252/783

Figure 67. Writing data to an indexed file

• With the screen handling functions (presentation file and

screen operation functions), enter data from the screen, thenwrite it to an indexed file, as shown in the following example.

Chapter 7. File Processing 229

Figure 68. Writing data from the screen to an indexed file

Extending (Sequential)

To extend an indexed file, open the file in EXTEND mode, thenwrite records sequentially. At this time, records are added to theend of the last record in the file.

The file can be extended only in sequential access mode.

To edit the records to be written, the primary key values must bein ascending order.

When DUPLICATES is not specified in the RECORD KEY clausein the file control entry, the primary key value first processed

b h h i i k l i h fil

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 253/783

must be greater than the maximum primary key value in the file.

When DUPLICATES is specified, the primary key value firstprocessed must be equal to or greater than the maximumprimary key value in the file.

Referencing (Sequential, Random, and Dynamic)

To refer to records, open the file in INPUT mode, then read

records with a READ statement.

In sequential access, specify the start position of the record to beread with a START statement. Then, start reading records from

230 Chapter 7. File Processing

the specified position in ascending order of the primary oralternate key values.

In random access, the records to be read are determined by theprimary or alternate key values.

When OPTIONAL is specified in the SELECT clause in the filecontrol entry, the OPEN statement is successful even if the filedoes not exist. The at end condition is satisfied with theexecution of the first READ statement.

For information about the at end condition, see “Input-OutputError Processing.”

If the record with the specified key value is not found inRANDOM or DYNAMIC access, the invalid key condition issatisfied. For information on the invalid key condition, see“Input-Output Error Processing.”

A START or READ statement can be executed by specifying

multiple keys.

Updating (Sequential, Random, and Dynamic)

To update records, open the file in I-O mode, then rewrite

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 254/783

records in the file.

In sequential access, records read with the last READ statementare updated.

In random access, the primary key records with the specified keyvalues are updated.

If the record with the specified key value is not found inRANDOM or DYNAMIC access, the invalid key condition is

satisfied. For information on the invalid key condition, see“Input-Output Error Processing.”

The contents of primary keys cannot be changed. The contents ofalternate keys, however, can be changed.

Chapter 7. File Processing 231

Deleting (Sequential, Random, and Dynamic)

To delete records, open the file in I-O mode, then delete recordsfrom the file.

In sequential access, records read with the last READ statementare deleted.

In random access, the primary key records with the specified keyvalues are deleted.

If the record with the specified key value is not found in randomor dynamic access, the invalid key condition is satisfied. Forinformation about the invalid key condition, see “Input-OutputError Processing.”

Inserting (Random and Dynamic)

To insert records, open the file in I-O mode, then insert records inthe file. The record insertion position is determined by theprimary key value.

When DUPLICATES is not specified in the RECORD KEY orALTERNATE RECORD KEY clause in the file control entry and

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 255/783

ALTERNATE RECORD KEY clause in the file control entry, andthe record with the specified key value already exists, the invalid

key condition is satisfied.

For information about the invalid key condition, see “Input-Output Error Processing.”

232 Chapter 7. File Processing

Input-Output Error Processing

This section explains input-output error detection methods andexecution results if input-output errors occur.

The four input-output error detection methods are:

• AT END specification (detecting occurrence of the at end

condition)• INVALID KEY specification (detecting occurrence of the

invalid key condition)

• FILE STATUS clause (detecting input-output errors bychecking I-O status)

• Error procedures (detecting input-output errors)

AT END Specification

The AT END condition occurs when all records in a file are readsequentially and no next logical record exists in the file. To detect

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 256/783

y goccurrence of the at end condition, specify AT END in a READ

statement. With AT END specified, processing to be done atoccurrence of the at end condition can be written.

A coding example of a READ statement with AT END specifiedis:

READ sequential-file AT ENDGO TO at-end-processing

END-READ.

With the execution of the next READ statement after the lastrecord in the file is read, the at end condition occurs and the GOTO statement is executed.

Chapter 7. File Processing 233

INVALID KEY Specification

In input-output processing with an indexed or relative file, aninput-output error occurs if no record with a specified key orrelative record number exists in the file. This is called an invalidkey condition.

To detect occurrence of the invalid key condition, specifyINVALID KEY in the READ, WRITE, REWRITE, START, and

DELETE statements. With INVALID KEY specified, processingto be done upon the occurrence of an invalid key condition canbe written.

A coding example of a READ statement with INVALID KEYspecification is:

MOVE "Z" TO primary-key.READ indexed-file INVALID KEY

GO TO invalid-key-processingEND-READ.

If no record with primary key value "Z" is present in the file, theinvalid key condition occurs and the GO TO statement isexecuted.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 257/783

FILE STATUS Clause

When a FILE STATUS clause is written in the file control entry,the I-O status is posted to the data-name specified in the FILESTATUS clause upon execution of the input-output statement. Bywriting a statement (IF or EVALUATE statement) to check thecontents (I-O status value) of this data name, input-output errors

can be detected.

If no I-O status value is checked after the input-output statement,program execution continues even if an input-output erroroccurs. Subsequent operation is undefined.

234 Chapter 7. File Processing

For I-O status values to be posted, refer to Appendix B, “I-OStatus List.”

A coding example of a FILE STATUS clause is:

SELECT file-1.  FILE STATUS IS input-output-status  :  :

WORKING-STORAGE SECTION. 01 input-output-status PIC X(2).  :  :OPEN file-1.IF input-output-status NOT = "00"  THEN GO TO open-error-processing.

If a file could not be opened, a value other than "00" is set for theinput-output value. The IF statement checks this value, and theGO TO statement is executed.

Error Procedures

You specify error procedures by writing a USE AFTERERROR/EXCEPTION statement in Declaratives in thePROCEDURE DIVISION.

Writing error procedures executes the processing written in the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 258/783

g p p gerror procedures if an input-output error occurs. After executing

error processing, control is passed to the statement immediatelyafter the input-output statement with which an input-outputerror occurred. Thus, a statement indicating control of processingof the file where an input-output error occurred must be writtenimmediately after the input-output statement.

Control is not passed to the error procedures in the followingcases:

• AT END is specified in the READ statement with which theat end condition occurred

Chapter 7. File Processing 235

• INVALID KEY is specified in the input-output statementwith which the invalid key condition occurred

• An input-output statement is executed before the file isopened (the open mode is specified)

Branch from error procedures to the PROCEDURE DIVISIONwith the GO TO statement in the following cases:

• An input-output statement is executed for the file in which aninput-output error occurred

• Error procedures are re-executed before they are terminatedPROCEDURE DIVISION.  DECLARATIVES.  error-procedures SECTION.USE AFTER ERROR PROCEDURE ON file-1.  MOVE error-occurrence TO file-status. (1)

END DECLARATIVES.::

 OPEN open-mode file-1. IF file-status = error-occurrence (2)THEN GO TO open-error-processing.::

If a file could not be opened, error procedures (MOVE statementof (1)) are executed, and control is passed to the statement (IFstatement of (2)) immediately after the OPEN statement

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 259/783

statement of (2)) immediately after the OPEN statement.

Input-Output Error Execution Results

The execution result when an input-output error occurs dependson whether the AT END specification, INVALID KEYspecification, FILE STATUS clause, and error procedures arewritten. The following table lists execution results when input-output errors occur.

236 Chapter 7. File Processing

Table 19. Execution results when input-output errors occur 

Error type With error procedures Without error procedures

With the FILESTATUSclause

Without theFILE STATUSclause

With the FILESTATUSclause

Without theFILE STATUSclause

AT ENDcondition orINVALID KEYcondition

Detected byusing anexecutedinput-outputstatement withAT END or

INVALID KEYspecified

The statement written for the AT END or INVALID KEY specificationis executed.

Detected byusing anexecutedinput-outputstatementwithout ATEND orINVALID KEY

specified

Error procedures are executedimmediately after the input-output statement in which anerror occurred.

The statementimmediatelyfollowing aninput-outputstatement (inwhich an erroroccurred) isexecuted.

A U-levelmessage isoutput and theprogramterminatesabnormally.

Other input-output errors An I-levelmessage isoutput thenthe statementimmediatelyfollowing aninput-output

A U-levelmessage isoutput and theprogramterminatesabnormally.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 260/783

statement (in

which an erroroccurred) isexecuted.

File Processing

This section explains file assignment, file processing results,exclusive control of files, and methods for improving fileprocessing.

Chapter 7. File Processing 237

Assigning Files

The method of file input-output processing at program executionis determined by the contents of the ASSIGN clause in the filecontrol entry. The relation between the contents of the ASSIGNclause and files is explained below.

When Specifying a File Identifier in the ASSIGN Clause

Set the name of a file for input-output processing at programexecution with a file identifier as the run-time environmentinformation name. For details about how to set run-timeenvironment information, refer to “Setting Run-timeEnvironment Information” in Chapter 5.

The following is an example of setting run-time environmentinformation by using an initialization file.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 261/783

When a lowercase file identifier is specified in the ASSIGNclause:

A compiler error occurs if a file is compiled withcompiler option NOALPHAL specified.

• When setting run-time environment information, useuppercase letters.

238 Chapter 7. File Processing

If run-time environment information is left blank, a fileassignment error occurs.

When Specifying a Data Name in the ASSIGN Clause

Input-output processing is done for a file with the name specifiedin the data name. For example:

When the file name specified in the program is a relative pathname, the file having the current directory name prefixed iseligible for input-output processing.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 262/783

e g b e o put output p ocess g.

If the data name is left blank, a file assignment error occurs.

Chapter 7. File Processing 239

When Writing a File-Identifier Literal in the ASSIGN Clause

Input-output processing is done for a file with the name writtenas a file-identifier literal. For example:

When the file name written in the program is a relative pathname, the file having the current directory name prefixed iseligible for input-output processing.

When Writing a Character String DISK in the ASSIGN Clause

I t t t i i d f fil ith th ifi d

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 263/783

Input-output processing is done for a file with the name specified

in the SELECT clause. For example:

240 Chapter 7. File Processing

Files under the current directory are eligible for input-outputprocessing.

Exclusive Control of Files

Disable access during file processing by setting the exclusivemode for files or locking records in use. This is called exclusivecontrol of files.

This section explains the relationship between file processing andexclusive control of files.

Setting Files in Exclusive Mode

When a file is opened in exclusive mode, other users cannot

access the file.A file is opened in exclusive mode in the following cases:

• An OPEN statement is executed for a file with EXCLUSIVEspecified in the LOCK MODE clause in the file control entry.

• An OPEN statement in other than INPUT mode is executedf r fil ith ut th LOCK MODE l u p ifi d in th fil

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 264/783

for a file without the LOCK MODE clause specified in the file

control entry.

• An OPEN statement with WITH LOCK specified is executed.

• An OPEN statement in the OUTPUT mode is executed.

Chapter 7. File Processing 241

The following is an example of exclusive control of files:

Figure 69. Exclusive control of a file

1. File DATA1 is opened in exclusive mode.

2. If an attempt is made to execute an OPEN statement for fileDATA1 that is already in use in exclusive mode by programA, the attempt fails.

3 I O status value "93" (error caused by exclusive control of

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 265/783

3. I-O status value 93 (error caused by exclusive control of

files) is set for the data name specified in the FILE STATUSclause.

Locking Records

If records are locked, other users cannot lock them. To lock arecord, open the file containing the record in share mode.

A file is opened in share mode in the following cases:

• An OPEN statement without WITH LOCK specified in otherthan OUTPUT mode is executed for a file with AUTOMATIC

242 Chapter 7. File Processing

or MANUAL specified in the LOCK MODE clause of the filecontrol entry.

• An OPEN statement in the INPUT mode is executed.

Files opened in share mode can be used by other users. If a file isalready in use in exclusive mode by another user, however, anOPEN statement fails.

Records in a file opened in share mode are locked with theexecution of an input-output statement with exclusive controlspecified.

Records are locked in the following cases:

• A file with AUTOMATIC specified in the LOCK MODEclause in the file control entry is opened in I-O mode, then aREAD statement without WITH NO LOCK specified isexecuted.

•A file with MANUAL specified in the LOCK MODE clause inthe file control entry is opened in I-O mode, then a READstatement with WITH LOCK specified is executed.

Records are released from lock in the following cases:

• For a file with AUTOMATIC specified in the LOCK MODEclause

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 266/783

− A READ, REWRITE, WRITE, DELETE, or STARTstatement is executed

− An UNLOCK statement is executed

− A CLOSE statement is executed

• For a file with MANUAL specified in the LOCK MODEclause

− An UNLOCK statement is executed

− A CLOSE statement is executed

Chapter 7. File Processing 243

The following is an example of locking records.

Figure 70. Locking records

1. The file is opened in share mode.

2. The first record in the file is locked upon execution of aREAD statement

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 267/783

READ statement.

3. The file is opened in share mode.

4. A READ statement for the locked record fails.

5. I-O status value "99" (error caused by locking records) is setfor the data name specified in the FILE STATUS clause.

244 Chapter 7. File Processing

File Processing Results

File processing generates new files or updates files. This sectionexplains file status when file processing is done.

• File creation: Generates a new file upon execution of anOPEN statement. If a file with the same name already exists,the file is regenerated and the original contents are lost.

• File extension: Extends an existing file upon execution of a

WRITE statement. If an attempt is made to extend a file notexisting at program execution (optional file), a new file isgenerated upon execution of an OPEN statement.

• Record reference: Does not change the contents of the file.With an optional file, the at end condition occurs with thefirst READ statement.

• Record updating, deletion, and insertion: Changes thecontents of an existing file with the execution of a REWRITE,DELETE, or WRITE statement. With an optional file, a newfile is generated with the execution of an OPEN statement.Since no data exists in this file, however, the at end conditionoccurs with the first READ statement.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 268/783

When a program is terminated without executing a CLOSEstatement, files are closed unconditionally. If the unconditionalclose fails, a message is output, and files become unusable eventhough they are open.

A file can be assigned with the file identifier as a run-timeenvironment information name. If so, an input-output statementis executed for the file assigned with the file identifier, even if the

file assignment destination is changed with the environmentvariable operation function while the file is open.

When an OPEN statement is executed after the file assigned withthe file identifier is closed with a CLOSE statement, subsequent

Chapter 7. File Processing 245

input-output statements are executed for the file changed withthe environment variable operation function.

Therefore, use the OPEN statement to start the sequence of file

processing and the CLOSE statement to terminate the sequence.

If the area is insufficient for file creation, extension, recordupdating, or insertion, subsequent operation for the file isundefined. If an attempt is made to write records to the file whenthe area is insufficient, how they are stored in the file is alsoundefined.

When an indexed file is opened in OUTPUT, I-O, or EXTENDmode, it may become unusable if the program terminatesabnormally before it is closed. Make backup copies beforeexecuting programs that may terminate abnormally.

Files that became unusable can be recovered with the Recoverycommand of the COBOL85 FILE UTILITY. A function having thesame feature as the above command can be called from anapplication.

For more information, see “COBOL85 FILE UTILITY” andAppendix L, “Indexed File Recovery.”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 269/783

246 Chapter 7. File Processing

COBOL85 FILE UTILITY

This section explains the COBOL85 FILE UTILITY.

The COBOL85 FILE UTILITY allows you to use utilitycommands to execute file processing that can be used withCOBOL85 file systems, without using COBOL applications. Inthis section, files (record sequential, line sequential, relative, and

indexed files) handled by COBOL85 file systems are simplycalled COBOL files.

With the COBOL85 FILE UTILITY, you can create COBOL filesbased on data generated with text editors, and manipulateCOBOL files and records (such as display, edit, and sort).

Other operations for COBOL files include copying, moving, and

deleting files, converting file organization, and reorganizing,recovering, and displaying attributes of indexed files. Theseutilities can be easily operated by selecting menus in thewindow.

Using the COBOL85 FILE UTILITY

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 270/783

This section explains how to use the COBOL85 FILE UTILITY.

 Setting Up Environments

1. Specify the name of the path containing the COBOL run-timesystem for environment variable PATH.

2. Specify the directory to generate a temporary work file forenvironment variable TEMP with a path name beginningwith a drive name. When the Recovery command is executedwith these utilities, a temporary work file (~UTYnnnn.TMP

Chapter 7. File Processing 247

(nnnn indicates alphanumeric characters)) of the same size asthe file to be processed is generated under the specifieddirectory.

3. Specify the directory to generate a sort work file forenvironment variable BSORT_TMPDIR with a path namebeginning with a drive name. When the Sort command isexecuted with these utilities, a temporary file(~SRTnnnn.TMP (nnnn indicates alphanumeric characters)) isgenerated under the specified directory. If environmentvariable BSORT_TMPDIR is not specified, a sort work file is

generated under the directory specified by environmentvariable TEMP.

 Activating the COBOL85 FILE UTILITY

Start the COBOL85 FILE UTILITY as follows:

 Windows 95 and Windows NT:• Select COBFUT32[File Utility] from the P-STAFF Tools menu

• Execute COBFUT32.EXE

 Windows 3.1:

• Execute COBFUTY.EXE

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 271/783

• Select an execution command from the P-STAFF Utilitiesmenu.

• Select an execution command from the directory window ofFile Manager.

• Set up an icon for the command, and activate the commandby double-clicking on the icon.

• Select Run from the Program Manager or File Managermenus, then specify the program and parameters to run.

248 Chapter 7. File Processing

Selecting Commands

Select the command to be executed from the Command

pulldown menu on the menu bar. Selecting the commanddisplays a dialog box used to execute each command. For detailsof each function, see “COBOL85 FILE UTILITY Functions.”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 272/783

Figure 71. The COBOL85 FILE UTILITY window

The COBOL85 FILE UTILITY contains the following commands:

Convert

Create a new COBOL record sequential file in variable length

format with data generated by text editors as input. You canalso convert the COBOL file back to a text file.

Chapter 7. File Processing 249

Load

Convert COBOL file organization to another kind of fileorganization using a record sequential file in variable lengthrecord format as input.

In addition, all variable length records of a sequential file canbe added to an arbitrary COBOL file.

Unload

Convert COBOL file organization to variable length recordsin a sequential file using an arbitrary COBOL file as input.

Browse

Browse the content of records in COBOL files.

Print

Print the records in COBOL files.

Edit

Edit the contents of records from COBOL files.

Extend

Add variable length records in a sequential file to existing

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 273/783

arbitrary COBOL files.Sort

Sort records of an arbitrary COBOL file and place the resultsin a variable length record sequential file.

Attribute

Display attribute information (record length, record keyinformation etc.) of an index file excluding the recordcontents.

250 Chapter 7. File Processing

Recovery

Recover corrupt index files.

ReorganizeReduce file size by deleting empty blocks in index files.

Copy

Copy a file.

Delete

Delete a file.Move

Move a file to another location.

 Quitting the COBOL85 FILE UTILITY

Select Exit on the menu bar.

As with file processing using COBOL programs, file processingusing the COBOL85 FILE UTILITY depends on file organization.

For example, since record and line sequential files are processedin sequential access, records are processed only in a fixed orderor cannot be inserted or deleted. See “File Organization Types

d P i ”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 274/783

and Processing.”A system error can occur during execution of the COBOL85 FILEUTILITY. If an error occurs, an error code (decimal expression) isdisplayed in the error message. Refer to the system error codeexplanation or “System Error Codes” in Appendix F.

Chapter 7. File Processing 251

COBOL85 FILE UTILITY Functions

The COBOL85 FILE UTILITY provide the functions given below.In quotation marks (") are commands (< > indicates a commandname and [ ] indicates its use is optional) to use the functions. Formore information about how to operate the dialog box, refer tothe online help.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 275/783

252 Chapter 7. File Processing

Creating Files

Create a new COBOL file with data generated by text editors asinput using the "<Convert> [ + <Load>]" commands.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 276/783

Figure 72. Creating a file with the COBOL85 FILE UTILITY

When an error occurs with extended specification, the contents ofexisting files are lost if the check box of Make BACKUP is notselected.

Chapter 7. File Processing 253

Adding Records

Add records to existing COBOL files with the "<Extend>"

command.

Figure 73. Adding records with the Extend command

The Extend window contains the following elements:Exit

Quit (exit) the Extend window.

Browse

Browse the content of records in COBOL files.

Edit

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 277/783

Edit

Edit a record.

Option

Determine the method of data input (hexadecimal orcharacter) when adding new records.

HelpAccess the online help.

Add button

254 Chapter 7. File Processing

Add new records to the file.

The following describes other items which are found in thisexample of an Extend window.

Line sequential file

Illustrates the attributes of the displayed file.

Record length 120/120

Illustrates the record length/maximum record length.

HEX MODE

Illustrates the hexadecimal data input method.

Character string under [OFFSET] and " ;0 +1 ... +E +F"

The position offset of the data record is illustrated by thehexadecimal. The position of the cursor (offset in the datarecord) is "0x00000008" which left "00000000" of "+8" of the

cursor line and the cursor was added.Two character strings under "+0 +1 ... +E +F"

The data record is displayed by a hexadecimal every onebyte.

Character string under "0123456789ABCDEF"

The data record is displayed by a one-byte character mark.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 278/783

Note: Characters that cannot be displayed, such as nationalcharacters, are displayed with periods (.).This is the same forbrowsing, editing, and printing records. Refer to the online helpfor additional details.

Chapter 7. File Processing 255

Adding records from another file

Use the "[<Convert> + ] <Load (extend)> or [<Unload> + ]

<Load (extend)>" commands to add the contents of other files toexisting COBOL files.

or

Figure 74. Two methods of adding records from another file

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 279/783

256 Chapter 7. File Processing

Browsing Records

Browse the contents of records in COBOL files with the"<Browse>" command.

Figure 75. Browsing files with the Browse command

The Browse window contains the following elements:

Exit

Quit (exit) the Browse window.

Browse

B th t t f d i COBOL fil

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 280/783

Browse the contents of records in COBOL files.

Options

Determine the method of data input (hexadecimal orcharacter) when adding new records.

Help

Access the online help.

Chapter 7. File Processing 257

Key button

Change the order of displayed records. The order displayeddepends upon which record key is selected.

Search button

Search for a particular record.

First button

Go to the first record in a file.

Prev button

Go to the previous record in a file.

Next button

Go to the next record in a file.

Last button

Go to the last record in the file.Note: Characters that cannot be displayed, such as nationalcharacters, are displayed with periods (.).This is the same forbrowsing, editing, and printing records. Refer to the online helpfor additional details.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 281/783

258 Chapter 7. File Processing

Editing Records

Update, insert, and delete records within COBOL files using the"<Edit>" command.

Figure 76. Updating, inserting or deleting records with the Edit command

The Edit window contains the following elements:

Exit

Quit (exit) the Edit window.

Browse

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 282/783

Browse the content of records in COBOL files.

Edit

Edit a record.

Options

Determine the method of data input (hexadecimal orcharacter) when adding new records.

Chapter 7. File Processing 259

Help

Access the online help.

Key buttonChange the order of displayed records. The order displayeddepends upon which record key is selected.

Search button

Search for a particular record.

First button

Go to the first record in a file.

Prev button

Go to the previous record in a file.

Next button

Go to the next record in a file.Last button

Go to the last record in the file.

Update button

Update a record.

Insert button

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 283/783

Insert a new record.

Delete button

Delete a record.

Length button

Change the length of a record.

260 Chapter 7. File Processing

Note: If the maximum record length of an indexed file is 16kilobytes or more, the file cannot be opened with the Editcommand.

Sorting Records

Sort records in COBOL files with the "<Sort>" command.

Figure 77. Sorting records in COBOL files with the Sort command

A record sequential file with variable length record format isgenerated.

Manipulating COBOL files

Copy, delete, and move COBOL files with the "<Move>,<Copy>, and <Delete>" commands.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 284/783

Chapter 7. File Processing 261

Figure 78. Manipulating COBOL files with the Copy and Move commands

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 285/783

262 Chapter 7. File Processing

Printing Files

Print the contents of COBOL files with the "<Print>" command.

Figure 79. Printing COBOL files with the Print command

Converting File Types

Convert COBOL file to another kind of file organization usingthe "<Load>" or "<Unload>" commands. Use the "<Load>"command to input a record sequential file in variable lengthrecord format and convert it to a COBOL file. Use the

"<Unload>" command to input a COBOL file and convert it to arecord sequential file in variable length record format.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 286/783

Figure 80. Converting files using the Load and Unload commands

Chapter 7. File Processing 263

Manipulating Indexed Files

You can execute the following operations for indexed files:• Display attribute information with the "<Attribute>"

command

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 287/783

Figure 81. Displaying attribute information with the Attribute command

264 Chapter 7. File Processing

The Indexed File Information window contains the followinginformation:

File name

Displays the index file name whose attributes follow.

Record format

Displays the record format (fixed length/variable length).

If the maximum record length is fixed, the maximum recordlength is displayed.

If the minimum record length is fixed, the minimum recordlength is not displayed.

If the maximum record length is variable, the maximumrecord length is displayed.

If the minimum record length is variable, the minimumrecord length is displayed.

Record key information

Displays key information for the index file. The format of thekey information is the same as the format of key informationspecified when the index file is created by the Loadcommand. Refer to the online help for more details.

Block lengthDisplays the length of one block in the index file.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 288/783

Block increment

Displays block increments in the index file.

Compress of record data

Displays whether or not the stored record data iscompressed.

Chapter 7. File Processing 265

Key data compression

Displays whether or not the stored key data is compressed.

Number of recordsDisplays the number of records in the index file.

Number of blocks

Displays the number of blocks in the index file.

Number of empty blocks

Displays the number of unused blocks in the index file.

• Recover corrupt indexed files with the "<Recovery>"command.

Figure 82. Recovering corrupt files with the Recovery command

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 289/783

266 Chapter 7. File Processing

• Reorganize (delete empty blocks) indexed files with the"<Reorganize>" command.

Figure 83. Reorganizing indexed files with the Reorganize command

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 290/783

Chapter 8. Printing

This chapter explains how to print data by line or form, andprovides information about types of printing methods, printcharacters, form overlay patterns, forms control buffers (FCB),and form descriptors.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 291/783

268 Chapter 8. Printing

Types of Printing Methods

Use a print file or presentation file to print data from a COBOLprogram. This section outlines how to print data using thesefiles, and explains print character types, form overlay patterns,forms control buffers (FCB), and form descriptors. The printfunction you use depends on the printer being used. Refer to theuser manual for each specific printer.

Outline of Printing Methods

There are two types of print files, files with a FORMAT clauseand those without a FORMAT clause.

Use a print file without a FORMAT clause to print data in line

mode (line by line; Use 1), overlay data line by line with a formoverlay pattern, and print data by setting print information withan FCB (Use 2).

By using a print file with a FORMAT clause, data in forms withform descriptors can be printed.

This chapter classifies print and presentation files in the

following groups:

1. Print file without a FORMAT clause (Use 1)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 292/783

2. Print file without a FORMAT clause (Use 2)

3. Print file with a FORMAT clause

4. Presentation file

The following table lists the characteristics, advantages, and usesof printing methods (1) to (4).

Chapter 8. Printing 269

Table 20. Characteristics, advantages, and uses of eachprinting method

File Type (1) (2) (3) (4)Characteristics Data can be printed in line mode. B B B C

Data can be overlaid with form overlaypatterns.

C B B B *1

Data in forms can be printed withform descriptors.

C C B B

Advantage Simple program coding. A B B ASimple forms printing. B A A AExisting form descriptors generated byother systems can be used.

C C A A

Various types of print information canbe specified in programs.

C A A B

Use Output data to files. A A C CPrint forms. B A A A

A : Can be used (suitable).B : Can be used.C : Cannot be used.

*1 Can be printed only when an overlay pattern name is specified in form descriptors or isspecified in a printer information file. For details, refer to the FORM RTS HELP.

The following table lists related products

Table 21. Related products

File Type (1) (2) (3) (4) Power FORM - - - Needed FORM overlay option - Needed Needed Needed FORM RTS - - Needed Needed MeFt/NET - - - Needed

E h i i h d i li d b l

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 293/783

Each printing method is outlined below.

270 Chapter 8. Printing

(1) Print File without a FORMAT Clause (Use 1)

By using a print file without a FORMAT clause, data can be sentin line mode to a printer. During output, a logical page size, linefeed, and page alignment can be specified.

For details on how to use a print file when printing data in linemode, see “Using Print File 1.”

(2) Print File without a FORMAT Clause (Use 2)

With a print file, a page of output data can be overlaid with aform overlay pattern, or print information can be specified with aFCB. When specifying that a page of output data be overlaidwith a form overlay pattern, use a control record. Whenspecifying print information with a FCB, write a FCB controlstatement in an initialization file.

For details on form overlay patterns, see “Form OverlayPatterns.” For details on FCB, see “Forms Control Buffers(FCB).” For how to use print files, see “Using Print File 2.”

(3) Print File with a FORMAT Clause

For a print file with a FORMAT clause, specify the FORMATclause in file definitions in a program. By using a print file with aFORMAT clause, data in forms can be printed with partitioned

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 294/783

, p pform descriptors. At this time, the attributes of items defined inthe form descriptors can be changed by using a special registerduring program execution.

Forms can be printed with the form overlay patterns described

above and FCB. FORM RTS is required, however, to print formsusing a print file with a FORMAT clause.

Chapter 8. Printing 271

For details on form descriptors, see “Form Descriptors.” Fordetails on print files with form descriptors, see “Using Print Fileswith Form Descriptors.”

(4) Presentation File

With a presentation file, data in forms defined in the formdescriptors can be printed. As with the print file with a FORMATclause, the attributes of items defined in the form descriptors canbe changed by using a special register during program execution.

Before using a presentation file, the file must be defined and apresentation record must be created with a WRITE statement.

When a chart record is output, forms in the format defined in theform descriptors are printed. The attributes of output datadefined in the form descriptors can then be changed. For moreinformation about how to use presentation files when printingforms, see “Using Presentation Files (Printing Forms).”

Print Characters

The size, font, form, direction, and space of print characters canbe specified in the CHARACTER TYPE clause of a datadescription entry. MODE-1, MODE-2, MODE-3, and a

mnemonic-name, and print mode name can be specified in aCHARACTER TYPE clause.

MODE 1 MODE 2 d MODE 3 d 12 9

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 295/783

MODE-1, MODE-2, and MODE-3 designate 12-point, 9-point,and 7-point print characters.

When a mnemonic-name is set, data is printed with the size, font,form, direction, and space of a print character indicated by a

function-name. That function-name is related to a mnemonic-name with a function-name clause in the SPECIAL-NAMESparagraph.

272 Chapter 8. Printing

When a print mode name is set, data is printed with the size,font, form, direction, and space of a print character defined in aPRINTING MODE clause in the Special-Names paragraph.

For details about how to write a CHARACTER TYPE clause, andhow to define a mnemonic-name and print mode name, refer tothe “COBOL85 Reference Manual.”

The sizes, fonts, forms, and directions of available printcharacters, and spaces defined according to the sizes and formsof print characters are explained below.

Available sizes

3.0 to 300.0 points

Character size can be specified in units of 0.1 point. When araster-type device font (fixed size) is selected, data is printed witha point (character size) of a font mounted on each printer.

If character size specification is omitted and executionenvironment information @CBR_PrinterANK_Size is specified,the character size will be the default of the executing platform. Ifno character size is specified, the default is 7.0 points. Refer to“Format of Run-time Environment Information” in Chapter 5.

Specify a font with run-time environment information

@PrinterFontName. If the run-time environment information isomitted, CourierNew is normally selected.

If an outline font or a TrueType font is specified for run-time

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 296/783

If an outline font or a TrueType font is specified for run timeenvironment information, the print format is a scaleable font anddata can be printed with 3.0 to 300.0 points in units of 0.1 point.

Available Fonts

Fonts used are MINCHOU, MINCHOU-HANKAKU, GOTHIC,and GOTHIC-HANKAKU. The default font is GOTHIC.

Chapter 8. Printing 273

By using a print file without a FORMAT clause, if the font nameis set for run-time environment information @PrinterFontName,data is printed with the character font of the specified font name.If the font name is omitted, CourierNew is used as the default.

For a print file with a FORMAT clause and presentation file, referto the FORM RTS online help.

Available Print Character Forms

Print character forms are em-size and em-size tall and wide;

double size, en-size, and en-size tall and wide; and double size.The default form is em-size.

Orientation of Print Characters

Characters are printed horizontally.

Print Character Spaces

The following table lists spaces determined according to the sizesand forms of print characters. Character spaces of 0.01 to 24.00cpi are specified in units of 0.01 cpi. The default space is 10.0 cpi.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 297/783

274 Chapter 8. Printing

Table 22. Relationship between print character sizes/forms and character spaces

Unit: cpi

Character FormCharacterSize

 Em-size

 En-size

 Tallchar

 En-sizetallchar

 Widesizechar

 En-sizewidechar

Doublesize

En-doublesize

MODE-1(12 point)

  5 10 5 - 2.5 - 2.5 5

MODE-2(9 point)

  8 16 8 - 4 - 4 8

MODE-3(7 point)

  10 - 10 - 5 - 5 -

A(9 point)

  5 10 5 10 2.5 5 2.5 5

B(9 point)

 20/3 40/3 20/3 40/3 10/3 20/3 10/3 20/3

X-12P (12 point)

  5 10 5 10 2.5 5 2.5 5

X-9P(9 point)   8 16 8 16 4 8 4 8

X-7P(7 point)

  10 20 10 20 5 10 5 10

C (9 point)

  7.5 15 7.5 15 3.75 7.5 3.75 7.5

D-12P(12 point)

  6 12 6 12 3 6 3 6

D-9P(9 point)

  6 12 6 12 3 6 3 6

For the meanings of the codes for character sizes, refer to the“COBOL85 Reference Manual.”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 298/783

COBOL85 Reference Manual.

Arrangement coordinates of print characters

There are two methods for calculating the print coordinates whenprinting forms using the FORMAT phrase:

Chapter 8. Printing 275

(1) Dividing the print resolution character interval with the spacebetween the lines (DPI), and then arranging characters whilerounding off the remainder.

(2) Arrange the characters in coordinates and corrected the resultfor each print inch. This is done when the resolution cannotbe divided using the character interval (CPI) and spacebetween lines (DPI).

In method 1 the character stores only with the number of dotsrounded by the top and left. If method 1 can’t be used, thenmethod 2 can be used as an alternate.

Coordinates for arranging printed characters can be specifiedwith environment variable @CBR_PrintTextPosition when theFORMAT clause is omitted from the file control entry.

Refer to Chapter 5, “Format of Run-time EnvironmentInformation” on the method of specifying the arrangementcoordinates of print characters with @CBR_PrintTextPosition.

Form Overlay Patterns

A form overlay pattern is used to set fixed sections in forms inadvance, such as ruled lines and headers. Forms can be printed

by overlaying a page of output data with a form overlay pattern.

A form overlay pattern is generated from a screen image with theFORM overlay option A form overlay pattern can be shared

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 299/783

FORM overlay option. A form overlay pattern can be sharedwith multiple programs, and form overlay patterns generated byother systems can also be used.

For more information about how to generate form overlay

patterns, refer to the “FORM V1.3 Manual.” For printing formswhen using form overlay patterns, see “Using Print File 2.”

276 Chapter 8. Printing

Forms Control Buffers (FCB)

A forms control buffer (FCB) defines the number of lines on one

page, line space, and column start position. By using an FCB, thenumber of lines on one page, line space, and column startposition can be changed.

When an FCB name is specified with an I control record or whenthe default FCB name is specified in the initialization file(@DefaultFCB_Name=FCBxxx), FCB information can be specifiedexternally. Specify the FCB information in the initialization file as

follows:

FCBxxx=FCB-control-statement

xxx is the FCB name specified in the I control record or FCBname (part of xxx) specified for execution environmentinformation @ DefaultFCB_Name=FCBxxx.

For details of the syntax of a FCB control statement, seeAppendix K, “FCB Control Statement.”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 300/783

Chapter 8. Printing 277

The default value of the I control record FCB name is:

• 6 lpi x 11 inches (66 lines)

• Channel number : 01, Line number : 4

• Channel number : 02, Line number : 10

• Channel number : 03, Line number : 16

• Channel number : 04, Line number : 22

• Channel number : 05, Line number : 28

• Channel number : 06, Line number : 34

• Channel number : 07, Line number : 40

• Channel number : 08, Line number : 46

• Channel number : 09, Line number : 66

• Channel number : 10, Line number : 52

• Channel number : 11, Line number : 58

• Channel number : 12, Line number : 64

Refer to “Format of Run-time Environment Information” inChapter 5 for details on specifying the default FCB name.

Refer to “Using Print File 2” for details on specifying I control

records.

Form Descriptors

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 301/783

When forms are designed with FORM or Power FORM, formdescriptors are generated. COBOL85 enables data items defined

in the form descriptors to be included in a program so that formscan be printed with values set in the data items. Form overlaypatterns can be included in form descriptors.

278 Chapter 8. Printing

FORM RTS is required when printing forms using formdescriptors. FORM RTS requires a printer information file. Fordetails of printer information files, refer to the FORM RTS onlinehelp.

For information on how to generate form descriptors, refer to the“FORM V1.3 Manual.” For information about printing forms byusing form descriptors see “Using Print Files with FormDescriptors,” or “Using Presentation Files (Printing Forms).”

Using Print File 1

This section explains how to print data in line mode using a printfile without a FORMAT clause. For a sample of a program usinga print file, refer to the “Getting Started with Fujitsu COBOL”guide.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 302/783

Chapter 8. Printing 279

Outline

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 303/783

Define a print file in the same manner as a record sequential file,and do the same processing as generating the record sequentialfile. The following can be specified with a print file without aFORMAT clause:

• Logical page size (LINAGE clause in the file descriptionentry)

280 Chapter 8. Printing

• Character size, font, form, direction, and space(CHARACTER TYPE clause in the data description entry)

• Line feed and page alignment (ADVANCING phrase in the

WRITE statement)

Program Specifications

This section details program descriptions in a print file usingdata in line mode for each COBOL division.

 ENVIRONMENT DIVISION

In the ENVIRONMENT DIVISION, write the relation betweenthe function-name and mnemonic-name (print characters areindicated in the program) and define a print file.

Relating the Function-Name to the Mnemonic-NameRelate the function-name indicating the size, font, form,direction, and space of a print character to the mnemonic-name.Specify the mnemonic-name in the CHARACTER TYPE clausewhen defining data items in records and work data items. Forfunction-name types, refer to the “COBOL85 Reference Manual.”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 304/783

Chapter 8. Printing 281

Defining Print Files

The following table lists information required to specify a filecontrol entry.

Table 23. Information to be specified in a file control entry

Location InformationType

Details and Use of Specification

Required SELECT clause File name Write the name of a file to use in aCOBOL program, conforming to therules of COBOL user-defined words.

ASSIGN clause File-

reference-identifier

Write PRINTER, local-printer-port-

name (LPTn) or serial-printer-port-name (COMn:).When PRINTER is specified, data isoutput to the system default printer.

Optional ORGANIZATION clause

Keywordindicating fileorganization

Write SEQUENTIAL.

FILE STATUSclause

Data-name Write the data-name defined as a 2-byte alphanumeric data item in theWORKING-STORAGE or LINKAGEsection. The input-output execution result isset for this data-name. For value to beset, see Appendix B, “I-O Status List.”

 DATA DIVISION

In the DATA DIVISION, define record definitions and thedefinitions of data-names specified in a file control entry. Writerecord definitions in file and record description entries. Thef ll i t bl li t i f ti i d t it fil

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 305/783

following table lists information required to write a filedescription entry.

282 Chapter 8. Printing

Table 24. Information to be specified in a file description entry

Location Information

Type

Details and Use of Specification

Optional RECORDclause

Record size Define the size of the printable area.

LINAGE clause Logical pageconfiguration

Define the number of lines per page, topand bottom margins, and the footingarea starting position.When a data-name is specified in thisclause, the data can be changed in theprogram.

 PROCEDURE DIVISION

Execute an input-output statement in the following sequence:

1. OPEN statement with OUTPUT specified: Starts printing.

2. WRITE statement: Outputs data.

3. CLOSE statement: Stops printing.

 OPEN and CLOSE Statements

Use an OPEN statement once at the start of printing and aCLOSE statement once at the end of printing.

 WRITE StatementOne WRITE statement writes one line of data.

Specify PAGE in the ADVANCING phrase of the WRITEstatement for page alignment When the number of lines is

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 306/783

statement for page alignment. When the number of lines iswritten, the page is advanced by the specified number of lines.

The AFTER ADVANCING and BEFORE ADVANCING phrases

are used to specify whether data is output before or after pagealignment or a line feed. When the ADVANCING phrase isomitted, AFTER ADVANCING 1 is the default.

Chapter 8. Printing 283

Control of print lines with AFTER ADVANCING phrase isshown in the following example.

Figure 85. Print lines with AFTER ADVANCING

When writing WRITE A FROM B, define the CHARACTERTYPE clause for B but not for A. If the CHARACTER TYPE

clause is defined for both A and B, only the specification of B isvalid.

Program Compilation and Linkage

There are no required compiler and linker options.

Program Execution

First, assign a printer. Assigning a printer depends on the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 307/783

contents of descriptions in the ASSIGN clause in the file controlentry.

This section explains how to specify a printer in a program orinitialization file, and gives the relation between the contents ofdescriptions in the ASSIGN clause and the output destination byusing examples.

284 Chapter 8. Printing

If the destination of a print file is other than a printer, contentsare not assured.

Specifying a Printer 

A printer can be specified by the following methods:

• Printer name

• Local printer port name ("LPTn:") or Serial port name("COMn: "). Where "n" is a number from 1-9.

Windows 95

Use the information in the Details tab of the Printer Propertiesdialog box to obtain the printer name. To access the Details tab,click on the Start button and then select SettingsàPrinters.Highlight a printer and select Properties from the File menu.Click on the Details tab.

The Printer Properties dialog box (with the Details tab selected) isshown below.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 308/783

Chapter 8. Printing 285

Figure 86. The Details tab in the Printer Properties dialog box

Printer name

Specify a locally connected printer in the following manner:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 309/783

PRTNAME:HP LaserJet 5P

In this example, HP LaserJet 5P is the specified printer.

Specify a printer connected to a network in the followingmanner:

286 Chapter 8. Printing

PRTNAME:\\NMSVR20\Canon LBP-A404E

Local printer port name / Serial port name

Specify a local printer port name or serial port name in the

following manner:Example : "LPT1:"

Windows NT

Use the information in the Printer Properties dialog to obtain theprinter name. Activate the Print Manager and select Properties

from the Printer menu to display the Printer Properties dialogbox. The Printer Properties dialog box is shown below:

Figure 87. The Printer Properties dialog box

Printer name

Specify a locally connected printer in the following manner:

PRTNAME L J

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 310/783

PRTNAME:LaserJet

In this example, LaserJet is the specified printer.

Specify a printer connected to a network in the followingmanner:

PRTNAME:\\NMSVR20P\LaserJet

Chapter 8. Printing 287

Local printer port name / Serial port name

Specify a local printer port name or serial port name in thefollowing manner:

Example : "LPT1: "

Windows 3.1

• Specify the name of the port where the printer is connected.

• Specify "LPTn: " when the port where the printer is connectedis a local printer port. Specify "COMn:" when connected to a

serial port. "n" designates 1 to 9.

Examples of Programs

When PRINTER is Specified in the ASSIGN Clause

Data is sent to the system default printer (*1).

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 311/783

Figure 88. Data flow when sent to the default printer 

288 Chapter 8. Printing

*1 System default printer:

 Windows 95

"Set as Default" is checked for the printer.

 Windows NT

Printer is set as default using the Print Manager.

 Windows 3.1

Printer is set as default using the control panel.

To send data to a printer connected to a specific port, follow themethod explained below.

When a File-Identifier is Specified in the ASSIGN Clause

Define the name of the output destination printer, local printerport name, or serial port name with the file-identifier as the run-

time environment information name. For details on setting run-time environment information, refer to “Setting Run-timeEnvironment Information” in Chapter 5.

A file assignment error occurs if no printer is assigned to the file-identifier. An example of when the initialization file is used isshown in the following figure.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 312/783

Chapter 8. Printing 289

Figure 89. Data sent to a printer specified in the initialization file

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 313/783

290 Chapter 8. Printing

When a File-Identifier Literal is Specified in the ASSIGN Clause

Data is sent to a printer specified in the file-identifier literal or to

a printer connected to a local or serial port specified in the file-identifier literal.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 314/783

Figure 90. Data sent to a printer specified in the file-identifier literal

Chapter 8. Printing 291

When a Data-Name is Specified in the ASSIGN Clause

Data is sent to a printer specified in the data-name or to a printer

connected to a local or serial port specified in the data-name. Afile assignment error occurs if the data-name is left blank.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 315/783

Figure 91. Data sent to a printer specified in the data-name in theASSIGN clause

292 Chapter 8. Printing

Using Print File 2

This section explains how to use a form overlay pattern and FCB

in a print file without a FORMAT clause.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 316/783

Chapter 8. Printing 293

Outline

Use a control record to employ a form overlay pattern with aprint file.

As with ordinary data, a control record is created with a WRITEstatement. If a control record is created with a form overlaypattern name specified, the data and form overlay pattern areoverlaid on the subsequent page.

The size, font, form, direction, and space of a print character aredefined with a COBOL program and form overlay pattern. For

character settings, see “Print Characters,” and also refer to the“FORM V1.3 Manual.”

Figure 92. Defining print characters

Program Specifications

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 317/783

This section details program descriptions in COBOL divisionswhen forms are printed with form overlay patterns.

294 Chapter 8. Printing

ENVIRONMENT DIVISION

In the ENVIRONMENT DIVISION, write the relation between

the function-name and mnemonic-name, and define a print file.

Relating the Function-Name to the Mnemonic-Name

To enter a control record to the function-name CTL, relate themnemonic-name. Specify this mnemonic-name in the WRITEstatement when creating the control record.

When specifying a print character with a CHARACTER TYPEclause, relate the function-name indicating the size, font, form,direction, and space of a print character to the mnemonic-name.For function-name types, refer to the “COBOL85 ReferenceManual.”

Defining Print Files

Define a print file in a file control entry. For details ofdescriptions in a file control entry, see Table 23, “Information tobe specified in a file control entry.”

DATA DIVISION

In DATA DIVISION, define the record definitions and the

definitions of data-names used in the ENVIRONMENTDIVISION.

Defining Records

Define a record in file and record description entries. For details

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 318/783

Define a record in file and record description entries. For detailsof descriptions in a file description entry, see Table 24,“Information to be specified in the file description entry.” Definethe following records in the record description entry:

Chapter 8. Printing 295

Line Records

Define a record to print data edited in a program. Multiple linerecords can be written.

The contents of one line record are printed sequentially from theleft margin of the printable area. Specify the size of a line recordso that it is written within the printable area.

The size of a print character can be specified in the CHARACTERTYPE clause in the data description entry. For contents that canbe specified in the CHARACTER TYPE clause, see “Print

Characters.”

Control Records

Two types of control records are used for printing, I and Scontrol records. The format of each control record is shownbelow.

For detailed explanations of the record areas and areas notexplained in this manual, refer to the “COBOL85 ReferenceManual.”

As printer functions vary by model, refer to the users guide foreach printer specified.

 I Control Record

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 319/783

296 Chapter 8. Printing

01 I-CONTROL-REC.03 REC-ID PIC X(2) VALUE "I1".03 M PIC X(1) VALUE "1".03 FOVL PIC X(4). ⇒ FOVL

03 R PIC 9(3). ⇒ R03 C PIC 9(3). ⇒ C03 FCB PIC X(4). ⇒ FCB03 FORMAT-ID PIC X(8). ⇒ FORMAT-ID03 PIC X(30).03 PRT-FORM PIC X(2). ⇒ PRT-FORM03 FSIZE PIC X(3). ⇒ SIZE03 HOPPER PIC X(2). ⇒HOPPER03 PIC X(2).03 SIDE PIC X. ⇒ SIDE03 PIC X.03 PRT-AREA PIC X. ⇒ PRT-AREA03 BIND ⇒ BIND  04 PIC X OCCURS 4 TIMES.03 WIDTH PIC 9(4). ⇒WIDTH03 OFFSET.  04 PIC 9(4) OCCURS 4 TIMES. ⇒ OFFSET03 PIC X(9) VALUE SPACE. ⇒ RSV

FOVL

Specify the name of the form overlay pattern to use. If an overlaygroup is specified, a single overlay is performed by using the

first overlay pattern in the group.

R

Specify the number of times (0 to 255) that the form overlaypattern is printed. With this system, the same value as thenumber of copies is assumed

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 320/783

number of copies is assumed.

C

Specify the number of copies (0 to 255) for each page.

Chapter 8. Printing 297

FCB

Specify the applicable FCB name. Cannot be specified at the sametime as FORMAT-ID.

FORMAT-ID

Specify the applicable name of the screen and form descriptors touse. Cannot be specified at the same time as FCB.

PRT-FORM

Specify a print format. The following values can be specified:

• P (portrait mode)• L (landscape mode)

• LP (line printer mode)

• PZ (reduced printing portrait mode),

• LZ (reduced printing landscape mode)

PZ and LZ reduction specifications, however, are ignored. P andL specifications are used instead.

SIZE

Specify a forms size. The following sizes can be specified:A3, A4, A5, B4, B5, and LTR.

You can dynamically specify a paper size to be used at run time.In the I control record, the FSIZE field is set to a user-definedstring of three characters or less. The user-defined string replaces"XXX" in the environment variable @PRN_FormName_xxx whichis called at run time.

Environment variable @PRN FormName xxx is set equal to a

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 321/783

Environment variable @PRN_FormName_xxx is set equal to astring that defines the paper size. The values for the paper size

strings can be found in the Windows system printer defaults.

298 Chapter 8. Printing

Refer to the method of specifying execution environmentinformation in “Format of Run-time Environment Information”in Chapter 5.

Note: The user-defined string specifies a blank for this field when

paper sizes are specified by using the print file with a FORMATclause and specifies an actual paper size with the printerinformation file. For additional details, refer to the FORM RTSonline help.

HOPPER

Specify a hopper to be used to feed forms. The following values

can be specified:

• P1 (hopper 1)

• P2 (hopper 2)

• S (sub-hopper)

• P (arbitrary hopper)

The hopper cannot be changed by an application using the Icontrol record because the system automatically selects a hopperaccording to the form size specified. (32)

SIDE

Specify a print side. The following values can be specified:

• F (single-sided printing)

• B (double-sided printing)

Single-sided printing is output, however, even when B isspecified.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 322/783

PRT-AREA

Specify whether the unprintable area is set (L) or not set (N). Thisspecification has no effect, however, if the form descriptors arenot used.

Chapter 8. Printing 299

BIND

Specify the binding direction when multiple pages are outputtedsequentially.

WIDTHSpecify the binding width from 0 through 9999 (unit: 1/1440

inch).

OFFSET

Specify the offset from 0 through 9999 (unit: 1/1440 inch).

RSVArea used by the system. Enter a blank.

 S Control Record

PROCEDURE DIVISION

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 323/783

PROCEDURE DIVISION

Execute an input-output statement in the following sequence:

1. OPEN statement with OUTPUT specified: Starts printing.

300 Chapter 8. Printing

2. WRITE statement: Outputs data.

3. CLOSE statement: Stops printing.

OPEN and CLOSE Statements

Use an OPEN statement once at the start of printing and aCLOSE statement once at the end of printing.

WRITE Statement

Use a WRITE statement when creating a control or line record.

A line record is written in the same manner as when using a

WRITE statement to create data in line mode. See “ProgramSpecifications.”

To write a control record, write the mnemonic-name related tothe function-name CTL in the ADVANCING phrase.

To overlay data created by a line record with a form overlaypattern, write a control record with a form overlay pattern name

specified.

To not overlay data with a form overlay pattern, write a controlrecord with a blank entered as the form overlay pattern name.

After a control record is written, the format of the output page isset according to the contents of the control record. When acontrol record is written, however, no line record can be written

to the current page. Thus, to write a line record immediately aftera control record, the AFTER ADVANCING PAGE phrase mustbe specified.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 324/783

Chapter 8. Printing 301

  :  :  FILE SECTION.  FD file-1.  :  :  01 control-record.  :  :  02 FOVL PIC X(4).  :  :  MOVE "MREC" TO FOVL.  WRITE control-record AFTER ADVANCING mnemonic-  name. (1)  MOVE SPACE TO line-record.  WRITE line-record AFTER ADVANCING PAGE. (2)  MOVE 101234 TO employee-number.  MOVE "Jack London" TO name.  WRITE line-record AFTER ADVANCING 3. (3)  MOVE 105678 TO employee-number.  MOVE "Anne Miller" TO name.  WRITE line-record AFTER ADVANCING 2. (4)  :  :

Figure 93. Flow of control with a form overlay pattern

Program Compilation and Linkage

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 325/783

There are no required compiler and linker options.

302 Chapter 8. Printing

Program Execution

This section explains how to execute a program using a form

overlay pattern and FCB.

Programs Using Form Overlay Patterns

When a form overlay pattern is used with a print file, thefollowing settings are required:

• Specify the form overlay pattern storage directory for run-time environment information FOVLDIR. If the FOVLDIRsetting is omitted, the form overlay pattern is not printed.

• If the extent of the form overlay pattern storage file is otherthan OVD, specify an extent for run-time environmentinformation OVD_SUFFIX. If the file has no extent, specify

"None".• If the first four characters of the name of the form overlay

pattern storage file is other than KOL5, specify the first fourcharacters of the file name for run-time environmentinformation FOVLTYP.

For details about how to set run-time environment informationFOVLDIR, FOVLTYPE, and OVD_SUFFIX, refer to “Format ofRun-time Environment Information” in Chapter 5. An exampleof writing an initialization file is shown below.

Contents of an initialization file when executing program Ausing a form overlay pattern

[A]

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 326/783

[A]FOVLDIR=C:\FOVLDIR (1)OVD_SUFFIX= (2)FOVLTYPE=FOVL (3)

Chapter 8. Printing 303

(1) Set the directory (C:\FOVLDIR) where the form overlaypattern is stored for run-time environment informationFOVLDIR.

(2) The extent of the form overlay pattern storage file is OVD.

(3) The first four characters of the form overlay pattern storagefile are KOL6.

Outputting Form Overlay Patterns

For printers supporting form overlay patterns:

The software overlay function provided by the Windows 95,Windows NT , and Windows 3.1 graphic device interface (GDI)is supported, so a form overlay pattern can be sent to printershaving a Windows 95, Windows NT or Windows 3.1 printerdriver.

For Windows 3.1 (16), use a COBOL85 run-time system

information file.

COBOL85 Run-time System Information File (COB85RTS.CBR)(16)

A COBOL85 run-time system information file keeps informationcommon to all the COBOL85 application run-time environments

within one system. Use a text editor to change the contents of aCOBOL85 run-time system information file.

The PRINTERSEQUENCE section is entered in a COBOL85 run-time system information file. The PRINTERSEQUENCE sectiondefines a printer name and a mode setting for the printer(hardware setting)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 327/783

(hardware setting).

304 Chapter 8. Printing

The specification format of the PRINTERSEQUENCE section isshown below.

 [PRINTERSEQUENCE]printer-name=[mode-type]

printer-name=[mode-type](1) (2)

[ ]: Optional

(1) Printer name: Specify the printer name displayed on theWindows Control Panel.

(2) Mode type: Specify the mode set for the printer (hardware

setting). The mode type is indicated by a blank character or auppercase alphabetic character. COBOL85 supports thefollowing printer modes (orders):

Mode (order) Mode TypeFM (For blank or default)FM (image printing) (*1) FESC/Page ELIPS III L

Graphic device interface (GDI)(*2)

G

For the modes (orders) supported by the printer, refer to themanual included with the printer. If the printer name is omitted,FM is assumed as the mode (order).

*1 To use a form overlay pattern utilizing image printing

with a printer supporting the FM sequence, specify F for themode type.

*2 The result of a form overlay pattern output in the graphicdevice interface (GDI) mode depends on the printerspecification. Print a form overlay pattern in FM mode usinga printer supporting the FM sequence. This improves

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 328/783

performance and printing quality, compared to when the

graphic device interface (GDI) mode is used.

For information about how to use the tool, refer to the onlinehelp.

Chapter 8. Printing 305

Figure 94. The establishment of the order of classification dialog box

When printing with a form overlay pattern is done in other thanthe graphic device interface (GDI) mode, a blank sheet of papermay be ejected, depending on the printer. In this case, if theprinter can control "Print Without Data" on the printer operationpanel, reset it to "Print Without Data".

Programs Using FCB

When FCB is used with a print file, write an FCB controlstatement in the initialization file.

For the specification format of an FCB control statement, see“Forms Control Buffers (FCB).” For details of an FCB controlstatement, refer to Appendix K, “FCB Control Statement.”

An error occurs if an FCB name is specified in the I controlrecord, but no applicable FCB control statement is found in theinitialization file.

An example of an FCB control statement is shown below.

Contents of the initialization file when executing program A with

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 329/783

Contents of the initialization file when executing program A with

FCB1 set as the FCB name:[A]FCBFCB1=LPI((6,1),(12,4),(6,1),(12,2),(6,1))

306 Chapter 8. Printing

The output format of one page set by a FCB control statement isshown below:

Figure 95. Format of an FCB control statement

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 330/783

Chapter 8. Printing 307

Using Print Files with Form Descriptors

This section explains how to use partitioned form descriptors byusing a print file with a FORMAT clause.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 331/783

308 Chapter 8. Printing

Outline

Use a chart record to print forms using partitioned form

descriptors.

Define a partition (item group) designated in the formdescriptors in a chart record. You do not have to write thedefinition statement of a chart record, as it can be fetched fromthe form descriptors with a COBOL COPY statement.

As with ordinary data, create a chart record with a WRITE

statement. The size, font, form, direction, and space of printcharacters can be indicated in a COBOL program and formdescriptors.

For character settings, see “Print Characters,” and the “FORMV1.3 Manual.”

Figure 96. Flow of control with form descriptors

Program Specifications

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 332/783

This section explains how to write programs that use formdescriptors in a print file with a FORMAT clause.

Chapter 8. Printing 309

ENVIRONMENT DIVISION

In the ENVIRONMENT DIVISION, write the relation between

the function-name and mnemonic-name (print characters areindicated in the program) and define a print file.

Relating the Function-Name to the Mnemonic-Name

To specify a print character with a CHARACTER TYPE clause,relate the function-name indicating the size, form, direction, andspace of a print character to the mnemonic-name. For function-

name types and type styles, refer to the “COBOL85 ReferenceManual.”

Defining Print Files

Define a print file in a file control entry. The following table listsinformation required to write a file control entry.

Table 25. Information to be specified in a file control entryLocation Information

TypeDetails and Use of Specification

Required SELECTclause

File name Write the name of a file to use in a COBOLprogram, conforming to the rules of COBOL user-defined words.

ASSIGNclause

File-reference-

identifier

Write a file-identifier, file-identifier literal, or data-name. Use a file reference code to assign a printer

information file to be used by Form RTS atexecution time.FORMATclause

Data-name Specify a data-name defined as an 8-bytealphanumeric data item in the WORKING-STORAGE or LINKAGE section. Use this data-name to set the form descriptor name.

GROUPclause

Data-name Specify a data-name defined as an 8-bytealphanumeric data item in the WORKING-STORAGE or LINKAGE section Use this data

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 333/783

STORAGE or LINKAGE section. Use this data-

name to set the name of the item group defined inthe form descriptor.

310 Chapter 8. Printing

Table 25. Information to be specified in a file control entry (cont.)

Location InformationType

Details and Use of Specification

Optional FILESTATUSclause

Data-name Write the data-name defined as a 2-bytealphanumeric data item in the WORKING-STORAGE or LINKAGE section. The input-outputexecution result is set for this data-name. For valueto be set, see Appendix B, “I-O Status List.” Fordetail information, specify a 4-bytes alphanumericdata item.

How you assign a printer information file at execution time

depends on whether a file-identifier, file-identifier literal, or data-name is specified for a file-reference-identifier.

What you specify for a file-reference-identifier depends on whenthe name of the printer information file is determined. Specify afile-identifier literal if the name of the printer information file isdetermined during COBOL program generation and not changedafterwards. Specify a file-identifier if the name of the printerinformation file is undetermined during COBOL programgeneration or it is to be determined every program executiontime. Specify a data-name to determine the name of the printerinformation file in a program.

 DATA DIVISION

In the DATA DIVISION, define record definitions and thedefinitions of data used in the ENVIRONMENT DIVISION.

Define a record in file and record description entries. Thefollowing table lists information required to write a filedescription entry.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 334/783

Chapter 8. Printing 311

Table 26. Information to be specified in a file description entry

Location Information Type Details and Use ofSpecification

Optional RECORD clause Record size Define the size of theprintable area.

CONTROLRECORD clause

Control record name Specify a controlrecord name.

In a record description entry, line, control, and chart records canbe defined. For information about how to define and use line andcontrol records, see “Program Specifications.”

A record description statement defined in a chart record can befetched from form descriptors with a COPY statement withXMDLIB specified as a library-name at compile time. For detailson the record description statement to be expanded, see“Program Specifications.”

PROCEDURE DIVISION

Execute an input-output statement in the following sequence:

1. OPEN statement with OUTPUT specified: Starts printing.

2. WRITE statement: Writes data.

3. CLOSE statement: Stops printing.

OPEN and CLOSE Statements

Use an OPEN statement once at the start of printing and aCLOSE statement once at the end of printing.

WRITE Statement

In a WRITE statement, the line record, control record, and chart

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 335/783

In a WRITE statement, the line record, control record, and chart

record can be output. The output of these records makes page 1either a fixed form page or an irregular form page. In a fixedform page, the layout and chart record are defined by form

312 Chapter 8. Printing

descriptors and the line record can be printed. The irregular formpage is not defined by form descriptors, therefore only the linerecord can be printed because it acts in the same manner as theprint FORMAT phrase none file.

When the chart record and the line record exist together on afixed form page, the form descriptors defining the chart recordshould be set in the CONTROL RECORD phrase of the filedescription paragraph.

When the control record has a blank immediately after theexecution of an OPEN statement and the form descriptor name isoutput, the page becomes an irregular form page. In order tobecome a fixed form page, the form descriptors defining the chartrecord should be set in the FORMAT phrase of the file controldescription paragraph.

The fixed or irregular form of these pages is maintained onsubsequent pages as long as a WRITE statement changing theform of the page is not executed.

Pages can be changed if new form descriptors are added. In thisinstance, AFTER ADVANCING is specified for a WRITEstatement immediately after the output of the control record. See“Program Specifications” for the ADVANCING specification of aWRITE statement.

When executing a WRITE statement without the AFTER

ADVANCING PAGE phrase, the first print line is not validated.In this case, printing is started from the first printable line of theprinter.

Using Special Registers

Attributes of data items defined by form descriptors can be

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 336/783

changed by using special registers.

There are three special registers that can be used.

Chapter 8. Printing 313

EDIT-MODE

To specify whether or not output processing should occur.

EDIT-OPTION

To specify underlines and overstrikes.EDIT-COLOR

To specify color.

These special registers are modified by the data name defined bythe form descriptors. For example, to edit the color of data nameA, use "EDIT-COLOR OF A". Refer to “Special Registers Used

with Presentation File Module” in Appendix E for the values setin special usage of each register.

Note: A special register cannot be used by form descriptorswhere the item control part none is specified. Additionally, formdescriptors where the item control part none is specified and theitem control part is specified cannot be used together in a single

program.

Program Compilation and Linkage

Compilation

Select the compiler option FORMLIB, and specify the directory

name of the form descriptors storage file.

Linkage

There are no libraries that need to be linked.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 337/783

314 Chapter 8. Printing

Program Execution

To execute a program that uses form descriptors with a print file,

FORM RTS requires a printer information file. For details abouthow to generate a printer information file, see “GeneratingPrinter Information Files.”

The following environments must be set to execute a programthat uses form descriptors with a print file:

• Add the directory containing FORM RTS to environment

variable PATH.

• Generate a printer information file to be used by FORM RTS,and assign the file according to the contents of the ASSIGNclause. For information about how to assign a file, refer to“Assigning Files” in Chapter 7, because it is the same asassigning ordinary files. For details on a printer informationfile and how to generate it, refer to the FORM RTS onlinehelp.

When a printer information file is specified with a relative pathname, it is retrieved in the following sequence:

1. Directory set for environment variable MEFTDIR

2. Current directory

The following is an example showing form descriptors used witha print file.

Contents of the ASSIGN clause in a COBOL program:

ASSIGN TO PRTFILE

Contents of the initialization file(COBOL85.CBR):

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 338/783

:PRTFILE=C:\DIR\MEFPRC:

Chapter 8. Printing 315

Assign a printer information file to the file-identifier specified inthe ASSIGN clause of a COBOL program.

To use a form overlay pattern in form descriptors, set the extentsof the path and file names of the directory where the form

overlay pattern is stored for the printer information file. In thiscase, the extents set in run-time environment informationFOVLDIR and OVD_SUFFIX have no effect.

Using Presentation Files (Printing Forms)

This section explains how to print forms using a presentation file.For information about operation environments, refer to“Operation Environments” in Chapter 9, because they are thesame as when executing screen input-output with a presentationfile.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 339/783

316 Chapter 8. Printing

Outline

The presentation file module prints forms in the forms formatdefined with Power FORM (form descriptors). Form descriptorsare generated with a screen image.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 340/783

g g

Data items defined in form descriptors can be included in aCOBOL program at compile time by using a COBOL COPY

Chapter 8. Printing 317

statement. Thus, you do not have to write data item definitionsfor printing forms in a COBOL program.

The attributes of output data defined in form descriptors can bechanged during execution of a program by using a COBOL

special register.

Figure 97. Using a COBOL special register to change output data

Work Procedures

To print forms with the presentation file module, formdescriptors, COBOL source programs, and printer information

f l d

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 341/783

files are required.Generate form descriptors and COBOL source programs beforecompile time, and print information files before execution.

318 Chapter 8. Printing

The following is the standard order of work procedures forprinting forms with the presentation file module:

1. Generate form descriptors with FORM or Power FORM.

2. Generate COBOL source programs by using a text editor.

3. Compile and link COBOL source programs to generateexecutable programs.

4. Generate printer information files with a text editor.

5. Execute the executable programs.

Generating Form Descriptors

This section describes how to generate form descriptors used bythe presentation file module.

For detailed FORM functions and how to use FORM, refer to the“FORM V1.3 Manual.”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 342/783

Chapter 8. Printing 319

The following table lists information to be set to generate formdescriptors.

Table 27. Information to be set to generate form descriptors

Information Type Details and Use of SpecificationRequired File name Specify the name of a file in which form descriptor is

stored.Definition size Specify the forms size with the numbers of lines and

columns.Descriptors format Specify the free format.Data item Specify the data item to set print data. This item name is

used as a data-name when writing a COBOL program.Item group Put one or more item to be printed at a single run of print

processing into one item group. This item group name isused when writing a COBOL program.

Optional Item control field Specify a 5-byte item control field if the contents of formdescriptors need to be changed with a special register in aCOBOL program.

The item control field is information appended to data itemsdefined in form descriptors, and is classified into three input-output options:

• Sharable (3 bytes)

• Non-sharable (5 bytes)

• None

When a special register in a COBOL program is used, 5 bytesmust be specified.

Program Specifications

This section explains how to write programs when printingforms with the presentation file module for each COBOLdivision.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 343/783

320 Chapter 8. Printing

ENVIRONMENT DIVISION

ENVIRONMENT DIVISION defines a presentation file. In thepresentation file, as with defining an ordinary file, write a file

control entry in the FILE-CONTROL paragraph of the INPUT-OUTPUT section.

The following table lists the contents to be written in the filecontrol entry. These information values can be determinedregardless of the contents of form descriptors generated withFORM or Power FORM.

Table 28. Information to be specified in a file control entry

Location InformationType

Details and Use of Specification

Required SELECT clause File name Write the name of a file to use in a COBOLprogram, conforming to the rules ofCOBOL user-defined words.

ASSIGN clause File-reference-

identifier

Specify this item in the format of "GS- file-identifier". This file-identifier is the

environment variable to set the path nameof the printer information file used by theconnection product at execution.

FORMAT clause Data-name Specify a data-name defined as an 8-bytealphanumeric data item in the WORKING-STORAGE or LINKAGE section. For thisdata-name, specify the name of formdescriptors during forms printing.

GROUP clause Data-name Specify a data-name defined as an 8-byte

alphanumeric data item in the WORKING-STORAGE or LINKAGE section. For thisdata-name, specify the item group name tobe output during forms printing.

SYMBOLICDESTINATIONclause

Specificationof the outputdestination

Specify "PRT".

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 344/783

Chapter 8. Printing 321

Table 28. Information to be specified in a file control entry (cont.)

Location InformationType

Details and Use of Specification

Optional FILE STATUSclause Data-name Write the data-name defined as a 2-bytealphanumeric data item in the WORKING-STORAGE or LINKAGE section. Theinput-output execution result is set for thisdata-name. For value to be set, seeAppendix B, “I-O Status List.” For detailinformation, specify a 4-byte alphanumericdata item.

PROCESSING

MODE clause

Data-name Specify the data-name defined as a 2-byte

alphanumeric data item in the WORKING-STORAGE or LINKAGE section. For thisdata-name, set in input-output processingtype during forms input-output. See Table29.

UNITCONTROLclause

Data-name Specify the data-name defined as a 6-bytealphanumeric data item in the WORKING-STORAGE or LINKAGE section. For thisdata-name, set the control information ofinput-output processing at printing. SeeTable 29.

Table 29. Input-output processing types and specification values

Processing Type Value Control InformationPrinter control "CT" Form feed "PAGE"Partition output "PW" Output after feeding

nnn lines

"Annn"

Feed nnn lines afteroutput

"Bnnn"

Output at linenumber nnn

"Pnnn"

Line movementoutput

"FW" Move backward bynnn lines

"Annn"

Move forward by

nnn lines

"Snnn"

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 345/783

nnn lines

322 Chapter 8. Printing

DATA DIVISION

In the DATA DIVISION, write chart record definitions and thedefinitions of data-names specified in the file control entry.

A record description statement defined in a chart record can befetched from form descriptors with a COPY statement withXMDLIB specified as a library-name. For details of the recorddescription statement to be expanded, see “ProgramSpecifications.”

 PROCEDURE DIVISION

Like ordinary file processing, use input-output statements forprinting forms. Execute input-output statements in the followingsequence:

1. OPEN statement with I-O specified: Starts printing.

2. WRITE statement: Outputs data.

3. CLOSE statement: Stops printing.

OPEN and CLOSE Statements

Use an OPEN statement once at the start of printing and aCLOSE statement once at the end of printing.

WRITE Statement

One WRITE statement prints one form.

The name of form descriptors used for printing must be set forthe data-name specified in the FORMAT clause before executinga WRITE statement.

With a WRITE statement, data items in an item group set for the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 346/783

With a WRITE statement, data items in an item group set for thedata-name specified in a GROUP clause are eligible for printing.By setting a value in a special register before executing a WRITE

Chapter 8. Printing 323

statement, the data item attributes can be changed. For detailsabout how to use a special register, see “Program Specifications.”

Program Compilation and Linkage

Compiling

Select compiler option FORMLIB, and specify the path name tothe directory of the file containing form descriptors.

Linking

There are no libraries that need to be linked.

Generating Printer Information Files

This section describes how to print forms with the presentationfile module. For details on printer information files and how togenerate them, refer to the FORM RTS online help.

The following table lists information to be entered in a printerinformation file.

Table 30. Information to be entered in a printer information file

Information Type Details and Use of SpecificationPRTDRV Specify the device name of the output printer

device.PRTDEV Specify the printer model name of the output

printer device.MEDDIR Specify the path name to the directory containing

form descriptors.MEDSUF Specify the extension of form descriptor files. When

the specification of the extension is omitted, thedefault value of FORM RTS is used.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 347/783

324 Chapter 8. Printing

Program Execution

The following environments must be set to execute a programthat prints forms with the presentation file module:

• When using FORM RTS:

− Add the directory containing FORM RTS to environmentvariable PATH.

− Set the name of the printer information file with the file-identifier as an environment variable name.

 

When a printer information file is specified with a relativepath name, it is retrieved in the following sequence:

1. Directory set for environment variable MEFTDIR

2. Current directory

• When using MeFt/NET (32):

Add the directory containing MeFt/NET-SV toenvironment variable PATH.

− Set the printer information file name with the file-identifieras an environment variable name. The actual printerinformation file must be prepared for Windows 3.1.

− Specify an environment variable indicating thatMeFt/NET is used as a connector. There are twospecification methods:

• Set "MEFTNET" for the connector name with the file-identifieras an environment variable name.

• Set "MEFTNET" for environment variable@CBR_PSFILE_PRT.

For details on how to set MEFTNET, refer to “Format of Run-time Environment Information” in Chapter 5

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 348/783

time Environment Information in Chapter 5.

Chapter 8. Printing 325

Examples of how to print forms with the presentation filemodule are shown below.

Contents of the ASSIGN clause in a COBOL program:

ASSIGN TO GS-PRTFILE

Contents of the initialization file (COBOL85.CBR):

(When using FORM RTS)

:PRTFILE=MEFPRC:

(When using MeFt/NET (32)):

PRTFILE=MEFPRC,MEFTNET:

Assign a printer information file to the file-identifier specified inthe ASSIGN clause of a COBOL program. In the example usingFORM RTS, the printer information file is retrieved from the

directory set for environment variable MEFTNETDIR because thefile is assigned with a relative path specification.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 349/783

326 Chapter 8. Printing

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 350/783

Chapter 9. Input-Output UsingScreens

This chapter explains how to display screens and enter data fromthe displayed screens. Chapter 9 also describes how to usepresentation files, work procedures, and the screen handlingfunction.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 351/783

328 Chapter 9. Input-Output Using Screens

Types of Input-Output Using Screens

A COBOL program allows you to display a screen where you canenter data. This is referred to as screen input-output. Thefollowing two types of screen input-output functions areprovided:

• Presentation file function

• Screen handling function

The following table lists the features and uses of the presentationfile and screen handling functions.

Table 31. The features and uses of the presentation file and screen handlingfunctions

Feature and Use Presentation File Function Screen Handling  Function

Feature Screen design Designs a screen based onscreen image (using FORM). Designs a screen as acollection of lines.Number of screens Defines the number of

presentation files in a program.One

Changing screenattributes duringprogram execution

Enabled Enabled

Programspecification

contents

- Presentation file definition- Presentation record definition

- OPEN statement- READ statement- WRITE statement- CLOSE statement

- Screen definition- ACCEPT statement

- DISPLAY statement

Related products FORM (screen definition)FORM RTS (LOCAL Input-Output processing)MeFt/NET (REMOTE Input-Output processing)

None

Use Used for screen input-outputwith complex screens

Used for screen input-output simple screens

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 352/783

with complex screens(for example, form, slip)

output simple screens

Chapter 9. Input-Output Using Screens 329

Using Presentation Files (Screen Input-Output)

This section outlines how the presentation file module is used forscreen input-output, explains how to establish operationenvironments, and describes how to generate screen descriptorsand COBOL source programs. For sample programs of screeninput-output using the presentation file module, refer to the“Getting Started with Fujitsu COBOL” guide.

Outline

The presentation file module performs screen input-output usingscreens (screen descriptors) defined with FORM. Screendescriptors are generated with a screen image with FORM.

Data items for input-output processing defined in the screen

descriptors can be included in a COBOL program at compile timewith a COBOL COPY statement. Therefore, you do not specifydata item definitions for input-output processing in a COBOLprogram.

The attributes of data defined in the screen descriptors can bechanged during execution of a program with a COBOL special

register.

Operation Environments

To use the presentation file (screen input-output) module, screendescriptors generated with FORM are required. The followingfigure shows how an executable file is generated.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 353/783

330 Chapter 9. Input-Output Using Screens

 Figure 98. Generating a program using the presentation file module

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 354/783

Chapter 9. Input-Output Using Screens 331

To use the presentation file function, both the screen descriptorsand FORM RTS are required.

Figure 99. Operating a program using the presentation file module

*1 Besides Windows NT, the function is available with UXP/DS, Sun and HP-UX. For UXP/DS, FORM RTS is also required

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 355/783

332 Chapter 9. Input-Output Using Screens

Work Procedures

To perform screen input-output with the presentation file

module, screen descriptors, COBOL source programs, andwindow information files are required. The screen descriptorsand COBOL source programs must be generated beforecompilation, and window information files must be generatedbefore execution.

The following is the standard work procedure of screen input-output with the presentation file module:

1. Generate screen descriptors with FORM.

2. Generate COBOL source programs with a text editor.

3. Compile and link COBOL source programs to generateexecutable programs.

4. Generate window information files with a text editor.

5. Execute the programs.

Generating Screen Descriptors

This section describes how to generate screen descriptors used bythe presentation file module. For detailed FORM functions and

how to use FORM, refer to the “FORM V1.3 Manual.”

The following table lists information to be entered for screendescriptors.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 356/783

Chapter 9. Input-Output Using Screens 333

Table 32. Information to be entered for screen descriptors

Information Type Details and Use of SpecificationRequired File name Specify the name of a file in which screen descriptor is

stored.Definition size Specify the screen size with the numbers of lines and

columns.Descriptors format Specify the free format.Data item Specifies the area for screen input-output. The item

name specified here is used as a data-name in theCOBOL program specifications.

Item group Groups one or more items (displayed or entered onceper input-output group. The group name specified

here is used in the COBOL program specifications.Optional Item control field Specify a 5-byte item control field if the contents of

screen descriptors need to be changed with a specialregister in a COBOL program.

Attentioninformation

Specifies to decide an input key in the COBOLprogram.

The item control field is information appended to data itemsdefined in screen descriptors, and is classified into three options:

• Sharable (3 bytes)

• Non-sharable (5 bytes)

• None (for input and output)

Program Specification

This section explains how to use the presentation file module foreach COBOL division.

ENVIRONMENT DIVISION

The presentation file is defined in the ENVIRONMENTDIVISION.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 357/783

334 Chapter 9. Input-Output Using Screens

To define the presentation file, specify a file control entry in theFILE-CONTROL paragraph of the INPUT-OUTPUT section. Thisis the same as when you define an ordinary file.

The following table lists the contents to be written in the file

control entry. These values can be determined regardless of thedefinition contents of screen descriptors generated with FORM.

Table 33. Information to be specified in a file control entry

Location Information Type

Details and Use of Specification

Required SELECT clause File name Specifies the presentation file name to beused in the COBOL program This file name

must conform to the COBOL user-definedword rules.ASSIGN clause File-

referenceidentifier

Specify this item in the format of "GS- file-identifier". This file-identifier is theenvironment variable to set the path nameof the printer information file used byFORM RTS at execution.

FORMATclause

Data-name Specify a data-name defined as an 8-bytealphanumeric data item in the WORKING-

STORAGE or LINKAGE section. For thisdata-name, specify the name of screendescriptors during screen input-output.

GROUP clause Data-name Specify a data-name defined as an 8-bytealphanumeric data item in the WORKING-STORAGE or LINKAGE section. For this,specify the item group name to be input oroutput.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 358/783

Chapter 9. Input-Output Using Screens 335

Table 33. Information to be specified in a file control entry (cont.)

Location InformationType

Details and Use of Specification

Optional SYMBOLICDESTINATION

clause

outputdestination

Specify "DSP." (This clause can be omitted,since "DSP" is the default value of this

clause.)FILE STATUSclause

Data-name Specify a data-name defined as a 2-bytealphanumeric data item in the WORKING-STORAGE or LINKAGE section. Theexecution results of input-output processingare set in this data name. For value to be set,see Appendix B, “I-O Status List.” For detailinformation, specify a 4-byte alphanumericdata item.

PROCESSINGMODE clause

Data-name Specify a data-name defined as a 2-bytealphanumeric data item in the WORKING-STORAGE or LINKAGE section. Theprocessing class of screen input- outputprocessing is set in this data-name. See Table34.

SELECTEDFUNCTION

clause

Data-name Specify a data-name defined as a 4-bytealphanumeric data item in the WORKING-

STORAGE or LINKAGE section. Theattention information returned upon READstatement completion is set in this data-name. See Table 35.

UNITCONTROLclause

Data-name Specify a data-name defined as a 6-bytealphanumeric data item in the WORKING-STORAGE or LINKAGE section. For thisdata-name, specify the unit controlinformation during screen input-output. See

Table 34.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 359/783

336 Chapter 9. Input-Output Using Screens

Table 34. Input-output processing types and specification values

Processing Mode Control InformationInput Ordinary entry Blank None

Non-erasing entry "NE"Entry after alarm "AL"

Full screenerasing entry

"CL"

Changenotification entry

"NI"

Changenotification entryafter alarm

"AI"

Output Normal output Blank None

No erasing output "CL"Selection of menuitem disability

"PF" Menu item Attentioninformation

Selection of menuitem

"PN"

Terminal controloutput

"CT" Start preentry "BSTR"

End preentry "BSTP"

Clear preentry buffer "BCLR"Buzzer type: High tone "BZ1"Buzzer type: Low tone "BZ2"

Table 35. Attention information values and attention types

Attention Information Value Attention TypeCustomized values (*1) Value specified by user at screen definition"C000" Clear key

"E000" Execution key (*2)"E000" Data full key"E000" Item escape key*1 Includes such items as function keys and menu items.*2 This key is assigned as the for window information files. For details, refer to the FORMRTS online help.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 360/783

Chapter 9. Input-Output Using Screens 337

DATA DIVISION

In DATA DIVISION, presentation record definitions and dataitems specified in the file control entry are defined.

A record description statement defined in a presentation recordcan be fetched from screen descriptors with a COPY statementwith XMDLIB specified as a library-name.

The details of the record description statement to be expandedare explained below.

Figure 100. Expanding a record description statement

PROCEDURE DIVISION

The input-output statements are used for screen input-outputprocessing the same as for ordinary file processing.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 361/783

338 Chapter 9. Input-Output Using Screens

Input-output processing is executed in the following order:

1. OPEN statement with I-O phrase specified: Starts screeninput-output processing.

2. READ and WRITE statements: Screen input-output

processing.

3. CLOSE statement: Stops screen input-output processing.

OPEN and CLOSE Statements

Use an OPEN statement once at the start of screen input-outputprocessing and a CLOSE statement once at the end of screen

input-output processing.

READ or WRITE Statements

To display a screen, use a WRITE statement with a presentationrecord specified.

To read data from a screen, use a READ statement with a

presentation record specified.Before executing a WRITE statement, the screen descriptorsname must be set for a data-name specified in a FORMAT clause,and an item group name be set for a data-name specified in aGROUP clause.

Data items in an item group set for a data-name specified in a

GROUP clause are eligible for input-output.By setting values in special registers before executing a WRITE orREAD statement, the attributes of data items in presentationrecords can be changed. For values to be set for special registers,refer to “Special Registers Used with the Presentation FileModule” in Appendix E.

If an error is found in input data while executing a READstatement, and a re-input request order has been defined in

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 362/783

Chapter 9. Input-Output Using Screens 339

screen descriptors, screen display and input editing to enable re-input are repeated until the error is cleared.

When no error is found or no re-input request order has beendefined, the input edit result is posted to a COBOL program. In

addition, attention information is posted to a data-name specifiedin a SELECTED FUNCTION clause.

After executing a READ statement, the input result is returned tospecial register EDIT-STATUS. For the values to be set, refer to“Special Registers Used with the Presentation File Module” inAppendix E.

How to Use Special Registers

The attributes of data items defined with screen descriptors canbe changed with special registers. Multiple screen descriptorswith control fields that have different sizes cannot coexist. Thefive types of special registers are as follows:

• EDIT-MODE: Specify whether items are eligible for outputprocessing.

• EDIT-OPTION: Specify emphasis, underline, and reversedisplay.

• EDIT-COLOR: Specify a color.

• EDIT-STATUS: Specify whether items are eligible for input

processing. In addition, input results are posted.

• EDIT-CURSOR: Specify a cursor position.

Use these special registers with modification of data-namesdefined with screen descriptors. For example, write EDIT-COLOR OF A for the color of data-name A.

For the values to be set for special registers, refer to “SpecialRegisters Used for the Presentation File Module” in Appendix E.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 363/783

340 Chapter 9. Input-Output Using Screens

With 3-byte screen and form descriptors where item controlfields are shared in input and output processing, EDIT-MODE,EDIT-STATUS, EDIT-CURSOR, and EDIT-OPTION use the samestorage area for items defined in the screen and form descriptors.For example, EDIT-MODE OF A and EDIT-STATUS OF A, and

EDIT-CURSOR OF A and EDIT-OPTION OF A both use thesame storage area.

Program Compilation and Linkage

Compilation

Select compiler option FORMLIB, and specify the path name tothe directory containing the screen descriptors file.

Linkage

No libraries need to be linked.

Generating Window Information Files

This section describes how to generate a window information fileto perform screen input-output processing with the presentationfile module. For details on window information files and how togenerate them, refer to the FORM RTS online help. The followingtable lists information to be set in a window information file.

Table 36. Information to be set in a window information file

InformationType

Details and Use of Specification

Required MEDDIR Specify the path name to the directory containingscreen descriptors.

Optional MEDSUF Specify the extension of the file containing screendescriptors. When the specification of the extension is

omitted, the default value of FORM RTS is used.MEDCNT Specify the number of registrations of screen

descriptors. The default value is 10.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 364/783

Chapter 9. Input-Output Using Screens 341

Program Execution

The following environments must be set to execute a program

that performs screen input-output processing using thepresentation file module:

• When using FORM RTS:

− Add the directory containing FORM RTS to environmentvariable PATH.

− Set the name of the window information file with the file-

identifier as an environment variable name.

When a window information file is specified with a relativepath name, it is retrieved in the following sequence:

1. Directory set for environment variable FORM RTSDIR

2. Current directory

• When using MeFt/NET (32):− Add the directory containing MeFt/NET-SV to

environment variable PATH.

− Set the name of the window information file with the file-identifier as an environment variable name. The windowinformation file must be prepared for Windows 3.1. The

name of the window information file must be the same asthe file-identifier defined in the program.

− Specify an environment variable indicating thatMeFt/NET is used as a connector. There are the followingtwo specification methods:

• Set "MEFTNET" for the connector name with the file-identifier

as an environment variable name.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 365/783

342 Chapter 9. Input-Output Using Screens

• Set "MEFTNET" for environment variable@CBR_PSFILE_PRT.

For details on how to set MEFTNET, see “EnvironmentVariables” in Chapter 5.

The following example shows how to perform screen input-output with the presentation file module.

Contents of the ASSIGN clause in a COBOL program:

ASSIGN TO GS-DSPFILE

Contents of the initialization file:

(When using FORM RTS)::

DSPFILE=C:\DIR1\MEFWRC::

(When using MeFt/NET (32))

::

DSPFILE=MEFWRC,MEFTNET::

Assign a window information file to the file-identifier specified inthe ASSIGN clause of a COBOL program.

Display File Input Interruption

When MeFt is called from other applications, the system waitsfor input and the display can be interrupted. (This is true onlywhen MeFt is used). Refer to “COBOL-Supported Subroutine” inAppendix N for details.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 366/783

Chapter 9. Input-Output Using Screens 343

Using the Screen Handling Function

This section explains how to perform screen input-output usingthe screen handling function. For sample programs using thescreen handling function, refer to the “Getting Started withFujitsu COBOL” guide.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 367/783

344 Chapter 9. Input-Output Using Screens

Outline

The screen handling function displays a screen with a DISPLAY

statement and inputs data from a screen with an ACCEPTstatement.

The screen layout is defined in a screen data description entry inthe SCREEN section in the DATA DIVISION. A screen itemdefined in the SCREEN section is arranged on the screen with theline and column numbers.

Figure 101. Screen item defined in the SCREEN section

Screen Windows

One screen window to perform screen input-output with thescreen handling function is generated per run unit. Screen

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 368/783

Chapter 9. Input-Output Using Screens 345

windows are generated by the first ACCEPT or DISPLAYstatement executed, and closed when the run unit is terminated.

Although the size of the logical screen of this window isnormally 24 lines and 80 columns, it can be changed with run-time environment information @ScrnSize.

You can specify whether to close this window automatically orclose after message confirmation with run-time environmentinformation @WinCloseMsg.

The following table lists window attributes that can be changedat execution time. For details about how to specify run-timeenvironment information, see “Setting Run-time EnvironmentInformation” in Chapter 5.

Table 37. Changing window attributes for screen handling

Attribute Run-timeEnvironmentInformation

Setting Value

Meaning 

Automaticwindow closing

@WinCloseMsg ON Closes the window afterdisplaying a message.

(*1)OFF Closes the window without

displaying a message.Window size @ScrnSize (m,n) Specifies the size of a logical

screen with the number ofcolumns (m) and lines (n).

*1 This run-time environment information is also valid for console windows used with theACCEPT/DISPLAY function.

User-Defined Function Keys

The screen handling function invalidates the input of specificfunction keys and corresponding processing in programs tospecified function keys.

To use a function key when executing a program, define the

function key with the run-time environment variableTERMINATOR. Data input from the screen cannot be ended by

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 369/783

346 Chapter 9. Input-Output Using Screens

using a function key invalidated by the run-time environmentvariable TERMINATOR.

In a program, information on the input function key is set fordata items specified in the CRT STATUS clause in the SPECIAL-NAMES paragraph. For details about how to set the run-timeenvironment variable TERMINATOR, refer to “Setting Run-timeEnvironment Information” in Chapter 5.

Program Specification

This section explains how to write programs using the screen

handling function for each COBOL division.

ENVIRONMENT DIVISION

The following information can be entered in the SPECIAL-NAMES paragraph:

• Data items for setting or receiving cursor positions in theCURSOR clause.

• Data items for receiving screen input-output status in theCRT STATUS clause. The following table lists values set forthese data items.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 370/783

Chapter 9. Input-Output Using Screens 347

Table 38. Screen input-output status values

Status Key 1(1st Character)

Status Key 2(2nd Character)

Meaning 

"0" "0" A termination key was entered by the operator."1" The last item was entered.

"1" 0x00-0xff A user-defined function key was entered. (Afunction key number is set for status key2.) (*1)

"2" 0x00-0xff A system-defined function key was entered. (Afunction key number is set for status key2.) (*2)

"9" 0x00 No input item was found. (Error)*1 A user-defined function key is a function key defined using the run-time environmentvariable TERMINATOR.*2 A system-defined function key is a function key not defined using the run-timeenvironment variable TERMINATOR.

DATA DIVISION

The SCREEN section is written at the end of the DATADIVISION.

The SCREEN section has literal, input, output, update, and

input-output items. These items are classified based on coding ofthe screen data description entry.

The following table lists relationships between screen itemattributes and clauses that can be specified in the screen datadescription entry. For information about how to code the screendata description entry, refer to the “COBOL85 ReferenceManual.”

Data items defined in the BASED-STORAGE section cannot bespecified in the SCREEN section.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 371/783

348 Chapter 9. Input-Output Using Screens

Table 39. COBOL clauses specified for screen items

Purpose COBOL Clause Screen ItemAttribute *1 *2

L I O U IO G EEmphasis Display in high

intensity

HIGHLIGHT

clause

o o o o o x o

Display in lowintensity

LOWLIGHTclause

o o o o o x o

Display withblinking

BLINK clause ∆ ∆ ∆ ∆ ∆ x ∆

Display withunderline

UNDERLINEclause

o ∆ o o o x o

Color Specifybackground color

BACKGROUND-COLOR clause

o o o o o o o

Specifyforeground color

FOREGROUND-COLOR clause

o o o o o o o

Reversebackground andforegroundcolors

REVERSE-VIDEOclause

o o o o o x o

Sound Sound an audiotone

BELL clause o ∆ o o o x o

Expressionformat

Display a blankfor zero

BLANK WHENZERO clause

x ∆ o o o x o

Specify justification

 JUSTIFIED clause x o o o o x o

Specify operationsign position

SIGN clause x o o o o o o

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 372/783

Chapter 9. Input-Output Using Screens 349

Table 39. COBOL clauses specified for screen items (cont.)

Purpose COBOL Clause Screen ItemAttribute *1 *2

Displaymethod

Specify full-screen erasure

BLANK SCREENclause

o ∆ o o o o o

Specify partialscreen erasure

ERASE EOS clause o ∆ o o o x o

Specify full-lineerasure

BLANK LINEclause

o ∆ o o o x o

Specify partialline erasure

ERASE EOL clause o ∆ o o o x o

Specify non-display status

SECURE clause x o x x x o o

Position Specify columnnumber

COLUMNNUMBER clause

o o o o o x o

Specify linenumber

LINE NUMBERclause

o o o o o x o

Input Specify inputmode

FULL clause x o ∆ o o o o

Specify inputmode

REQUIRED clause x o ∆ o o o o

Others Automatic cursor

skip

AUTO clause x o ∆ o o o o

Specify generalcharacteristics

PICTURE clause x o o o o x o

Specifyexpressionformat

USAGE clause x o o o o o o

Specify literalitem

VALUE clause o x x x x x o

o : Can be specified∆ : Can be specified, but not validatedx : Cannot be specified*1 L: Literal, I: Input, O: Output, U: Update, IO: Input-output*2 Define G (Group) as a group item, and E (Elementary) as an elementary item.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 373/783

350 Chapter 9. Input-Output Using Screens

PROCEDURE DIVISION

To display a screen, use a DISPLAY statement with a screen itemdefined.

After executing a DISPLAY statement, data can be input from adisplayed screen. After input, by referring the values of screeninput-output status set for data-names specified in the CRTSTATUS clause in the SPECIAL-NAMES paragraph, appropriateprocessing can be selected.

Program Compilation and Linkage

No compiler options or additional libraries are required.

Program Execution

To define a function key, set the run-time environment variableTERMINATOR as shown in the following example:

TERMINATOR=PF1-PF4,!PF5-PF12,PF13-PF16

PF1 to PF4 and PF13 to PF16 are valid, but PF5 to PF12 areinvalid.

To change a window attribute, define the run-time environment

information listed in Table 37, “Changing window attributes forscreen handling.” Then, execute the program.

The ACCEPT/DISPLAY statement and screen handling functionoperate windows with an ACCEPT or DISPLAY statement, butuse different windows.

With this system, function keys PF10 and PF17 to PF24 are

invalid, regardless of the specification of the run-timeenvironment variable TERMINATOR.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 374/783

Chapter 9. Input-Output Using Screens 351

Windows used with the screen handling function cannot beminimized.

The size of a logical screen must not be smaller than the sizes ofdata items defined in the screen items.

Input items are always underlined.An error occurs when a program is executed if a logical screenset for run-time environment information @ScrnSize is (number

of columns + 1) * number of lines > 16,250.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 375/783

352 Chapter 9. Input-Output Using Screens

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 376/783

Chapter 10. CallingSubprograms (Inter-Program

Communication)This chapter explains how to call programs from other programs,or inter-program communication. Chapter 10 contains an outlineof calling relationships, including relation forms and linkagesrules, and describes how COBOL programs call COBOL and

other language programs, such as C and Visual Basic.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 377/783

354  Chapter 10. Calling Programs (Inter-Program Communication)

Outline of Calling Relationships

This section outlines program calling relationships.

Calling Relationship Forms

COBOL programs can call other programs or can be called fromother programs, as shown in the following figure (1), even if theother programs are coded in other languages.

COBOL programs, however, cannot be called recursively (2), andthey cannot call themselves (3).

Figure 102. Calling relationship forms

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 378/783

Chapter 10. Calling Programs (Inter-Program Communication) 355

Differences Among Linkage Rules

COBOL85 supports the following linkage rules:

1. COBOL linkage rules

2. C linkage rules

3. Pascal linkage rules (16)

4. STDCALL linkage rules (32)

Items 2-4 are applicable to _cdecl, _pascal, and _stdcallsupported by Microsoft C and Visual C++ compilers.

Table 40. Differences between linkage rules

Linkage Rules Stacking andFetching Parameters

Restoring StackPointer (SP)

Calling Name (*1)and ExternalReference NameRules

COBOL linkage rules Parameters arestacked from right toleft, and fetched

from left to right

The calling programrestores the SP

The calling name isthe externalreference name

without modificationC linkage rules The calling name

with "_" prefixed isthe externalreference name

Pascal linkage rules(16)

Parameters arestacked from left toright, and fetched

from right to left

The called programrestores the SP

The calling name isthe externalreference name

without modificationSTDCALL linkagerules (32)

Parameters arestacked from right toleft, and fetchedfrom left to right

The calling namewith "_" prefixed and@###(*2) suffixed isthe externalreference name

*1 When writing a calling name in COBOL, specify case-sensitivity and specify compileroption NOALPHAL.*2 ### represents a decimal number that indicates the number of bytes of the parameter.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 379/783

356  Chapter 10. Calling Programs (Inter-Program Communication)

Linkage Rules and Supporting Compilers

The following table lists the correspondence between the linkagerules supported by COBOL, and the compilers supporting thelinkage rules.

Table 41. Linkage rules and supporting compilers

Linkage Rules Specification in a CALL Statement, ENTRYStatement, or PROCEDURE DIVISION

(16) (32)

COBOL linkage rules None o oC linkage rules WITH C LINKAGE o oPascal linkage rules WITH PASCAL LINKAGE o x(*2)STDCALL linkagerules

WITH STDCALL LINKAGE x(*1) o

*1 A compile time W error is output, and Pascal linkage rules are assumed.*2 A compile time W error is output, and STDCALL linkage rules are assumed.

Calling COBOL Programs from COBOL

Programs

This section explains how to call other COBOL programs(subprograms) from COBOL programs (calling programs).

Calling Method

To call programs from COBOL programs, use the CALLstatement. In the CALL statement, write a program name with aliteral, or specify a data-name and set the name of a calledprogram in this data-name.

Called programs can be changed at program execution by

specifying the data-name in the CALL statement. Callingprograms by specifying data names in the CALL statement

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 380/783

Chapter 10. Calling Programs (Inter-Program Communication) 357

makes the program structure dynamic between calling programsand subprograms.

For details of program structure, refer to “Linkage Types andProgram Structure” in Chapter 4.

Secondary Entry Points

An entry point to call programs can be set in the procedures inCOBOL programs. The start point of a program procedure is aprimary entry point, and an entry point set in the middle of aprocedure is a secondary entry point.

Executing the CALL statement with a program name specifiedexecutes a subprogram from the primary entry point.

To execute a subprogram from a secondary entry point, specifythe name of the secondary entry point in the CALL statement thesame way you specify the program name.

To set a secondary entry point in a COBOL program, write an

ENTRY statement. When a program is sequentially executed, theENTRY statement is skipped. An ENTRY statement cannot bewritten in internal programs.

Returning Control and Exiting Programs

To return control from subprograms to calling programs, executethe EXIT PROGRAM statement. When the EXIT PROGRAMstatement is executed, control returns immediately after theCALL statement executed by the calling program.

To quit execution of all COBOL programs, execute the STOPRUN statement. When the STOP RUN statement is executed,control returns to the calling source of the COBOL mainprogram.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 381/783

358  Chapter 10. Calling Programs (Inter-Program Communication)

Passing Parameters

Parameters can be passed between calling programs andsubprograms.

In a calling program, write data items defined in the FILE,WORKING-STORAGE, or LINKAGE sections in the USINGphrase of the CALL statement. In a subprogram, write data-names to receive parameters in the USING phrase of thePROCEDURE DIVISION header or ENTRY statement.

The order of data-names entered in the USING phrase of theCALL statement of the calling program corresponds to that of

data names written in the USING phrase of the calledsubprogram. Data names need not be the same between thecalling program and subprogram. The attribute, length, andnumber of corresponding data items, however, should be thesame.

Figure 103. Order of data-names between calling and called programs

When the contents of parameters of the calling program should

not be changed with the execution of the subprogram, write BY

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 382/783

Chapter 10. Calling Programs (Inter-Program Communication) 359

CONTENT data-name in the USING phrase of the CALLstatement.

Figure 104. BY CONTENT data-name in the USING phrase of the CALLstatement

Sharing Data

By specifying the EXTERNAL clause in the data or filedescription entry, the data area can be shared among multipleexternal programs. Specifying the EXTERNAL clause gives the

data or file the external attribute. Data having the externalattribute is external data, and a file having the external attributeis an external file.

Note: The EXTERNAL clause cannot be specified for thepresentation file without OUTPUT mode.

Program maintainability can be improved by generating the

definitions of external data or files as a COBOL library, thenincluding the data in programs with the COPY statement.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 383/783

360  Chapter 10. Calling Programs (Inter-Program Communication)

Figure 105. Improving program maintainability by generating data andfile definitions

Return Codes

When control returns to calling programs from subprograms,return code values can be passed with special registerPROGRAM-STATUS (or RETURN-CODE). Special registerPROGRAM-STATUS is implicitly declared as PIC S9(9) COMP-5,and you do not have to define it in the program.

When a subprogram writes a value to special registerPROGRAM-STATUS, the value is written to special registerPROGRAM-STATUS of the calling program.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 384/783

Chapter 10. Calling Programs (Inter-Program Communication) 361

Internal Programs

COBOL programs are classified into external and internalprograms based on the program structure. The outermost

program not included in other programs is an external program.Programs directly or indirectly included in an external programare internal programs.

An external program (A) can call its internal program (A1). Theinternal program (A1) can call another external program (B) or itsinternal program (A11). However, internal programs (C1 and D1)

cannot call outside programs (C and D2) other than commonprograms.

Figure 106. Calling sequence

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 385/783

362  Chapter 10. Calling Programs (Inter-Program Communication)

Common Programs

To call an internal program from an outside internal program,specify a COMMON clause in the PROGRAM-ID paragraph of

the called internal program.The program with COMMON specified is a common program,and it can be called from internal programs not including theprogram with COMMON specified.

Initial Programs

To place a program in the initial state whenever it is called,specify an INITIAL clause in the PROGRAM-ID paragraph. This

program is an initial program. When the initial program is called,the program is always placed in the initial state.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 386/783

Chapter 10. Calling Programs (Inter-Program Communication) 363

When program F1 is called, the value of DATA01 is always 0.

Valid Scope of Names

To use data items defined by external programs in the internalprograms, specify the GLOBAL clause in the data descriptionentry. Normally, names are valid only within the same program,but data items with the GLOBAL clause specified can be used byinternal programs.

External programs cannot use data items with GLOBAL clausespecified in the internal programs.

Notes

If compiler option ALPHAL is valid in both the calling programand subprogram, literal of the program name is treated asfollows:

• Calling program: A program name specified with a literal inthe CALL statement is always treated as uppercase.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 387/783

364  Chapter 10. Calling Programs (Inter-Program Communication)

• Subprogram: A program name written in the PROGRAM-IDparagraph is always treated as uppercase.

When compiling the calling program and subprogram, specifythe same compiler option for each, ALPHAL or NOALPHAL.Note: Specify compiler option NOALPHAL when using

lowercase letters for a program name.

When compiling the main program, compiler option MAIN mustbe specified. When compiling the subprogram, compiler optionNOMAIN must be specified.

Linking C Programs

This section explains how to call C programs (functions) fromCOBOL programs, and how to call COBOL programs from Cprograms (functions). In this section, C programs (functions) aresimply called C programs.

Calling C Programs from COBOL Programs

This section explains how to call C programs from COBOLprograms.

Calling Method

To call C programs from COBOL programs, specify functionnames in the CALL statement of COBOL. When the returnstatement is executed in the called C program, control returnsimmediately after the CALL statement of COBOL.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 388/783

Chapter 10. Calling Programs (Inter-Program Communication) 365

Passing Parameters

To pass parameters from COBOL programs to C programs,specify data-names in the USING clause of the CALL statement.

The parameters to be passed to the C program are the areaaddresses or the values of the data names. Specify parameters inthe USING clause of the CALL statement.

The relation between the description of the USING clause and thecontents of parameters is explained below.

When BY REFERENCE Data-Name is Specified: Area AddressThe actual argument value that the COBOL program passes tothe C program is the area address of the specified data-name.Declare a pointer having a data type corresponding to theattribute of the parameter to be passed as a dummy argument inthe C program. For correspondence between COBOL and C datatypes, see Table 42.

When BY CONTENT Data-Name (or Literal) is Specified: Area Address

The actual argument value that the COBOL program passes tothe C program is the address of the area containing the value ofthe specified data-name. Declare a pointer having the data typecorresponding to the attribute of the parameter to be passed as adummy argument in the C program.

Changing the contents of the area pointed to by the actualargument in the C program does not change contents of the dataname of the COBOL program.

When BY VALUE Data-Name is Specified: Contents of the Area

The actual argument value that the COBOL program passes to

the C program is the contents of the specified data-name.Changing the contents of the actual argument in the C program

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 389/783

366  Chapter 10. Calling Programs (Inter-Program Communication)

does not change contents of the data name of the COBOLprogram.

Return Codes (Function Values)

Use the PROGRAM-STATUS special register to receive returncodes (function values) from C programs. C function values mustbe of the long int type.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 390/783

Chapter 10. Calling Programs (Inter-Program Communication) 367

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 391/783

368  Chapter 10. Calling Programs (Inter-Program Communication)

When a C program of the short int type is called, C functionvalues written to the PROGRAM-STATUS special register arereferred to as follows:

  :  01 return-value-storage-area PIC S9(9) COMP-5.  01 REDEFINES return-value-storage-area.

  02 function-value PIC S9(4) COMP-5.  02 PIC 9(4) COMP-5.  :  CALL "Cprog" USING PARAM1 PARAM2.  MOVE PROGRAM-STATUS TO return-value-storage-area.  IF function-value = 0 THEN ...  :

The attribute of the PROGRAM-STATUS special register isapplicable to the C long int type. After a C program of the shortint type is called, therefore, the values of special registerPROGRAM-STATUS, if referred to as they are, cannot be referredto as correct function values.

Calling COBOL Programs from C Programs

This section explains how to call COBOL programs from Cprograms.

Calling Method

To call COBOL programs from C programs, specify COBOLprogram names in the C function calling format. When the EXITPROGRAM statement is executed in the called COBOL program,control returns immediately after the C program function call.

When the main program (C program) calls a COBOL program,call JMPCINT2 before calling the first COBOL program, and call JMPCINT3 after calling the last COBOL program. JMPCINT2 is asubroutine that initializes COBOL programs. JMPCINT3 is a

subroutine that terminates COBOL programs.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 392/783

Chapter 10. Calling Programs (Inter-Program Communication) 369

Calling COBOL programs without calling JMPCINT2 and JMPCINT3 may degrade performance because COBOL programrun-time environments are initialized and terminated every timeCOBOL programs are called.

Passing Parameters

To pass arguments from C programs to COBOL programs,specify actual arguments with C function calls. The values ofactual arguments that can be passed from C programs to COBOLprograms must be storage addresses.

With COBOL programs, by specifying data-names in the USING

clause of the PROCEDURE DIVISION header or the ENTRYstatement, the contents of the area at the address specified for anactual argument are received.

A CONST type specifier can be designated in the declaration ordefinition of a variable at the address specified by an actualargument. When this happens, do not change the contents of the

area at the address specified by the actual argument.

Return Codes (Function Values)

Values set to special register PROGRAM-STATUS are passed toC programs as function values. C programs receive the functionvalues as the long int type.

Correspondence of Data Types

The combination of the attributes of data passed betweenCOBOL and C programs are optional. The following table liststhe basic correspondence of data items between COBOL and C

programs.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 393/783

370  Chapter 10. Calling Programs (Inter-Program Communication)

For the COBOL internal format, refer to the “COBOL85 ReferenceManual.” For the C internal expression format, refer to Clanguage manuals.

Table 42. Correspondence between COBOL data items and C data types

COBOL Data Item C Data Type COBOL Coding Example CDeclarationExample

Size

Alphabetic oralphanumeric

char, chararraytype or struct(structuretype)

77 A PIC X.

01 B PIC X(20).

char A;

char B[20];

1 byte

20 bytes

External decimal

(*1)

char array

type, or struct(structuretype)

77 C PIC S9(5) SIGN IS

LEADING SEPARATE

char C[6]; 6 bytes

Binary (*2) short int

long int

01 D PIC S9(4) COMP-5

77 E PIC S9(9) COMP-5

short int D;

long int E;

2 bytes

4 bytesGroup item (*3) char, char

array type, orstruct

(structuretype)

01 FGRP  02 F1 PIC S9(4) COMP-5.  02 F2 PIC X(4).

Struct{ short intF1; char

F2[4];}FGRP;

6 bytes

Internal floating-point(single-precision)double-precision)

float

double

01 G COMP-1.

01 H COMP-2.

float G;

float H;

4 bytes

8 bytes

*1 The internal format of COBOL external decimal items are character strings consisting ofcharacters indicating signs and numeric characters. In the C program, therefore, these aretreated as character data but not as numeric data. To handle external decimal items asnumeric data in the C program, the data type must be converted in the C program.*2 Binary items are applicable to short int or long int of the C program depending on thenumber of digits as follows:

- Up to 4 digits: short int- 5 to 9 digits : long int

A binary item with a fraction part is converted to a floating-point item, then passed.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 394/783

Chapter 10. Calling Programs (Inter-Program Communication) 371

*3 When declaring group items as structure, note the storage boundary of variables included

in the structure. To align the data item storage boundary with COBOL, specify theSYNCHRONIZED clause in the data description entry. For details, refer to the “COBOL85Reference Manual.” For C variable storage boundary alignment, refer to C languagemanuals.

Compiling Programs

When calling a C program with the CALL statement with aliteral specified, and if the program is compiled with compileroption ALPHAL specified, the desired program may not becalled since the program name is always treated as beinguppercase. Specify compiler option NOALPHAL whencompiling programs.

For example:

 CALL "abc".

When compiler option NOALPHAL is specified, program "abc"is called upon execution of the CALL statement.

When compiler option ALPHAL is valid, program "ABC" iscalled upon execution of the CALL statement.

 MOVE "abc" TO A. CALL A.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 395/783

372  Chapter 10. Calling Programs (Inter-Program Communication)

Program "abc" is called regardless of whether or not compileroption ALPHAL or NOALPHAL is specified.

A COBOL program compiled with compiler option ALPHALspecified can be called from a C program. If so, the desiredprogram may not be called since the program name specified in

the PROGRAM-ID paragraph is always treated as beinguppercase. Specify compiler option NOALPHAL whencompiling programs.

For example:

 PROGRAM-ID. abc.

When compiler option NOALPHAL is specified, the programname is "abc".

When compiler option ALPHAL is valid, the program name is"ABC".

When compiling a C program to be linked to a COBOL program,an option with which the DS and SS registers are discriminatedand the memory model is large (for example, Microsoft Ccompiler option/ALw) must be specified. (16)

Since COBOL85 supports multiple data segments (you can writethe Data Division of 64 K bytes or more), DS and SS registers donot always have the same address. The operation, therefore, maybe undefined when a C program operating on the assumptionthat DS and SS registers have the same address is called. C run-

time libraries have many functions that process DS and SS on theassumption that they are the same.

In addition, suppressing stack checks and adding Windowsprologue and epilogue codes to all FAR functions (usingMicrosoft C compiler option/Gws) in C programs executedunder the Windows environment must be specified.

When compiling a C program to be linked to a COBOL program,an option (/Gs) to suppress stack checks and an option (/G3) to

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 396/783

Chapter 10. Calling Programs (Inter-Program Communication) 373

optimize the program for 80386 processor. For details, refer to theVisual C++ on-line Help. (32)

Because data names used in C and COBOL are the same, theunderscore (_) can be used for the data name.

Linking Programs

Library F1BCOWEP.LIB provided by the COBOL85 run-timesystem includes the following functions (16):

• WEP

• LIBENTRY

• LIBMAIN

When linking C programs that call COBOL programs (16), thefile specification order in the LINK command depends onwhether executable files are generated by linking C programsthat call COBOL programs or dynamic link libraries (DLLs) aregenerated.

Examples of linking C programs that call COBOL programs areshown below. To link C programs that call COBOL programs,link option /NOD must be specified.

 (1) Generating executable files from C programs that callCOBOL programs:

LINK /NOD Cprog.OBJ, Cprog.EXE, Cprog.MAP, CimplibLIBW, Cprog.DEF

CPROG.OBJ

C program object file name.

CPROG.EXE

Name of the executable file to be generated.

CPROG.MAP

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 397/783

374  Chapter 10. Calling Programs (Inter-Program Communication)

Map file name (optional).

CIMPLIB

Import library of C run-time library. Refer to a C manual. WithMicrosoft C, LLIBCEW is applicable to this import library.

LIBW(.LIB)Windows function import library name.

CPROG.DEF

C program module definition file name.

F1BCCIMP.LIB is required to call JMPCINT2 or JMPCINT3.

(2) Generating executable files from COBOL programs and Cprograms that call COBOL programs:

LINK /NOD COB.OBJ Cprog.OBJ, COB.EXE, COB.MAP, F1BCCIMPF1BCARMV.LIBCimplib LIBW, COB.DEF

COB.OBJ

COBOL program object file name.COB.EXE

Name of the executable file to be generated.

COB.MAP

Map file name (optional).

F1BCCIMP(.LIB) F1BCARMV.LIB

COBOL run-time system import library name.

CIMPLIB

Import library of C run-time library.

LIBW(.LIB)

Windows function import library name.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 398/783

Chapter 10. Calling Programs (Inter-Program Communication) 375

COB.DEF

COBOL program module definition file name.

To generate an executable file by linking a COBOL program to aC program, the import library of the run-time library (COBOLrun-time system) of the program having the WinMain functionmust be specified first.

For example, when a COBOL program has the WinMain function(when compiled with compiler option MAIN specified), specifythe import library of the COBOL run-time system prior to that ofthe C run-time library. Doing so prevents the startup routineprovided by the import library of the C run-time library from

being linked to the COBOL program.(3) Generating DLLs from C programs that call COBOLprograms:

LINK /NOD Cprog.OBJ LIBENTRY.OBJ, Cprog.DLL, Cprog.MAP, CimplibLIBW, Cprog.DEF

CPROG.OBJ

C program object file name.

LIBENTRY.OBJ

Name of the initialization function to be dynamically linked.

CPROG.DLL

Name of the DLL to be generated.

CPROG.MAP

Map file name (optional).

CIMPLIB

Import library of C run-time library. Refer to C manuals. WithMicrosoft C, LDLLCEW is applicable to this import library.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 399/783

376  Chapter 10. Calling Programs (Inter-Program Communication)

LIBW(.LIB)

Windows function import library name.

CPROG.DEF

C program module definition file name.

(4) Generating DLLs from COBOL programs and C programsthat call COBOL programs:

LINK /NOD COB.OBJ Cprog.OBJ F1BCOWEP.OBJ, COB.DLL, COB.MAP,F1BCCIMPF1BCARMV Cimplib LIBW,COB.DEF

COB.OBJ

COBOL program object file name.

CPROG.OBJ

C program object file name.

F1BCOWEP.LIB

Name of the initialization function to be dynamically linked.

COB.DLL

Name of the DLL to be generated.

COB.MAP

Map file name (optional).

F1BCCIMP(.LIB) F1BCARMV.LIB

COBOL run-time system import library name.

CIMPLIB

Import library of C run-time library.

LIBW(.LIB)

Windows function import library name.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 400/783

Chapter 10. Calling Programs (Inter-Program Communication) 377

COB.DEF

COBOL program module definition file name.

To generate the DLL, except for the following cases, linkF1BCOWEP.LIB, which contains the DLL initialization function

(LibMain) and the termination function (WEP):• The C program provides DLL initialization and termination

functions.

• Microsoft C V7.0 or later is used.

To link F1BCOWEP.LIB, specify it in the object field on thecommand line.

When linking C programs that call COBOL programs (32), thefile specification order in the LINK command depends onwhether executable files are generated by linking C programsthat call COBOL programs or dynamic link libraries (DLLs) aregenerated.

Examples of linking C programs that call COBOL programs are

shown below.(1) Generating executable files from C programs that callCOBOL programs:

LINK Cprog.OBJ Cimplib /OUT:Cprog.EXE

CPROG.OBJ

C program object file name.CPROG.EXE

Name of the executable file to be generated.

CIMPLIB

Import library of C run-time library. Refer to C manuals.

F3BICIMP.LIB is required to call JMPCINT2 or JMPCINT3.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 401/783

378  Chapter 10. Calling Programs (Inter-Program Communication)

(2) Generating executable files from COBOL programs and Cprograms that call the COBOL programs:

LINK COB.OBJ Cprog.OBJ F3BICIMP.LIB COB.EXP LIBC.LIB KERNEL32.LIBUSER32.LIB/OUT:COB.EXE

COB.OBJCOBOL program object file name.

COB.EXE

Name of the executable file to be generated.

F3BICIMP.LIB

COBOL run-time system import library.

COB.EXP

COBOL program export file generated by the LIB command.

LIBC.LIB KERNEL32.LIB USER32.LIB

C run-time library import library name required by COBOL

To generate an executable file by linking a COBOL program to aC program, the import library of the run-time library (COBOLrun-time system) of the program having the WinMain functionmust be specified first.

For example, when a COBOL program has the WinMain function(when compiled with compiler option MAIN specified), specify

the import library of the COBOL run-time system prior to that ofthe C run-time library. Doing so prevents the startup routineprovided by the import library of the C run-time library frombeing linked to the COBOL program.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 402/783

Chapter 10. Calling Programs (Inter-Program Communication) 379

(3) Generating DLLs from C programs that call COBOLprograms:

(Generating a C program export file):

 LIB /DEF:Cprog.DEF /OUT:Cprog.LIB /MACHINE:IX86

(Generating a COBOL program import library):

 LIB /DEF:COB.DEF /OUT:COB.LIB /MACHINE:IX86

(Generating a DLL):

LINK Cprog.OBJ Cprog.EXP COB.LIB Cimplib /DLL/OUT:Cprog.DLL

CPROG.DEF

C program module definition file name .

CPROG.LIB

C program import library name.

COB.DEF

COBOL program module definition file name.

COB.LIB

COBOL program import library name.

CPROG.OBJ

C program object file name.

CPROG.DLL

Name of the DLL to be generated.

CPROG.EXP

C program export file.

CIMPLIB

Import-library of C run-time library. Refer to C manuals.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 403/783

380  Chapter 10. Calling Programs (Inter-Program Communication)

(4) Generating DLLs from COBOL programs and C programsthat call the COBOL programs:

(Generating an export file):

 LIB /DEF:COB.DEF /OUT:COB.LIB /MACHINE:IX86

(Generating a DLL):LINK COB.OBJ F3BICIMP.LIB COB.EXP LIBC.LIB KERNEL32.LIBUSER32.LIB/DLL /OUT:COB.DLL

COB.DEF

COBOL program module definition file name.

COB.LIB

COBOL program import library name.

COB.OBJ

COBOL program object file name.

F3BICIMP.LIB

COBOL run-time system import library.

COB.EXP

COBOL program export file generated by the LIB command.

LIBC.LIB KERNEL32.LIB USER32.LIB

C run-time library import library name required by COBOL.

COB.DLL

Name of the DLL to be generated.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 404/783

Chapter 10. Calling Programs (Inter-Program Communication) 381

Executing Programs

When calling COBOL programs from C programs, no COBOLrun-time options can be specified for arguments of functions that

call COBOL programs. The run-time options are treated the sameas other arguments and are not handled as COBOL run-timeoptions even if specified.

Do not use the exit function to unconditionally terminate Cprograms called from COBOL programs.

Do not use the STOP RUN statement to terminate COBOL

programs called from C programs with JMPCINT2.Unlike C character strings, no null characters are insertedautomatically at the end of COBOL character strings.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 405/783

382  Chapter 10. Calling Programs (Inter-Program Communication)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 406/783

Chapter 11. Using ACCEPT andDISPLAY Statements

This chapter offers tips on using the ACCEPT and DISPLAYstatements, including I-O destination types and specificationmethods, using console windows, message boxes, and programusing files, and entering current date and time. Additionally,Chapter 11 describes fetching command line arguments andenvironment variable handling.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 407/783

384 Chapter 11. Using ACCEPT and DISPLAY Statements

ACCEPT/DISPLAY Function

This section explains how the ACCEPT/DISPLAY function

inputs and outputs data with ACCEPT and DISPLAYstatements. For a sample program using the ACCEPT/DISPLAYfunction, refer to the “Getting Started with Fujitsu COBOL”guide.

Outline

With the ACCEPT/DISPLAY function, data is input and outputwith console windows, message boxes, and files. Additionally,the current date and time can be read from the system.

Use the ACCEPT statement to input data, and use the DISPLAYstatement to output data.

Figure 107. The ACCEPT/DISPLAY function

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 408/783

Chapter 11. Using ACCEPT and DISPLAY Statements 385

Input/Output Destination Types and SpecificationMethods

The input/output destination of data depends on:

• ACCEPT statement FROM specification

• DISPLAY statement UPON specification

• Compiler option specifications

• Setting of run-time environment information

The following table lists the relationship between thesespecifications and input/output destinations.

Table 41. Input/output destinations of the ACCEPT/DISPLAY function

FROM or UPONSpecification

Compile Option to beSpecified

Run-timeEnvironmentInformationSetting 

Input/Output Destination

1) None or function-nameSYSIN/SYSOUT(*1)

None

SSIN (run-timeenvironmentinformation name)

SSOUT (run-timeenvironmentinformation name)

Enter a file namefor the run-timeenvironmentinformation name

Display unit (console window)

File (*2)

2) Function-name

SYSERR

Enter a blank for

@MessOutFile

Enter a file namefor @MessOutFile

Display unit (message box)

File

3) Function-nameCONSOLE(*1)

Display unit (console window)

C CC S S

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 409/783

386 Chapter 11. Using ACCEPT and DISPLAY Statements

*1 1) and 3) cannot both be used simultaneously in the program through its completeexecution. The direction specified in the first ACCEPT or DISPLAY statement executed in theprogram becomes effective.*2 When SYSIN and SYSOUT are specified for compiler options SSIN and SSOUT asenvironment variable names, the input source and output destinations are system standardinput and output.

Reading/Writing Data with Console Windows

This section explains how to write, compile, link, and executeprograms, and provides an example of the simplest coding usingconsole windows.

IDENTIFICATION DIVISION.

 PROGRAM-ID. program-name.DATA DIVISION. WORKING-STORAGE SECTION.  01 data-name ... .PROCEDURE DIVISION.  ACCEPT data-name.  DISPLAY data-name.  DISPLAY "nonnumeric-literal".  EXIT PROGRAM.END PROGRAM program-name.

Console Windows

In a console window, data is read from or displayed on a displayunit with the ACCEPT/DISPLAY function. One console windowis provided for each COBOL program run unit.

A console window is generated by the ACCEPT or DISPLAYstatement first executed in the program run unit, and is closedupon normal termination of the run unit.

The attributes of console windows can be changed with theCOBOL initialization file (COBOL85.CBR). The following tablelists the attributes that can be changed and the specificationmethods.

Ch t 11 U i ACCEPT d DISPLAY St t t 387

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 410/783

Chapter 11. Using ACCEPT and DISPLAY Statements 387

Table 42. Changing the attributes of console windows

Attribute Run-time EnvironmentInformation

Setting Value Meaning  

Automatic windowclosing

@WinCloseMsg

(*1)

ON

OFF

Closes the window afterdisplaying a message

Closes the windowwithout displaying amessage

Window size @CnslWinSize (m,n) Specifies the size of awindow with thenumber of lines (m) andthe number of columns(n)

Number of lines fordata to be retained

@CnslBufLine Number of lines Data for the number ofspecified lines isretained and can bebrowsed by verticallyscrolling the window

*1 This run-time environment information is also valid for windows used with the screenoperation function.

Program Specifications

This section explains the program descriptions for each COBOLdivision.

ENVIRONMENT DIVISION

No specifications are required.

DATA DIVISION

In the DATA DIVISION, define data items to store input dataand items to set output data. Define the data items with one ofthe following attributes:

• Group item

• Alphabetic item

388 Chapter 11 Using ACCEPT and DISPLAY Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 411/783

388 Chapter 11. Using ACCEPT and DISPLAY Statements

• Alphanumeric item

• Binary item

• Internal decimal item

• External decimal item

• Alphanumeric edited item

• Numeric edited item

• National item

• National edited item

National item and national edited item cannot be used in an

ACCEPT statement.

PROCEDURE DIVISION

Use an ACCEPT statement to input data from a console window.Input data is stored in a data-name specified in an ACCEPTstatement for the length (80 alphanumeric characters if defined as

01 input-data PIC X(80)) defined for the data-name.If the length of input data is less than that of data to be stored,the input request is repeated.

For character data, the input request is repeated until the entereddata satisfies the specified length.

For numeric data, the input request is repeated until the Enter or

Return key is pressed.Use a DISPLAY statement to output data to a console window.

When a data-name is specified in a DISPLAY statement, datastored in the data-name is output.

When a nonnumeric literal is specified in a DISPLAY statement,a specified character string is output.

Chapter 11 Using ACCEPT and DISPLAY Statements 389

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 412/783

Chapter 11. Using ACCEPT and DISPLAY Statements 389

Program Compilation and Linkage

Do not specify compiler options SSIN and SSOUT.

Program Execution

Execute programs like ordinary programs.

Data input is requested on a console window when an ACCEPTstatement in a program is executed. Enter data as required.

Input data is set for the data item for the length (80 bytes)specified in an ACCEPT statement. If the length of input data isless than that of the data item, the input request is repeated.

For character data, the input request is repeated until the entereddata satisfies the specified length.

For numeric data, the input request is repeated until the Enter orReturn key is pressed.

When a DISPLAY statement in the program is executed, data isoutput to the console window.

To associate data at one entry with one ACCEPT statement, usefunction-name CONSOLE. When function-name CONSOLE isused, space is filled if the length of input data is less than that ofthe data item.

390 Chapter 11. Using ACCEPT and DISPLAY Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 413/783

390 Chapter 11. Using ACCEPT and DISPLAY Statements

 IDENTIFICATION DIVISION.  PROGRAM-ID. A. ENVIRONMENT DIVISION.  CONFIGURATION SECTION.  SPECIAL-NAMES.  CONSOLE IS CONS.

 DATA DIVISION.  WORKING-STORAGE SECTION.  01 data-1 PIC X(80). PROCEDURE DIVISION.  ACCEPT data-1 FROM CONS.  DISPLAY data-1 UPON CONS.  EXIT PROGRAM. END PROGRAM A.

Writing Messages to Message Boxes

This section explains how to write messages to message boxes.

 IDENTIFICATION DIVISION.  PROGRAM-ID. program-name. ENVIRONMENT DIVISION.  CONFIGURATION SECTION.  SPECIAL-NAMES.

  SYSERR IS mnemonic-name. DATA DIVISION.  WORKING-STORAGE SECTION.  01 data-name .... PROCEDURE DIVISION.  DISPLAY data-name UPON mnemonic-name.  EXIT PROGRAM. END PROGRAM program-name.

Message Boxes

Normally, COBOL program run-time messages are displayed inmessage boxes. With a COBOL program, messages other thanrun-time messages can also be displayed in the message boxes.Executing a DISPLAY statement opens a message box, andclicking on the OK button closes it.

Chapter 11. Using ACCEPT and DISPLAY Statements 391

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 414/783

p g

Program Specifications

This section explains program descriptions for each COBOLdivision.

ENVIRONMENT DIVISION

In the ENVIRONMENT DIVISION, associate a mnemonic-namewith function-name SYSERR.

DATA DIVISION

In the DATA DIVISION, define data items to set output data.

Define these data items with one of the following attributes:• Group item

• Alphabetic item

• Alphanumeric item

• External decimal item

• Alphanumeric edited item

• Numeric edited item

• National item

• National edited item

392 Chapter 11. Using ACCEPT and DISPLAY Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 415/783

PROCEDURE DIVISION

To send a message to a message box, use a DISPLAY statementwhere a mnemonic-name associated with function-name SYSERRis specified in the UPON clause.

If a data-name is specified in a DISPLAY statement, data storedin the specified data-name is output.

If a nonnumeric literal is specified, the specified character stringis output. The maximum length of the message that can bewritten at one time is the length of the data that can be displayedwithin the message box.

Program Compilation and Linkage

No specific compiler and linker options are required.

Program Execution

Execute programs as ordinary programs.

Programs Using Files

This section explains how to write, compile, link, and executeprograms, and provides an example of the simplest coding forfile processing using the ACCEPT/DISPLAY function.

Chapter 11. Using ACCEPT and DISPLAY Statements 393

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 416/783

 IDENTIFICATION DIVISION.  PROGRAM-ID. program-name. DATA DIVISION.  WORKING-STORAGE SECTION.  01 data-name ... PROCEDURE DIVISION.

  ACCEPT data-name.  DISPLAY data-name.  EXIT PROGRAM. END PROGRAM program-name.

Program Specifications

This section explains program descriptions for each COBOL

division.

ENVIRONMENT DIVISION

No specifications are required.

DATA DIVISION

In the DATA DIVISION, define data items to store input dataand items to set output data. Define these data items with one ofthe following attributes:

• Group item

• Alphabetic item

• Alphanumeric item

• External decimal item

• Alphanumeric edited item

• Numeric edited item

• National item

National edited item

394 Chapter 11. Using ACCEPT and DISPLAY Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 417/783

National item and national edited item cannot be used in anACCEPT statement.

PROCEDURE DIVISION

At program execution, an input file is opened with the firstACCEPT statement, and an output file is opened with the firstDISPLAY statement of the program. With subsequent ACCEPTand DISPLAY statements, data is read or output only.

The input and output files are closed upon termination ofprogram execution.

The input file is opened in input mode and used in share mode.Records are not locked during read.

The output file is opened in output mode and used in exclusivemode.

Line feed characters are not handled as data.

After a file is opened (after executing the first ACCEPT andDISPLAY statements), the input/output destination cannot be

changed with the environment variable operation function.

Inputting Data

Use an ACCEPT statement to input data from a file.

Data at the byte immediately before the line feed character ishandled as one record.

Input data is read by record. Input data is stored in a data-namespecified in an ACCEPT statement for the length (80alphanumeric characters if defined as 01 input-data PIC X(80))defined for the data-name. If the length of input data is less thanthat of data to be stored, the next record is read and linked to thepreviously read data.

In this case, line feed characters are not treated as data. Records

are read until the entered data satisfies the specified length.

Chapter 11. Using ACCEPT and DISPLAY Statements 395

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 418/783

Figure 108. Reading records

Outputting Data

Use a DISPLAY statement to send data to a file.

When a data-name is specified in a DISPLAY statement, thecontents stored in the data-name is output.

If a nonnumeric literal is specified in a DISPLAY statement, thespecified character string is output. With one DISPLAYstatement, the length of the line feed character plus output data

is the length of data to be output.

Figure 109. Using DISPLAY to output data

396 Chapter 11. Using ACCEPT and DISPLAY Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 419/783

Program Compilation and Linkage

To enter data from a file with ACCEPT, specify compiler optionSSIN. To send data to a file with DISPLAY, specify compileroption SSOUT.

For example:

 SSIN(INDATA),SSOUT(OUTDATA)

When SYSIN is specified to compiler option SSIN, a consolewindow is the data input destination of an ACCEPT statement,regardless of the specification of run-time environment

information SYSIN.When SYSOUT is specified to compiler option SSOUT, a consolewindow is the data output destination of a DISPLAY statement,regardless of the specification of run-time environmentinformation SYSOUT.

Program Execution

Specify the names of files used for input-output in the run-timeenvironment information specified for compiler options SSINand SSOUT.

For example:

 INDATA=A:\IN.DAT OUTDATA=A:\OUT.DAT

If a specified file already exists at the output destination, the fileis recreated (previous data is deleted).

Chapter 11. Using ACCEPT and DISPLAY Statements 397

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 420/783

Entering Current Date and Time

This section explains how to write, compile, link, and executeprograms for entering the current date and time by using system

clocks with the ACCEPT/DISPLAY function. IDENTIFICATION DIVISION.  PROGRAM-ID. program-name. DATA DIVISION.  WORKING-STORAGE SECTION.  01 date-1 PIC 9(6).  01 day-1 PIC 9(5).  01 day-of-week-1 PIC 9(1).  01 time-1 PIC 9(8). PROCEDURE DIVISION.

  ACCEPT date-1 FROM DATE.  ACCEPT day-1 FROM DAY.  ACCEPT day-of-week-1 FROM DAY-OF-WEEK.  ACCEPT time-1 FROM TIME.  EXIT PROGRAM. END PROGRAM program-name.

Programs Descriptions

This section explains program descriptions for each COBOLdivision.

ENVIRONMENT DIVISION

No specifications are required.

DATA DIVISIONIn the DATA DIVISION, define the data items required to storeinput data.

398 Chapter 11. Using ACCEPT and DISPLAY Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 421/783

PROCEDURE DIVISION

To input the current date and time, use an ACCEPT statement inwhich DATE, DAY, DAY-OF-WEEK, or TIME are written for theFROM specification.

Program Compilation and Linkage

No specific compiler and linker options are required.

Program Execution

Execute programs as ordinary programs.When an ACCEPT statement in a program is executed, thecurrent date and time are set for the data-name specified in anACCEPT statement.

For example: 12-23-1991 (Mon.) 14:15:45.00

Table 43. Entering current date and time

Coding of FROM Specification Contents Set for the Data-NameFROM DATE |9|1|1|2|2|3|FROM DAY |9|1|3|5|7|FROM DAY-OF-WEEK |1|FROM TIME |1|4|1|5|4|5|0|0|

Chapter 11. Using ACCEPT and DISPLAY Statements 399

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 422/783

Fetching Command Line Arguments

This section explains how to refer to the counts and values of

arguments specified for commands that call programs.

 IDENTIFICATION DIVISION.  PROGRAM-ID. program-name. ENVIRONMENT DIVISION.  CONFIGURATION SECTION.  SPECIAL-NAMES.  ARGUMENT-NUMBER IS mnemonic-name-1.  ARGUMENT-VALUE IS mnemonic-name-2.

 DATA DIVISION.  WORKING-STORAGE SECTION.  01 data-name-1 ... .  01 data-name-2 ... .  01 data-name-3 ... . PROCEDURE DIVISION.  ACCEPT data-name-1 FROM mnemonic-name-1.  [DISPLAY numeric literal UPON mnemonic-name-1.]  [DISPLAY data-name-2 UPON mnemonic-name-1.]  ACCEPT data-name-3 FROM mnemonic-name-2  [ON EXCEPTION ... ].

 END PROGRAM program-name.

Outline

During program execution, the values of environment variablescan be referred to and updated.

To obtain the number of arguments, use an ACCEPT statementfor which a mnemonic-name corresponding to function-nameARGUMENT-NUMBER is specified.

To refer to an argument value, use a DISPLAY statement forwhich a mnemonic-name corresponding to function-nameARGUMENT-NUMBER is specified and an ACCEPT statement

for which a mnemonic-name corresponding to function-nameARGUMENT-VALUE is specified.

400 Chapter 11. Using ACCEPT and DISPLAY Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 423/783

A character string delimited with spaces or quotation marks (") iscounted as one argument.

The following is an example of an input command:

 SAMPLE M.HORIUCHI 901234 SHIZUOKA

Program Specifications

This section explains program descriptions for each COBOLdivision when command line argument handling function areused.

ENVIRONMENT DIVISION

Associate the following function-names with mnemonic-names:

• ARGUMENT-NUMBER

• ARGUMENT-VALUE

 ENVIRONMENT DIVISION.  CONFIGURATION SECTION.  SPECIAL-NAMES.

  ARGUMENT-NUMBER IS mnemonic-name-1.  ARGUMENT-VALUE IS mnemonic-name-2.

DATA DIVISION

Define data items to deliver values.

Table 44. Counts and values of arguments

Contents AttributeNumber of arguments Unsigned integer itemArgument position (not required ifspecified with a literal)

Unsigned integer item

Argument value Fixed-length group item or alphanumeric data item

Chapter 11. Using ACCEPT and DISPLAY Statements 401

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 424/783

The following is a definition example of data items:

 DATADIVISION.  WORKING-STORAGE SECTION.  01 number-of-arguments PIC 9(2) BINARY.  01 argument-position PIC 9(2) BINARY.  01 argument-value.  02 argument-value PIC X(10) OCCURS 1 TO 10 TIMES  DEPENDING ON number-of-arguments.

PROCEDURE DIVISION

To obtain the number of arguments, use an ACCEPT statementwhere a mnemonic-name corresponding to function-nameARGUMENT-NUMBER is specified.

To refer to an argument value, first, specify the argumentposition with DISPLAY statement (1) corresponding to function-name ARGUMENT-NUMBER. Then, fetch the value with anACCEPT statement (2) corresponding to function-nameARGUMENT-VALUE.

If the position of a non-existing argument is specified (forexample, 4 is specified although there are only three arguments),

an exception condition occurs and the statement (3) specified forON EXCEPTION is executed.

At the start of program execution when a DISPLAY statement isnot executed, the argument position is 1.

For each subsequent execution of the ACCEPT statement, theargument position is moved to the next argument.

For argument positioning, 0 to 99 can be specified. 0 is thecommand itself.

 DISPLAY 5 UPON mnemonic-name-1. ... (1) ACCEPT argument-value(5) FROM mnemonic-name-2 ... (2)  ON EXCEPTION MOVE 5 TO error-number GO TO ERROR PROCESS ... (3) END-ACCEPT.

If an argument value is referred to without executing a DISPLAY

statement for positioning, the argument position is 1 at the start

402 Chapter 11. Using ACCEPT and DISPLAY Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 425/783

of program execution. For each subsequent execution of theACCEPT statement, the argument position is moved to the nextargument.

The lengths of argument values cannot be obtained.

The rules for the COBOL MOVE statement are applied to the

setting of data items for the number of arguments and argumentvalues.

  :  01 number-1 PIC 9.  01 argument-1 PIC X(10).  :  ACCEPT number-1 FROM argument-number. ... (1)  ACCEPT argument-1 FROM argument-value. ... (2)

If statement (1) is executed when the number of argumentsspecified in the command is 10, the contents of "number-1" is 0.

If statement (2) is executed when the value of an argument to befetched is "ABCDE", the content of "argument-1" is as follows:

A B C D E Blank Blank Blank Blank

If statement (2) is executed when the value of an argument to be

fetched is "ABCDE12345FGHIJ", the content of "argument-1" is asfollows:

A B C D E 1 2 3 4 5

Program Compilation and Linkage

No specific compiler and linker options are required.

Program Execution

Execute programs as ordinary programs.

This can be used only with a COBOL program activated by thesystem.

Chapter 11. Using ACCEPT and DISPLAY Statements 403

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 426/783

With a COBOL program called from another COBOL program,the value of an argument to be referred to is that of an argumentspecified on a command line activated from the system.

Environment Variable Handling Function

This section explains how to refer to and update the values ofenvironment variables. Environment variables explained in thissection indicate run-time environment information set atprogram execution.

 IDENTIFICATION DIVISION.

  PROGRAM-ID. program-name. ENVIRONMENT DIVISION  CONFIGURATION SECTION.  SPECIAL-NAMES.  ENVIRONMENT-NAME IS mnemonic-name-1.  ENVIRONMENT-VALUE IS mnemonic-name-2. DATA DIVISION.  WORKING-STORAGE SECTION.  01 data-name-1 ... .  01 data-name-2 ... . PROCEDURE DIVISION.

  DISPLAY { "nonnumeric-literal" }  { } UPON mnemonic-name-1.  { data-name-1 }

  ACCEPT data-name-2  FROM mnemonic-name-2 [ON EXCEPTION ...].

  DISPLAY { "nonnumeric-literal" }  { } UPON mnemonic-name-1.  { data-name-1 }

  DISPLAY data-name-2  UPON mnemonic-name-2 [ON EXCEPTION ...].

 END PROGRAM program-name.

Outline

During program execution, the values of environment variablescan be referred to and updated.

404 Chapter 11. Using ACCEPT and DISPLAY Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 427/783

To refer to the value of an environment variable, use a DISPLAYstatement where a mnemonic-name corresponding to function-name ENVIRONMENT-NAME is specified and an ACCEPTstatement for which a mnemonic-name corresponding tofunction-name ENVIRONMENT-VALUE is specified.

To update the value of an environment variable, use a DISPLAYstatement where a mnemonic-name corresponding to function-name ENVIRONMENT-NAME is specified and a DISPLAYstatement where a mnemonic-name corresponding to function-name ENVIRONMENT-VALUE is specified.

Programs Specifications

This section explains program descriptions for each COBOLdivision when using the environment variables handlingfunction.

ENVIRONMENT DIVISION

Associate the following function-names with mnemonic-names:

• ENVIRONMENT-NAME

• ENVIRONMENT-VALUE

DATA DIVISION

Define data items to deliver values.

Table 45. Attributes of environment variablesContents AttributeName of an environment variable (not required if specifiedwith a literal)

Fixed-length group item or alphanumericdata item

Value of an environment variable (not required if specifiedwith a literal)

Fixed-length group item or alphanumericdata item

Chapter 11. Using ACCEPT and DISPLAY Statements 405

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 428/783

PROCEDURE DIVISION

To refer to the value of an environment variable, first, specify theenvironment variable name to be referred to with a DISPLAYstatement (1) where a mnemonic-name corresponding tofunction-name ENVIRONMENT-NAME is specified. Then, referto the value of the environment variable with an ACCEPT

statement (2) where a mnemonic-name corresponding tofunction-name ENVIRONMENT-VALUE is specified.

If the name of the environment variable to be referred to has notbeen specified or the name of a non-existing environmentvariable has been specified, an exception condition occurs. In thiscase, a statement (3) specified for ON EXCEPTION is executed.

To update the value of an environment variable, first, specify theenvironment variable name to be updated with a DISPLAYstatement (4) where a mnemonic-name corresponding tofunction-name ENVIRONMENT-NAME is specified. Then,update the value of the environment variable with a DISPLAYstatement (5) where a mnemonic-name corresponding tofunction-name ENVIRONMENT-VALUE is specified.

If the name of the environment variable to be updated has notbeen specified or the area to set the value of the environmentvariable cannot be assigned, an exception condition occurs. Inthis case, a statement (6) specified for ON EXCEPTION isexecuted.

406 Chapter 11. Using ACCEPT and DISPLAY Statements

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 429/783

 DISPLAY "TMP1" UPON environment-variable-name ... (1) ACCEPT value-of-TMP1  FROM environment-variable-value ... (2)  ON EXCEPTION ... (3)  MOVE occurrence-of-error TO ... END-ACCEPT.  : DISPLAY "TMP2" UPON environment-variable-name. ... (4) DISPLAY value-of-TMP2

  UPON environment-variable-value ... (5)  ON EXCEPTION ... (6)  MOVE occurrence-of-error TO ... END-DISPLAY.

The lengths of environment variables cannot be obtained.

Program Compilation and Linkage

No specific compiler and linker options are required.

Program Execution

Execute programs as ordinary programs.

The value of an environment variable changed during programexecution is valid only in the process being executed by theprogram, but is invalid for programs after the process isterminated.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 430/783

Chapter 12. UsingSORT/MERGE Statements (Sort-Merge Function)

Sort rearranges the records in a file according to a certainsequence, while merge integrates the records in multiple filesinto one file. This chapter describes the sort/merge function,looking at the types of sort and merge processing.

408 Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 431/783

Outline of Sort and Merge Processing

This section outlines sort and merge processing.

Sort

Sort means that records in a file are rearranged in ascending ordescending order using record information as a sort key. Therecords are rearranged according to the attribute of the programkey item.

Figure 110. Sorting records

Merge

Merge means that records in multiple files with records sorted inascending or descending order are integrated into one file.

Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function) 409

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 432/783

Figure 111. Merging records

Using Sort

This section explains the types of sort processing and how towrite, compile, and link a program that uses sort processing.

410 Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 433/783

Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function) 411

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 434/783

Types of Sort Processing

The following four types of sort processing are possible:

1. All records in the input file are sorted in ascending ordescending order, then are written to the output file: (Input)

file (Output) file2. All records in the input file are sorted in ascending or

descending order, then are handled as output data: (Input)file (Output) records

3. Specific records or data items are sorted in ascending ordescending order, then are written to the output file: (Input)

record (Output) file4. Specific records or data items are sorted in ascending or

descending order, and are handled as output data: (Input)record (Output) record

When sorting records in the input file (file to sort) withoutchanging their contents, sort processing type 1 or 2 is normallyused. When an input file is not used or the contents of a record ischanged, sort processing type 3 or 4 is used.

When writing sorted records to the output file withoutprocessing the contents of each record, sort processing type 1 or 3is used. When the output file is not used or the contents of eachrecord is changed, sort processing type 2 or 4 is used.

Program Specifications

This section explains the contents of a program that sorts recordsfor each COBOL division.

412 Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 435/783

ENVIRONMENT DIVISION

The following files must be defined.

• Sort-merge file

A work file for sort processing must be defined. The ASSIGNclause is assumed as a comment; up to 8 alphanumericcharacters must be specified in it.

• Input file

Define the same way as for ordinary file processing, ifrequired.

• Output file

Define the same way as for ordinary file processing, ifrequired.

When performing merge processing within the same program,define only one sort-merge file.

DATA DIVISION

Define the records of files defined in the ENVIRONMENTDIVISION.

PROCEDURE DIVISION

The SORT statement is used for sort processing. The contents ofthe SORT statement differ depending on what is used for input-output:

• For file input, "USING input-file-name" must be specified.

• For record input, "INPUT PROCEDURE input-procedure-

name" must be specified.

Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function) 413

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 436/783

• For file output, "GIVING output-file-name" must be specified.

• For record output, "OUTPUT PROCEDURE output-procedure-name" must be specified.

The input procedure specified in INPUT PROCEDURE can passrecords to be sorted one-by-one with the RELEASE statement.

The output procedure specified in OUTPUT PROCEDURE canreceive sorted records one-by-one with the RETURN statement.

Multiple sort keys can be specified.

When all records are sorted, the sort result is set in specialregister SORT-STATUS. Special register SORT-STATUS need notbe defined in the COBOL program since it is automatically

generated.

By checking the SORT-STATUS value after the SORT statement isexecuted, COBOL program execution can continue even if sortprocessing terminates abnormally. Setting 16 in SORT-STATUSin the input or output procedure specified by the SORTstatement terminates sort processing.

The following table lists the valid values for special registerSORT-STATUS and their meanings.

Table 46. SORT-STATUS values and their meanings

Value Meaning  0 Normal termination16 Abnormal termination

Any input and output files used must be closed during SORTstatement execution.

Program Compilation and Linkage

Compiler option EQUALS must be specified as required.

414 Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 437/783

When more than one record has the same sort key value in sortprocessing, EQUALS guarantees that the records are written inthe same order as they are read.

Note: Using this compiler option degrades performance.

Program Execution

Execute the program that uses sort as follows:

1. Set environment variable BSORT_TMPDIR.

A work file called the sort-merge file is required for sortprocessing. The sort-merge file is temporarily created in the

directory specified in environment variable BSORT_TMPDIR.When the directory is not specified in the environment variable,it is temporarily created in the directory specified in environmentvariable TEMP. These environment variables must be set inadvance.

2. Assign input and output files

When input and output files are defined using file-identifiers,use these identifiers as environment variables to set the names ofinput and output files.

3. Execute the program

Note: When PowerBSORT is installed, PowerBSORT will be usedalthough the sort/merge process is handled by the COBOL85

run-time system.

Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function) 415

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 438/783

Using Merge

This section explains the types of merge processing and how towrite, compile, link, and execute a program that uses mergeprocessing.

416 Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 439/783

Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function) 417

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 440/783

Types of Merge Processing

The following two types of merge processing are possible:

1. Write all records in multiple files already sorted in ascendingor descending order to the output file in ascending or

descending order: (Input) file (Output) file2. Processing all records in multiple files already sorted in

ascending or descending order as output data in ascending ordescending order: (Input) file (Output) records

When merged records are written to the output file withoutchanging the record contents, merge processing type 1 is

normally used. When an output file is not used or recordcontents are changed, merge processing type 2 is used.

Program Specifications

This section explains the contents of a program that uses mergefor each COBOL division.

ENVIRONMENT DIVISION

The following files must be defined:

• Sort-merge file

A work file for merge processing must be defined. TheASSIGN clause is assumed as a comment; up to 8alphanumeric characters must be specified in it.

• Input file

All files to be merged must be defined.

418 Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 441/783

• Output file

Define the same way as for ordinary file processing, ifrequired.

When sort is performed within the same program, only one sort-merge file must be defined.

DATA DIVISION

Define the records of files defined in the ENVIRONMENTDIVISION.

PROCEDURE DIVISION

The MERGE statement is used for merge processing. Thecontents of the MERGE statement differ depending on whetherfile or record output is to be used for merge processing:

• For file output, "GIVING output-file-name" must be specified.

• For record output, "OUTPUT PROCEDURE output-procedure-name" must be specified.

The output procedure specified in OUTPUT PROCEDURE canreceive merged records one-by-one by using the RETURNstatement.

Multiple merge keys can be specified.

When all records are merged, the merge result is set in specialregister SORT-STATUS.

Unlike general data, special register SORT-STATUS need not bedefined in the COBOL program since it is automaticallygenerated. By checking the SORT-STATUS value after MERGEstatement execution, COBOL program execution can continueeven if merge processing terminates abnormally.

Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function) 419

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 442/783

Setting 16 in SORT-STATUS in the output procedure specified bythe MERGE statement terminates merge processing. Thefollowing table lists the possible values for special register SORT-STATUS and their meanings.

Table 47. SORT-STATUS values and their meanings

Value Meaning  0 Normal termination16 Abnormal termination

Any input and output files used must be closed during MERGEstatement execution.

Program Compilation and Linkage

No specific compiler or linkage options are required.

Program Execution

1. Set environment variable BSORT_TMPDIR.

A work file called the sort-merge file is required for mergeprocessing. The sort-merge file is temporarily created in thedirectory specified in environment variable BSORT_TMPDIR.

When the directory is not specified in the environment variable,it is temporarily created in the directory specified in environmentvariable TEMP. These environment variables must be set in

advance.2. Assign input and output files.

When input and output files are defined using file-identifiers,use these identifiers as environment variables to set the names ofinput and output files.

3. Execute the program.

420 Chapter 12. Using SORT/MERGE Statements (Sort-Merge Function)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 443/783

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 444/783

Chapter 13. System ProgramDescription (SD) Functions

This chapter describes the system program description (SD)functions used to code a system program. Included in thischapter are explanations of how to use pointers, the ADDR andLENG functions, and the PERFORM statement without an “atend” condition.

422 Chapter 13. System Program Description (SD) Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 445/783

Types of System Program DescriptionFunctions

COBOL85 has the following functions that are not included inthe COBOL standards. These functions are called the systemprogram description (SD) functions in COBOL85. The followingSD functions are useful for the description of a system program:

• Pointer

• ADDR function and LENG function

• PERFORM statement without an “at end” condition

The following section outlines and explains the features of eachfunction.

Pointer 

An area with a specific address can be referenced and updatedusing a pointer.

For example, when a parameter identifying an area address isused to call a COBOL program from a program written inanother language, the area contents at that address can bereferenced or updated with a pointer in the COBOL program.

ADDR Function and LENG Function

The ADDR function can obtain the address of a data item definedby COBOL.

The LENG function can obtain the lengths of a data item and

literal defined by COBOL in bytes.

Chapter 13. System Program Description (SD) Functions 423

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 446/783

For example, an area address or length can be passed as aparameter to call a program written in another language from aCOBOL program.

PERFORM Statement without an “at end” Condition

In COBOL85, the PERFORM statement can be written withoutsetting an “at end” condition. For example, repeat processing canbe terminated by determining the processing result during repeatprocessing.

Using Pointers

This section explains how to use pointers.

IDENTIFICATION DIVISION.PROGRAM-ID. program-name.

DATA DIVISION.BASED-STORAGE SECTION.01 data-name-1 [BASED ON pointer-1].

77 data-name-2 ... [BASED ON pointer-2].WORKING-STORAGE SECTION.01 pointer-1 POINTER.LINKAGE SECTION.01 pointer-2 POINTER.

PROCEDURE DIVISION USING pointer-2.MOVE [pointer-1 =>] data-name-1 ... .IF [pointer-2 =>] data-name-2 ... .

END PROGRAM program-name.

Outline

A pointer is used to reference an area having a specific address.The following data items are required to use a pointer:

• Data item defined in BASED-STORAGE section (1)

• Data item whose attribute is pointer data item (2)

424 Chapter 13. System Program Description (SD) Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 447/783

The pointer is normally used with the pointer qualifier (=>). (1)is pointed to by (2). This is called pointer qualification, as shownin the following example:

(2) => (1)

In this case, the contents of (1) are those of the area whose

address is set in (2).

Program Specifications

This section explains the contents of a program that uses pointersfor each COBOL division.

ENVIRONMENT DIVISION

No specifications are required.

DATA DIVISION

The data-names where addresses are specified for reference orupdate must be defined in the BASED-STORAGE section. Thedata-names for storing addresses (with the attribute of pointerdata item (POINTER)) must also be defined in the FILE section,WORKING-STORAGE section, BASED-STORAGE section, andLINKAGE section.

Defining Data-Names in BASED-STORAGE Section

A data-name can be defined in the BASED-STORAGE section byusing a data description entry the same way as defining ordinarydata.

An actual area is not secured for a data-name defined in the

BASED-STORAGE section during program execution. Thus,

Chapter 13. System Program Description (SD) Functions 425

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 448/783

when referencing a data item defined in BASED-STORAGE,specify the address of the area to reference.

When the BASED ON clause is specified in a data descriptionentry, the data-name can be used without pointer qualificationsince a pointer is implicitly given by the data-name specified inthe BASED ON clause. When using a data-name where the

BASED ON clause is not specified, pointer qualification isrequired.

PROCEDURE DIVISION

A data-name with a pointer given can be specified in suchstatements as the MOVE and IF statements just like an ordinary

data-name.

Program Compilation and Linkage

No specific compiler and linkage options are required.

Program Execution

No specific environment settings are required.

426 Chapter 13. System Program Description (SD) Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 449/783

Using the ADDR and LENG Functions

This section explains how to use the ADDR and LENG functions.

IDENTIFICATION DIVISION.PROGRAM-ID. program-name.

DATA DIVISION.WORKING-STORAGE SECTION.01 data-name-1 ... .01 pointer-1 POINTER.01 data-name-2.02 ... [ OCCURS ... DEPENDING ON ...].01 data-name-3 PIC 9(4) BINARY.

PROCEDURE DIVISION.MOVE FUNCTION ADDR(data-name-1) TO pointer-1.

MOVE FUNCTION LENG(data-name-2) TO data-name-3.END PROGRAM program-name.

Outline

The ADDR function returns the address of a data item as afunction value. The LENG function returns the size of a data item

or literal in bytes.

Program Specifications

This section explains the contents for each COBOL division of aprogram that uses the ADDR and LENG functions.

ENVIRONMENT DIVISION

No specifications are required.

Chapter 13. System Program Description (SD) Functions 427

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 450/783

DATA DIVISION

The data-names for storing functions values returned by theADDR and LENG functions must be defined.

The attribute of a function value of the ADDR function is a

pointer data item.

The attribute of a function value of the LENG function is anumeric data item.

PROCEDURE DIVISION

The ADDR and LENG functions can be specified in suchstatements as the MOVE and IF statements, the same as withordinary data-names.

Program Compilation and Linkage

No specific compiler and linkage options are required.

Program Execution

No specific environment settings are required.

428 Chapter 13. System Program Description (SD) Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 451/783

Using the PERFORM Statement without an“at end” Condition

This section explains how to use the PERFORM statementwithout an “at end” condition.

IDENTIFICATION DIVISION.PROGRAM-ID. program-name.

PROCEDURE DIVISION.PERFORM WITH NO LIMITIF ...EXIT PERFORMEND-IF

:END-PERFORM.END PROGRAM program-name.

Outline

When using a conventional PERFORM statement to determine

the “at end” condition during repeat processing, complexprogram specifications are required. Using the PERFORMstatement without an “at end” condition simplifies programspecifications.

Program Specifications

This section explains the contents of each division of a COBOLprogram that uses the PERFORM statement without an “at end”condition.

ENVIRONMENT DIVISION

No specifications are required.

Chapter 13. System Program Description (SD) Functions 429

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 452/783

DATA DIVISION

No specifications are required.

PROCEDURE DIVISION

WITH NO LIMIT must be specified for the PERFORM statementto eliminate an “at end” condition.

For repeat processing executed by the PERFORM statement, astatement determining the “at end” condition and a statement toexit repeat processing must be specified.

If a statement for exiting repeat processing is not specified,

processing continues infinitely (in an infinite loop).

Program Compilation and Linkage

No specific compiler and linkage options are required.

Program Execution

No specific environment settings are required.

430 Chapter 13. System Program Description (SD) Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 453/783

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 454/783

Chapter 14. CommunicationFunctions

This chapter explains the presentation file module (asynchronousmessage communication/synchronous communicationprograms) and simplified inter-application communicationfunctions provided for message communication from COBOLprograms.

432 Chapter 14. Communication Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 455/783

Communication Types

This section explains the features and usage of the threefunctions provided for message communication from COBOL

programs:

• Presentation file module (asynchronous messagecommunication)

• Presentation file module (synchronous communicationprograms)

Simplified inter-application communication function.Table 48. Differences between the presentation file module and simplified inter-

application communication function

Feature Presentation File Simplified Inter-application

Communicationfunction

Asynchronousmessagecommunication

Synchronouscommunicationprograms

Asynchronousmessagecommunication

Communicationmode

[Client]Windows 3.1Windows NT[Server] (*A)Windows NTDS90K series

[Cooperate]Windows 95Windows NTDS90HP (*B)S familyGS-seriesSURE system (*B)

[Client]Windows 95Windows 3.1Windows NTDS90HP[Server] (*A)Windows 95

Windows NTDS90HP

Chapter 14. Communication Functions 433

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 456/783

Table 48. Differences between the presentation file module and simplified inter-application communication function (cont.)

Feature Presentation File Simplified Inter-application

Program definition - Presentation file description- Communication record description- OPEN statement

- READ statement- WRITE statement- CLOSE statement

- Communicationrecord description- Call function of

simple applicationcommunicationapparatus ability byCALL statement

Requiredproduct(s)

RDB/7000 Server forWindows NTBS*NET (*C)

IDCM None

Use Use for messagecommunication

When decentralizeddevelopmentbetween mutualsystems bycommunication ofreal time is done

At messagecommunication withCOBOL unit

(*A) The application can be started in the server system.(*B) Cannot cooperate with the COBOL application.(*C) Cannot cooperate with a Windows client.

434 Chapter 14. Communication Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 457/783

Using Presentation File Module(Asynchronous Message Communication)

This section explains how to use the presentation file module forasynchronous message communication, and describes theoperating environment and creation of COBOL source programs.

 IDENTIFICATION DIVISION.  PROGRAM-ID. program-name. ENVIRONMENT DIVISION.  INPUT-OUTPUT SECTION.  FILE-CONTROL.  SELECT file-name

  ASSIGN TO GS-file-identifier  SYMBOLIC DESTINATION IS "ACM"  DESTINATION-1 IS logical-destination-name-notification-area  [PROCESSING MODE IS processing-type-notification-area]  [PROCESSING TIME IS monitoring-time-notification-area]  [MESSAGE CLASS IS priority-notification-area]  [FILE STATUS IS input-output-status-1 input-output-status-2]. DATA DIVISION.  FILE SECTION.  FD file-name  [RECORD IS VARYING IN SIZE DEPENDING ON record-size].

  01 communication-record-name ... .  WORKING-STORAGE SECTION.  01 logical-destination-name-notification-area PIC X(8). [01 processing-type-notification-area PIC X(2).] [01 monitoring-time-notification-area PIC 9(4).] [01 priority-notification-area PIC 9.] [01 input-output-status-1 PIC X(2).] [01 input-output-status-2 PIC X(4).] [01 record-size PIC 9(5).] PROCEDURE DIVISION.  OPEN I-O file-name.

  MOVE logical-destination-name  TO logical-destination-name-notification-area.  [MOVE processing-type TO processing-type-notification-area.]  [MOVE monitoring-time TO monitoring-time-notification-area.]  [MOVE priority TO priority-notification-area.]  WRITE communication-record-name.  READ file-name.  CLOSE file-name. END PROGRAM program-name.

Chapter 14. Communication Functions 435

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 458/783

Outline

The presentation file module performs asynchronous messagecommunication using connected product communicationfunctions.

The following figure outlines data transfer through thepresentation file module.

Figure 112. Outline of data transfer using the presentation file module(asynchronous message communication)

Operating Environment

To use the presentation file module, use connected products toenable communication functions.

This section gives an example using RDB/7000 servers forWindows NT. The following figure is a diagram of the operatingenvironment using the presentation file module with the servers.

436 Chapter 14. Communication Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 459/783

With Server (Windows NT)

With Client-Server (Windows NT - Windows NT)

Figure 113. Operating environment for using the presentation file module(asynchronous message communication)

Program Specifications

This section explains the contents of a program using the

presentation file module (asynchronous messagecommunication).

ENVIRONMENT DIVISION

Define a presentation file in the same manner as you define ageneral file. Write a file control entry in the file control paragraph

Chapter 14. Communication Functions 437

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 460/783

of the input-output section. The following table lists theinformation to be specified in the file control entry.

Table 49. Information to be specified in the file control entry

Location Information Type Details and Use of SpecificationRequired SELECT clause File name Specify the file name used in the

COBOL program. The file name

must comply with the COBOLuser-defined words rules.ASSIGN clause File-reference-identifier Specify in the "GS-file-identifier"

format. This file identifier is usedas run-time environmentinformation for specifying theconnected product name at run-time.

SYMBOLIC-

DESTINATIONclause

Destination type Specify "ACM".

DESTINATIONclause

Data-name Specify a data-name defined as an8-byte alphanumeric data item inthe WORKING-STORAGE sectionor LINKAGE section. The logicaldestination name of input-outputprocessing must be specified forthis data-name whencommunication starts.

Optional FILE STATUSclause

Data-name Specify a data-name defined as a2-byte alphanumeric data item inthe WORKING-STORAGE sectionor LINKAGE section. Theexecution results of input-outputprocessing must be specified forthis data-name. See Appendix B,

“I-O Status List” for the value tobe specified. Specify a 4-bytealphanumeric data item fordetailed information.

438 Chapter 14. Communication Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 461/783

Table 49. Information to be specified in the file control entry (cont.)

Location Information Type Details and Use of SpecificationOptional MESSAGE

CLASS clauseData-name Specify a data-name defined as a

1-byte numeric item in theWORKING-STORAGE section orLINKAGE section. Input-outputprocessing priority (1-9) must be

specified for this name whencommunication starts. A value of1 specifies the highest priority. Ifthe default or 0 is specified, thesystem assumes the lowest level ofspecified logical destination.

PROCESSINGMODE clause

Data-name Specify a data-name defined as a2-byte alphanumeric data item inthe WORKING-STORAGE section

or LINKAGE section. The type ofinput-output processing must bespecified for this data-name whencommunication starts. See Table50.

PROCESSINGTIME clause

Data-name Specify a data-name defined as a4-byte numeric item in theWORKING-STORAGE section orLINKAGE section. Input-outputprocessing monitoring time mustbe specified in seconds for thisdata-name when communicationstarts. If the default or 0 isspecified, the system assumesinfinite wait time.

Chapter 14. Communication Functions 439

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 462/783

Table 50. Processing types and values to be specified

Processing Mode Control Information

Input Queuing notspecified

"NW" If there is no data at the logical destination, thesystem posts "0A" as the input-output status.

Queuingspecified

"WT"Blank

If there is not data at the logical destination, thesystem follows the monitoring time

specification and waits until data is written.Output Queuing not

specified"NW" If the maximum amount of data is written to

the logical destination, the system cancels writeprocessing and posts "9G" as the input-outputstatus.

Queuingspecified

"WT"Blank

If the maximum amount of data is written tothe logical destination, the system follows themonitoring time specification and waits untildata has been read.

Forcedexecutionspecified

"NE" If the maximum amount of data has beenwritten to the logical destination, the systemwrites data exceeding the maximum amountand posts "0B" as the input-output status.

DATA DIVISION

Write the record definition to be used for communication and thedata definition specified in the file control entry.

PROCEDURE DIVISION

Use input-output statements for communication processing inthe same manner as for general file processing:

• OPEN statement : Starts message send-receive processing.

• READ and WRITE statements: Send and receive messages.

• CLOSE statement: Quits message send-receive processing.

440 Chapter 14. Communication Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 463/783

OPEN and CLOSE Statements

Execute an OPEN statement to start message send-receiveprocessing. Execute a CLOSE statement to quit message send-receive processing.

READ and WRITE Statements

To send a message, use the WRITE statement where thecommunication record is specified. To receive a message, use theREAD statement where the presentation file is specified.

Before executing the READ or WRITE statement, specify thelogical destination name for the data name specified in theDESTINATION-1 clause. Messages are sent to and received from

the destination of the specified logical destination name.

Program Compilation and Linkage

No specific compiler or linkage options are required.

Program Execution

This section shows the environment setup for executing aprogram that sends and receives messages by using thepresentation file module.

Specify the name of the connected product to use with the file

identifier as the environment variable name.For example, to specify the ASSIGN clause of the COBOLprogram:

ASSIGN TO GS-ACMFILE

Chapter 14. Communication Functions 441

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 464/783

The initial file contents are:

 [program-name]  : ACMFILE=,ACM  :

Specify "ACM" (connected product name) for the file identifier

specified in the ASSIGN clause of the COBOL file.Specify a comma (,) before "ACM".

If the connected product is not specified for the file identifier, theconnected product specified in the environment variable@CBR_PSFILE_ACM is used.

@CBR_PSFILE_ACM=ACM

For details, refer to “Environment Variables” in Chapter 5.

To use ACM communication from a COBOL program using thepresentation file module, set up the ACM environment beforeexecuting the COBOL program.

Using ACM Communication

ACM communication is used through the presentation filemodule. ACM communication can also be used from COBOLprograms by using the CALL statement to call an ACM-supported COBOL subroutine.

442 Chapter 14. Communication Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 465/783

Using Presentation File Module(Synchronous Communication Programs)

This section explains how to use the presentation file module forsynchronous communication programs, describes the operatingenvironment and the creation of COBOL source programs, andprovides instructions on how to communicate betweenprograms.

IDENTIFICATION DIVISION.  PROGRAM-ID. program-name. ENVIRONMENT DIVISION.

  INPUT-OUTPUT SECTION.  FILE-CONTROL.  SELECT file-name  ASSIGN TO GS-file-identifier  SYMBOLIC DESTINATION IS "APL"  [SESSION CONTROL IS conversation-information-notification-region  [MESSAGE MODE IS message-kind-notification-region  [DESTINATION-1 IS logical-destination-1  [DESTINATION-2 IS logical-destination-2  [MESSAGE OWNER IS transmission-right-information-notification-region]  [MESSAGE CODE IS reason-code-notification-region

  [PROCESSING CONTROL IS extended-message-control-information-region]  [FILE STATUS IS input-output-status-1 input-output-status-2]. DATA DIVISION.  FILE SECTION.  FD file-name  [RECORD IS VARYING IN SIZE DEPENDING ON record-size].WORKING-STORAGE SECTION. [01 conversation-information-notification-region PIC X.] [01 message-kind-notification-region PIC X.] [01 logical-destination-notification-region-1 PIC X(8).] [01 logical-destination-notification-region-2 PIC X(8).]

 [01 transmission-right-information-notification-region PIC ~.] [01 reason-code-notification-region PIC ~.] [01 input-output-status-1 PIC X(2).] [01 input-output-status-2 PIC X(4).] [01 size-of-record PIC 9(5).]PROCEDURE DIVISION.  OPEN I-O file-name.  [MOVE conversation-information  TO conversation-information-notification-region.  [MOVE message-kind TO message-kind-notification-region.]  [MOVE logical-destination-1

Chapter 14. Communication Functions 443

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 466/783

  TO logical-destination-notification-region-1.]  [MOVE logical-destination-2  TO logical-destination-notification-region-2.]  [MOVE transmission-right-information  TO transmission-right-information-notification-region.]  [MOVE reason-code TO reason-code-notification-region.]  WRITE communication-record-name.  READ file-name.  CLOSE file-name. END PROGRAM program-name.

Outline

The presentation file module performs synchronouscommunication programs using the synchronous communicationprograms of IDCM.

The following figure outlines data transfer through the use ofIDCM.

444 Chapter 14. Communication Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 467/783

Figure 114. Outline of data transfer using the presentation file module (synchronouscommunication programs)

Note: Refer to the “IDCM User’s Guide” for the types ofnetworks that can be connected.

Chapter 14. Communication Functions 445

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 468/783

Program Specifications

This section explains the contents of a program using thepresentation file module (synchronous communicationprograms).

ENVIRONMENT DIVISION

Define a presentation file in the same manner as you define ageneral file. Write a file control entry in the file control paragraphof the input-output section.

The following table lists the information to be specified in the filecontrol entry.

Table 51. Information to be specified in the file control entry

Location Information Type Details and Use of Specification

Required SELECT clause File name Specify the file name used inCOBOL program. The file namemust comply with the COBOL

user-defined words rules.ASSIGN clause File-reference- identifier Specify in the "GS-file identifier"

format. This file identifier is usedas run-time environmentinformation for specifying theconnected product name at run-time.

SYMBOLIC-DESTINATIONclause

Destination type Specify "APL".

446 Chapter 14. Communication Functions

Table 51 Information to be specified in the file control entr (cont )

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 469/783

Table 51. Information to be specified in the file control entry (cont.)

Location InformationType

Details and Use of Specification

Optional FILE STATUSclause

Data name Specify a data-name defined as a 2-bytealphanumeric data item in theWORKING-STORAGE section orLINKAGE section. The execution results

of input-output processing must bespecified for this data-name. SeeAppendix B, “I-O Status List” for thevalue to be specified. Specify a 4-bytealphanumeric data item for detailedinformation.

SESSIONCONTROLclause

Data name Specify a data-name defined as a 1-bytenumeric item in the WORKING-STORAGE section or LINKAGE section.

Input-output processing priority (1-9)must be specified for this name whencommunication starts. A value of 1specifies the highest priority. If thedefault or 0 is specified, the systemassumes the lowest level of specifiedlogical destination.

MESSAGEMODE clause

Data name Specify a data-name defined as a 1-bytenumeric item in the WORKING-STORAGE section or LINKAGE section.Input-output processing priority (1-9)must be specified for this name whencommunication starts. A value of 1specifies the highest priority. If thedefault or 0 is specified, the systemassumes the lowest level of specifiedlogical destination.

Chapter 14. Communication Functions 447

Table 51 Information to be specified in the file control entry (cont )

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 470/783

Table 51. Information to be specified in the file control entry (cont.)

Optional DESTINATION-1 clause

Data-name Specify a data-name defined as an 8-bytealphanumeric data item in theWORKING-STORAGE section orLINKAGE section. The logicaldestination name of input-outputprocessing must be specified for this

data-name when communication starts.DESTINATION-2 clause

Data-name Specify a data-name defined as an 8-bytealphanumeric data item in theWORKING-STORAGE section orLINKAGE section. The logicaldestination name of input-outputprocessing must be specified for thisdata-name when communication starts.

MESSAGE

OWNER clause

Data-name Specify a data-name defined as a 1-byte

numeric item in the WORKING-STORAGE section or LINKAGE section.Input-output processing priority (1-9)must be specified for this name whencommunication starts. A value of 1specifies the highest priority. If thedefault or 0 is specified, the systemassumes the lowest level of specifiedlogical destination.

MESSAGECODE clause

Data-name Specify a data-name defined as a 1-32767digit alphanumeric character in theWORKING-STORAGE section orLINKAGE section. This sets the reasoncodes that will be given in the event offorce-ended communication.

PROCESSINGCONTROLclause

Data-name Specify a data-name defined as analphanumeric character of the digitprovided by IDCM in the WORKING-STORAGE section or LINKAGE section.

448 Chapter 14. Communication Functions

Note: Refer to the online help in the IDCM software

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 471/783

Note: Refer to the online help in the IDCM softwaredevelopment kit for more details on the settings for the optionalclauses.

DATA DIVISION

Write the record definition to be used for communication and thedata definition specified in the file control entry.

PROCEDURE DIVISION

Use input-output statements for communication processing inthe same manner as for general file processing:

• OPEN statement : Starts message send-receive processing.

• READ and WRITE statements: Send and receive messages.

• CLOSE statement: Quits message send-receive processing.

OPEN and CLOSE Statements

Execute an OPEN statement to start message send-receiveprocessing. Execute a CLOSE statement to quit message send-receive processing.

READ and WRITE Statements

To send a message, use the WRITE statement where thecommunication record is specified. To receive a message, use the

READ statement where the presentation file is specified.

Before executing the READ or WRITE statement, specify thelogical destination name for the data name specified in theDESTINATION-1 clause. Messages are sent to and received fromthe destination of the specified logical destination name.

Chapter 14. Communication Functions 449

Program Compilation and Linkage

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 472/783

Program Compilation and Linkage

No specific compiler or linkage options are required.

Program Execution

The communication environment of IDCM should bestraightened from the execution of the COBOL program whenthe program which communicates between programs which usethe display file function is executed. Refer to the “IDCM User’sGuide” and the online help in the IDCM software developmentkit for additional details.

Using Simplified Inter-applicationCommunication

This section explains how to use simplified inter-application

communication. For more information about how to usesimplified inter-application communication, refer to the sampleprograms in the “Getting Started with Fujitsu COBOL” guide.

Outline

Simplified inter-application communication is used to transfermessages between programs.

Messages are transferred between programs through the logicaldestination of a communication system process (called a server)that controls messages.

It generates logical destinations for storing messages in theserver.

450 Chapter 14. Communication Functions

A user send-receive program is called a client. Before starting theli li l i l d i i (l l l i l

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 473/783

client, connect a client logical destination (local logicaldestination) to a server logical destination (remote logicaldestination).

Consequently, if read-write processing is specified for the clientlogical destination, data is read from or written to the connected

server logical destination.A server can be operated under Windows 95 and Windows NT,and a client can be operated under Windows 95, Windows 3.1and Windows NT.

The following figure outlines simplified inter-applicationcommunication.

Figure 115. Outline of simplified inter-application communication

Operating Procedures

This section explains procedures for server and client operations

used to execute simplified inter-application communication.

Chapter 14. Communication Functions 451

The summary of procedures for server operation is:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 474/783

1. Set up the operating environment

2. Start the server (*)

3. Generate logical destinations (*)

4. Change the logical destination mode (*)

5. Collect logs (messages are received or sent by clients), displaylogical destination information

6. Quit the server

(*) These steps can be performed automatically by using the definition file.

452 Chapter 14. Communication Functions

The details of the above steps are given below:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 475/783

1. Simplified inter-application communication enablescommunication using the TCP/IP protocol with the Windowssocket API. To use simplified inter-application communication,set up an environment where the Windows socket API andTCP/IP protocol can be used.

• host file setup

The host name and IP address of the machine where theserver operates must be defined in the host files of themachines where clients operate.

• services file setup

A service name and port number must be defined in theservices files of the machines where the server and clientsoperate.

Any number can be defined as a port number unless thenumber is defined in another entry. A port number must beconsistent in local area networks (LANs) that use thesimplified inter-application communication function. For

example:

Service name: cobci

Port number/protocol: 20000/tcp

Using Windows 95:

After the TCP/IP protocol is installed, the hosts file and the

services file must be created using an editor. These files arestored in the directory where Windows 95 is installed. Note:the sample files (hosts.sam, services.sam) are also stored inthis directory.

Chapter 14. Communication Functions 453

Using Windows NT:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 476/783

If the TCP/IP protocol is installed, the hosts files and servicesfiles are created in directory system32/drivers/etc under thedirectory where Windows NT is installed.

2. to 4. Execute COBCISRV.EXE to start the server.

For screen operation and setup, see “Communication SystemEnvironment Setup Dialog Box” and “Simplified Inter-application Communication Server Window.”

The logical destinations have no permission for reading orwriting messages immediately after they are generated. Changethe logical destination mode to give read/write permission tothese destinations. The clients can then be started.

Only one server can be started on a machine.

Note: Steps 2 to 4 can be omitted by using a definition file. See“Starting by Using the Server Definition” for more details.

5. Logs can be collected, and logical destination information canbe displayed during client execution. For screen operation andsetup, see “Simplified Inter-application Communication ServerWindow.”

6. to 9. Switch the logical destination mode back to the originalmode. The logical destinations no longer have permission forreading and writing messages. Delete the messages and logicaldestinations, then quit the server.

The procedure for client operation:

1. Set up the operating environment

Define the information in the hosts files and services files. Seestep 1 of the procedure for server operation.

2. Create a logical destination definition file

454 Chapter 14. Communication Functions

Start the logical destination definition file creation utility((16): COBCIU16.EXE, (32): COBCIU32.EXE) to create a

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 477/783

((16): COBCIU16.EXE, (32): COBCIU32.EXE) to create alogical destination definition file. For the screen operationand setup, see “Logical Destination Definition File CreationUtility.”

3. Start the program

A client requires information regarding the logicaldestination definition file at run time. Therefore, specify@CBR_CIINF=definition-file-name in the initial file forCOBOL execution or in the Run-time Environment Setupwindow. Windows 95 and Windows NT are designed so thatthe definition file name can be directly specified in theenvironment variable.

The definition file name can be specified with the relative pathfrom the directory containing the executable client file.

Server Operation Windows

This section explains procedures for operating server windows:

• Communication System Environment Setup dialog box

• Simplified Inter-application Communication Server window

See “Log Collection” for the server error display format andresponse to server errors.

Communication System Environment Setup Dialog Box

Start the server, specify the maximum number of systemmessages and maximum waiting instructions in theCommunication System Environment Setup dialog box, thenclick on the OK button.

Chapter 14. Communication Functions 455

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 478/783

Figure 116. The Communication System Environment Setup dialog box

The server can be used. The Simplified Inter-applicationCommunication Server window is displayed.

• System max messages (0 to 999999999)

Specify the maximum number of messages that can be storedin the server.

If the default or 0 is specified, the system uses the maximumvalue. For the value to be specified, see “EstimatingMemory.”

Max waiting instructions (0 to 999999999)Specify the maximum number of read and write instructionsfrom clients that can be queued in the server.

If the default or 0 is specified, the system uses the maximumvalue. For the value to be specified, see “EstimatingMemory.”

456 Chapter 14. Communication Functions

Simplified Inter-application Communication Server Window

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 479/783

The following can be done in the Simplified Inter-applicationCommunication Server window:

• Logical destination operation (create, delete, change mode,

delete message, quit server)• Display information

• Logging

Figure 117. Simplified inter-application communication server window

Creating a Logical Destination

To create a logical destination, select Create logical destinationfrom the Logical destination operation menu, specify the logicaldestination name, the maximum number of messages, andpriority in the Create Logical Destination dialog box, then click

on the OK button.

Figure 118. The Create Logical Destination dialog box

Chapter 14. Communication Functions 457

A logical destination is generated.

The Create Logical Destination dialog box contains the following

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 480/783

The Create Logical Destination dialog box contains the followingelements:

Logical destination edit box

Specify the name of the logical destination to be generated inthe server.

The logical destination name can be up to eight alphanumericcharacters. The logical destination name for an opponentlogical destination is specified in the Client Definition dialogbox.

Max messages (0 to 999999999)

Specify the maximum number of messages that can be storedat the logical destination to be generated.

If the default or 0 is specified, the system uses the valuespecified for "System max messages" in the CommunicationSystem Environment Setup dialog box.

Priority (3 to 9)

Specify the number of priority levels in which messages canbe stored at the logical destination to be generated.

If the default or a value from 0 to 2 is specified, the systemassumes 9.

Deleting a Logical Destination

To delete a logical destination, select Delete logical destinationfrom the Logical destination operation menu, select the logicaldestination to be deleted in the Delete Logical Destination dialogbox, then click on the OK button.

The following are the requirements for deleting a logicaldestination:

•The logical destination contains no messages

458 Chapter 14. Communication Functions

• Inactive is specified for the read and write attributes

If Purge Message button is clicked, the message stored in the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 481/783

If Purge Message button is clicked, the message stored in theselected logical destination can be deleted.

Other logical destinations can be deleted continuously bypressing the Delete button.

Figure 119. The Delete Logical Destination dialog box

The Delete Logical Destination dialog box contains the followingelements:

LD name

Displays the logical destination name.

Current

Displays the number of the messages stored in a logicaldestination.

 Waitings

Displays the number of the instructions waiting in a logicaldestination.

OK button

Chapter 14. Communication Functions 459

Click to delete selected logical destinations and close theDelete Logical Destination dialog box.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 482/783

Cancel button

Click to cancel any deletions selected and return to the statebefore the Delete Logical Destination dialog box was opened.

Delete button

Click to continuously delete other logical destinations.

Purge Message button

Click to delete the messages stored in the selected logicaldestination.

Help button

Click to access the online help.

Changing a Logical Destination Mode

To change the mode of a logical destination, select Change modefrom the Logical Destination Operation menu, then change theread and write attributes of the logical destination in the Change

Mode of Logical Destination dialog box.Select a logical destination name from the list box, select either"Active" or "Inactive" for the read and write attributes, then clickon the OK button.

The logical destination attributes are changed.

You can change the mode of another logical destinations by

clicking the Change button.

460 Chapter 14. Communication Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 483/783

Figure 120. The Change Mode of Logical Destination dialog box

The Change Mode of Logical Destination dialog box contains thefollowing elements:

LD nameDisplays the logical destination name.

Read (status line)

Displays the active (Act) or inactive (-) read status of a logicaldestination.

 Write (status line)Displays the active (Act) or inactive (-) write status of alogical destination.

Chapter 14. Communication Functions 461

Read (radio buttons)

To read messages from the logical destination, select the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 484/783

g g ,"Active" radio button. If "Inactive" is clicked, messages cannotbe read from the logical destination.

 Write (radio buttons)

To write messages to the logical destination, select the"Active" radio button. If "Inactive" is clicked, messages cannotbe written to the logical destination.

Displaying Information

To display information, select Display information from theLogical Destination operation menu. The Logical Destination

Information dialog box is displayed.To update information, click on the Update button.

Figure 121. The Logical Destination Information dialog box

462 Chapter 14. Communication Functions

The Logical Destination Information dialog box contains thefollowing elements:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 485/783

Communication system set information

  - Max messages

  Displays the maximum number of messages that can bestored in the server.

  - Max waiting instruction

Displays the maximum number of read and writeinstructions that can be queued in the server.

LD name

Displays the names of generated logical destinations.

Read

Displays the read attribute of each logical destination. "Act"indicates that read is enabled; "-" indicates that read isdisabled.

 Write

Displays the write attribute of each logical destination. "Act"indicates that write is enabled; "-" indicates that write isdisabled.

Priority

Displays the number of priority levels where messages can bestored at each logical destination.

Max messages

Displays the maximum number of messages that can bestored at each logical destination.

Chapter 14. Communication Functions 463

Current

Displays the current number of messages that are stored at

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 486/783

each logical destination.

 Waiting 

Displays the number of read and write instructions that arequeued at each logical destination.

Log Collection

To collect logs, select Operate from the Logging menu. TheLogging Operation dialog box is displayed.

Figure 122. The Logging Operation dialog box

Acquire the log according to the following procedure:

1. Specify the name of the file for log collection.

2. Select either "Get error log" or "Get trace log".

3. Click on the Start logging button.

Log collection starts.

To quit log collection, click on the End logging button.

464 Chapter 14. Communication Functions

The name of the file for log collection can be specified with anabsolute or relative path. The path from the current serverdirectory serves as the relative path.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 487/783

y p

If the specified file does not exist, a new file is created. If thespecified file exists, log information is appended to the file.

Logs are classified into error information and trace information.

Select "Get error log" to collect server error information in the file.Select "Get trace log" to write server error information, processingrequests from clients, and processing results in the file.

Error information should be collected during server operation sothat server errors can be ascertained.

Use the trace information when you debug the client because

there is much output information.The following shows the log output format:

 < (1) > [ (2) ] ID: (3) Client: (4) EXE: (5) (6)

(1) Collection date and time(year/month/day/hours:minutes:seconds)

(2) Event

Chapter 14. Communication Functions 465

Table 52. Log Collection Explanation of Events

Event ExplanationOPEN req The client requested connection

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 488/783

OPEN req. The client requested connection.CLOSE req. The client requested disconnection.READ req. The client requested read processing.WRITE req. The client requested write processing.OPEN res. Connection processing for the client ended.

CLOSE res. Disconnection processing for the client ended.READ res. Read processing ended.WRITE res. Write processing ended.Communication error An error occurred during communication with the client.API error A Windows function error occurs.Internal conflict Internal conflict occurred.

(3) Client identification number

(4) Client IP address(5) Name of the client execution module (12 bytes). Excess bytesare truncated.

(6) Additional information

466 Chapter 14. Communication Functions

Table 53. Log Collection Additional Information

Event Additional InformationOPEN req ----

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 489/783

OPEN req. CLOSE req. ----READ req. Parameters of the COBCI_READ function (server-logical-

destination-name, buffer-length, processing-type, andmonitoring-time)

WRITE req. Parameters of the COBCI_WRITE function (server-logical-destination-name, message-length, priority, processing-type,and monitoring-time)

OPEN res. Error code (rtn: displayed in decimal) (*1)detail code (detail: displayed in decimal) (*1)

CLOSE res. Error code (rtn: displayed in decimal) (*1)detail code (detail: displayed in decimal) (*1)

READ res. Error code (rtn: displayed in decimal) (*1)detail code (detail: displayed in decimal) (*1)

WRITE res. Error code (rtn: displayed in decimal) (*1)detail code (detail: displayed in decimal) (*1)

Communication error Windows Sockets function name, error code (err: displayedin decimal) (*1)error content

API error Windows function name, error code (err: displayed indecimal) (*2)error content

Internal conflict Error content*1 See “Error Codes.”*2 See the Windows function error codes.

Only communication errors, API errors, and internal conflicts areoutput as error information.

The information from (3) to (6) is not always output.

Chapter 14. Communication Functions 467

The following table lists the responses to errors.

Table 54. Error responses

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 490/783

Event ResponseCommunication error Take action according to the corresponding error code (See the

Windows Sockets function error codes.) If the error value is 0, aclient communication error has probably occurred. See “ErrorCodes.”

API error A probable cause of the error is insufficient memory or diskresources. Review the operating environment.

Internal conflict Contact a Fujitsu systems engineer (SE).

Quitting a Server 

To quit or exit a server, select End server from the Logicaldestination operation menu.

All messages stored in a logical destination will be deleted whenEnd server is selected and the acquisition of the log is stopped.

Starting by Using a Server Definition File

The inter-application communication server can be started bycreating a server definition file which reads information on eachlogical destination.

Creating a Server Definition File

Use an editor to create a server definition file.

Note: If you change information on logical destinations (createnew logical destinations, change log file names, etc.) do not

update this file after starting the inter-application communicationserver.

Specifying a Server Definition File

If the execution environment information @CBR_CI_SRVINF isnot specified when the COBCISRV.EXE is started, the

468 Chapter 14. Communication Functions

COBSVINF.INI file in the directory where COBCISRV.EXE isstored will be used.

If the execution environment information @CBR_CI_SRVINF is

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 491/783

specified, it will then be used.

Use the AUTOEXEC.BAT file in Windows 95 to set the executionenvironment information and use the System in the Control

Panel in Windows NT.The full path name and the relative path name can be used forthe file name specified for execution environment information@CBR_CI_SRVINF. When the relative path name is used, itbecomes the relative path from the current directory when theInter-application Communication Server window is started. If thespecified file does not exist, the Communication System

Environment Set dialog box is displayed.

Server Definition File Description

[SRVINF] section

Necessary information is specified by the CommunicationSystem Environment Set dialog box and the Log Acquisition

Operation dialog box. The start and end methods for the inter-application communication server window can also be specified.

Chapter 14. Communication Functions 469

1. SysMaxMsg

SysMaxMsg=n

S f h b f

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 492/783

Specify the maximum number of system storage messagesset in the Communication System Environment Set dialogbox. The default is "999999999".

2. SysMaxWaitSysMaxWait=n

Specify the number of system waiting instructions set in theCommunication System Environment Set dialog box. Thedefault is "999999999".

3. StartMode

StartMode= { WINDOW | ICON }

Specify how to display the screen on server startup. You canhave a window (WINDOW) or an icon (ICON) appear atstartup.

4. IconMenu

IconMenu= { SYSDEF | CLOSEONLY }

Specify the type of system menu that starts with the icon.

SYSDEF: The default system menu is displayed.

CLOSEONLY: Only "Close" is displayed in the system menu.In this instance, you cannot change from an icon to a

window. Only when "ICON" is specified in "StartMode" canyou change from an icon to a window.

470 Chapter 14. Communication Functions

5. EndMode

EndMode= { MANUAL | AUTO }

S if th ti f th I t li ti C i ti

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 493/783

Specify the action of the Inter-application CommunicationServer window when Windows is shut down.

MANUAL: Displays a message which states that the Inter-

application Communication Server window is still runningafter ending Windows. After the Inter-applicationCommunication Server window is ended, Windows shouldbe shut down again.

AUTO: The Inter-application Communication Serverwindow ends with Windows shutdown. No message isdisplayed.

6. Log

Log= { YES | NO }

Specify whether or not to acquire the log. Specify either "YES"or "NO".

7. LogType

LogType= { ERROR | TRACE }

Specify the log type set in the Log Acquisition Operationdialog box.

ERROR: Specify the error log.

TRACE: Specify the trace log.

Only when "YES" is specified for "Log", will this item willbecome effective.

Chapter 14. Communication Functions 471

8. LogFileName

LogFileName=XXXXXXXX.XXX

Specify the log file name set in the Log Acquisition Operation

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 494/783

Specify the log file name set in the Log Acquisition Operationdialog box.

The full path name and the relative path name can be used

for the log file name. When the relative path name is used, itbecomes a relative path from the current directory.

The default is "COBCISRV.LOG".

Only when "YES" is specified for "Log", will this item willbecome effective.

[LDINF] section

Necessary information is specified by the Logical DestinationCreation dialog box and the Logical Destination Mode Changedialog box.

Specify this section in the following manner:

logical destination name= number of maximum storage message,number of maximum priority level, logical destination mode

If information regarding the number of maximum storagemessages is omitted, "," should still be specified.

1. Logical destination name

Specify the logical destination name set in the LogicalDestination Creation dialog box.

The logical destination name can be up to 8 alphanumericcharacters in length. There is no default.

472 Chapter 14. Communication Functions

2. Number of maximum storage messages

Specify the number of maximum storage messages set in theLogical Destination Creation dialog box.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 495/783

The default is the maximum number of system storagemessages (SysMaxMsg).

3. Number of maximum priority level

Specify the maximum priority level number set in the LogicalDestination Creation dialog box.

The default is "9".

4. Logical destination mode

Specify each logical destination mode set in the Logical

Destination Mode Change dialog box. When the server isstarted, each logical destination will be set in the modeaccording to its specification.

RDWR : Read / write is acceptable.

READ : Read is acceptable; write is not.

WRITE : Read is not acceptable; write is acceptable.

The default is "RDWR".

Note: A line in the server definition file which starts with asemicolon (;) is interpreted as a comment.

Chapter 14. Communication Functions 473

The following is an example of a server definition file.[SRVINF]; Number of System maximum storage messageSysMaxMsg=100

N b f S t iti i t ti

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 496/783

; Number of System waiting instructionSysMaxWait=50; Screen display when server startsStartMode=ICON; System menu when starts with iconIconMenu=; Movement when Windows is endedEndMode=AUTO; Presence of log acquisitionLog=YES; Log kindLogType=TRACE; Log file nameLogFileName=LOGDATA.TXT

[LDINF]; Logical destination name= number of maximum storage; message, number of maximum priority level, logical destination; modeLD1=100, 9, READLD2= , ,WRITELD3=500, ,LD4= , ,

Client Operation Window

This section explains the procedure for operating the logicaldestination definition file creation utility in a client window.

474 Chapter 14. Communication Functions

Logical Destination Definition File Creation Utility

Start the logical destination definition file creation utility ((16):

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 497/783

COBCIU16.EXE, (32): COBCIU32.EXE), specify the name of thedefinition file to be created in the Select Definition File dialogbox, then click on the OK button.

If the specified file does not exist, a new file is created. If anexisting file is specified, information is appended to the file.

The Client Definition dialog box is displayed.

Figure 123. The Client Definition dialog box

Chapter 14. Communication Functions 475

The Client Definition dialog box contains the following elements:Server name

Specify a logical name for the server that sends messages to

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 498/783

or receives messages from a client. You can specify anyserver name. The server name can be up to 15 alphanumericcharacters in length.

Server machine name

Specify the host name of the machine at which the server isoperating. The server machine name can be up to 15alphanumeric characters in length.

Client LD name

Specify the logical destination name of the client. The clientlogical destination name can be up to eight alphanumericcharacters in length.

Server LD name

Specify the logical destination name of the server to beconnected to the client logical destination. The server logicaldestination name can be up to eight alphanumeric charactersin length.

Specify the server name, then specify the server machine name,client logical destination name, and server logical destinationname. If information (server machine name, client logicaldestination name, or server logical destination name) is alreadydefined for the specified server name, the information is

displayed.Only one server machine name can be specified for a servername. Client logical destination names and server logicaldestination names, however, can be specified for a server name.

Verify that the selected server name is correct, then register anew server name by clicking on the Associate LD button.

476 Chapter 14. Communication Functions

If a logical destination and its opponent logical destination areboth applied to an already registered server name, use the Deletebutton in the Logical Destination Information group box to selectthe correct logical destination.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 499/783

To delete all the information (server machine name, client logicaldestination name, and server logical destination name) of thespecified server, click on the Delete button in the Setting

Contents group box.

If the specified file does not exist, a new file is created. If anexisting file is specified, information is appended to the file.

Chapter 14. Communication Functions 477

The following is an example of creating a logical destinationdefinition file with this utility:

[SERVERNAME_DEF_LIST]SERVER1=SERVERNAME }SERVER2=SERVERNAME } (1)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 500/783

SERVER2=SERVERNAME } (1)SERVER3=SERVERNAME }

[SERVER1] (2)@HOSTNM=SRV1 (3)

[SERVER1.LD] (4)MYLD1=LD1 }MYLD2=LD2 } (5)MYLD3=LD3 }

[SERVER2]  :[SERVER2.LD]  :[SERVER3]

  :[SERVER3.LD]  :

(1) server-name=SERVERNAME

(2) [server-name]

(3) @HOSTNM=server-machine

(4) [server-name.LD]

(5) client-LD-name=server-LD-name

478 Chapter 14. Communication Functions

Estimating Memory

This section explains how to estimate memory for the server

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 501/783

when simplified inter-application communication is used.

• Memory for messages stored at a logical destination

A message written to a logical destination is managed withan additional control area of 160 bytes. The memory requiredfor a message is the message length + 160 bytes.

• Memory for queuing instructions

A queuing read instruction is managed in a control area of160 bytes. The memory required for a queuing read

instruction is 160 bytes.

As with a message stored at a logical destination, a queuingwrite instruction is managed with an additional control area of160 bytes. The memory required for a queuing write instructionis the message length + 160 bytes.

The maximum memory required for the server depends on the

following values specified in the system:

• System max messages (Maximum number of messages)

• Max waiting instructions (Maximum number of instructions)

Chapter 14. Communication Functions 479

Determine the maximum memory required for the server basedon the following formula:

Memory required for server = M * (160 + ML) + WR * 160 + WW *(160 + ML)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 502/783

where the following conditions are satisfied:

MM =< M

MW =< WR + WW

• M: Number of messages stored at the logical destination

• ML: Message length (bytes)

• WR: Number of queuing read instructions

• WW: Number of queuing write instructions

• MM: Maximum number of messages specified in the system(System max messages)

• MW: Maximum number of instructions specified in thesystem (Max waiting instructions)

Notes

1. If there is a forced ending of a client application:

If the power supply to the client terminal is cut off before theclient application writes back to the server, the waitinginstruction remains in the server.

If there is a forced ending of the client application by issuing

"Close", the waiting instruction corresponding to the clientapplication is automatically deleted in the server.

2. Messages are remaining when the Inter-applicationCommunication Server window ends:

When the Inter-application Communication Server windowends, all message on the server will be deleted.

480 Chapter 14. Communication Functions

Simplified Inter-application CommunicationFunctions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 503/783

This section explains the functions used in simplified inter-application communication.

Clients use the COBCI_OPEN, COBCI_CLOSE, COBCI_READ,and COBCI_WRITE simplified inter-application communicationfunctions with the CALL statement to transfer messages betweenthem.

[Calling sequence]

• COBCI_OPEN (Connection to the server)

• COBCI_READ/COBCI_WRITE (Message reading from theserver or writing to the server)

• COBCI_CLOSE (Disconnection from the server)

Chapter 14. Communication Functions 481

An example of these functions used in an application is shownbelow.

IDENTIFICATION DIVISION. PROGRAM-ID. Program-name.ENVIRONMENT DIVISION.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 504/783

DATA DIVISION. WORKING-STORAGE SECTION. 01 STATUS-RE.  05 ERROR PIC S9(9) COMP-5.

  05 DETAIL PIC S9(9) COMP-5. 01 SERVERNAME-REC PIC X(15). 01 SERVERHD-REC PIC S9(9) COMP-5. 01 UNUSED-REC PIC S9(9) COMP-5 VALUE 0. 01 LDNAME-REC PIC X(8). 01 BUFFER-REC PIC X(n). 01 RECEIVETYPE-REC.  05 BUFFERLEN PIC S9(9) COMP-5.  05 MSGLEN PIC S9(9) COMP-5.  05 MSGTYPE PIC S9(9) COMP-5.  05 WAITTIME PIC S9(9) COMP-5.

  05 UNUSED PIC X(16) VALUE LOW-VALUE. 01 SENDTYPE-REC.  05 MSGLEN PIC S9(9) COMP-5.  05 PRIORITY PIC S9(9) COMP-5.  05 MSGTYPE PIC S9(9) COMP-5.  05 WAITTIME PIC S9(9) COMP-5.  05 UNUSED PIC S9(9) COMP-5.PROCEDURE DIVISION.  :[Connect with server] CALL "COBCI_OPEN" USING BY REFERENCE STATUS-REC

  BY REFERENCE SERVERNAME-REC  BY REFERENCE SERERHD-REC  BY VALUE UNUSED-REC.  :[Read message] CALL "COBCI_READ" USING BY REFERENCE STATUS-REC  BY VALUE SERVERHD-REC  BY REFERENCE LDNAME^REC  BY REFERENCE RECEIVETYPE-REC  BY REFERENCE BUFFER-REC  BY VALUE UNUSED-REC.

  :[Write message] CALL "COBCI_WRITE" USING BY REFERENCE STATUS-REC  BY VALUE SERVERHD-REC  BY REFERENCE LDNAME-REC  BY REFERENCE SENDTYPE-REC  BY REFERENCE BUFFER-REC  BY VALUE UNUSED-REC.  :[Disconnect from server]

482 Chapter 14. Communication Functions

 CALL "COBCI_CLOSE" USING BY REFERENCE STATUS-REC  BY VALUE SERVERHD-REC  BY VALUE UNUSED-REC.  :END PROGRAM Program-name.

Figure 124. An example of simplified inter-application communication functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 505/783

g p p pp

COBCI_OPEN

Establishes a connection between a client and server. The serveris identified by the specified server name.

The server identifier is returned when the client and server areconnected normally.

Chapter 14. Communication Functions 483

Calling Format

  : DATA DIVISION. 01 STATUS-REC.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 506/783

  05 ERRORCD PIC S9(9) COMP-5.  05 DETAIL PIC S9(9) COMP-5. 01 SERVERNAME-REC PIC X(15). 01 SERVERHD-REC PIC S9(9) COMP-5. 01 UNUSED-REC PIC S9(9) COMP-5 VALUE 0. PROCEDURE DIVISION.  CALL "COBCI_OPEN" WITH C LINKAGE  USING BY REFERENCE STATUS-REC  BY REFERENCE SERVERNAME-REC  BY REFERENCE SERVERHD-REC  BY VALUE UNUSED-REC.

Parameters

STATUS-REC

An error code is returned to ERRORCD; a detail code is returnedto DETAIL.

SERVERNAME-REC

The client specifies the name of the server to be connected. Theserver name must be defined in the logical destination definitionfile. If the server name is shorter than 15 bytes, the remainingbytes must be padded with spaces.

SERVERHD-REC

The server identifier is returned.

484 Chapter 14. Communication Functions

UNUSED-RECZero must be set for this area, which is reserved for futureexpansion.

Return Value

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 507/783

Return Value

If the client is connected with the server normally, the systemreturns 0 to special register PROGRAM-STATUS. Otherwise, thesystem returns -1 to special register PROGRAM-STATUS.

COBCI_CLOSE

Disconnects a client from a server. The server is identified by the

server identifier returned at calling of the COBCI_OPENfunction.

Calling Format

  : DATA DIVISION.

 01 STATUS-REC.  05 ERRORCD PIC S9(9) COMP-5.  05 DETAIL PIC S9(9) COMP-5. 01 SERVERHD-REC PIC S9(9) COMP-5. 01 UNUSED-REC PIC S9(9) COMP-5 VALUE 0. PROCEDURE DIVISION.  CALL "COBCI_CLOSE" WITH C LINKAGE  USING BY REFERENCE STATUS-REC  BY VALUE SERVERHD-REC  BY VALUE UNUSED-REC.  :

Parameters

STATUS-REC

An error code is returned to ERRORCD; a detail code is returnedto DETAIL.

Chapter 14. Communication Functions 485

SERVERHD-RECSpecify the server identifier returned at calling of theCOBCI_OPEN function.

UNUSED-REC

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 508/783

Zero must be set for this area, which is reserved for futureexpansion.

Return Value

If the client is disconnected from the server normally, the systemreturns 0 to special register PROGRAM-STATUS. Otherwise, thesystem returns -1 to special register PROGRAM-STATUS.

COBCI_READ

Reads messages from the server logical destination. The messagein the highest-priority level is first read. Messages in the samepriority level are read in the order they were written.

If there is no message at the logical destination, a method ofqueuing processing can be specified depending on theprocessing type specification.

486 Chapter 14. Communication Functions

Calling Format

  : DATA DIVISION. 01 STATUS-REC.

05 ERRORCD PIC S9(9) COMP-5

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 509/783

  05 ERRORCD PIC S9(9) COMP-5.  05 DETAIL PIC S9(9) COMP-5. 01 SERVERHD-REC PIC S9(9) COMP-5. 01 LDNAME-REC PIC X(8).

 01 RECEIVETYPE-REC.  05 BUFFERLEN PIC S9(9) COMP-5.  05 MSGLEN PIC S9(9) COMP-5.  05 MSGTYPE PIC S9(9) COMP-5.  05 WAITTIME PIC S9(9) COMP-5.  05 UNUSED PIC X(16) VALUE LOW-VALUE. 01 BUFFER-REC PIC X(n). 01 UNUSED-REC PIC S9(9) COMP-5 VALUE 0. PROCEDURE DIVISION.  CALL "COBCI_READ" WITH C LINKAGE  USING BY REFERENCE STATUS-REC

  BY VALUE SERVERHD-REC  BY REFERENCE LDNAME-REC  BY REFERENCE RECEIVETYPE-REC  BY REFERENCE BUFFER-REC  BY VALUE UNUSED-REC.  :

Parameters

STATUS-REC

An error code is returned to ERRORCD; a detail code is returnedto DETAIL.

SERVERHD-REC

Specify the server identifier returned at calling of the

COBCI_OPEN function.

Chapter 14. Communication Functions 487

LDNAME-RECSpecify the name of the client logical destination from wheremessages are to be read. If the logical destination name is shorterthan eight bytes, the remaining bytes must be padded withspaces. The logical destination name is specified in the Client

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 510/783

Definition dialog box.

RECEIVETYPE-RECFor BUFFERLEN, specify the length of the record area forreceiving messages.

Up to 32,000 bytes can be specified for BUFFERLEN.

The length of a message read from the logical destination isreturned as MSGLEN.

Specify a processing type for MSGTYPE. The following textexplains processing types:

• Queuing not specified

Specify 0 for MSGTYPE. Consequently, if the system cannotread a message because no message was found at the logicaldestination, the system returns control immediately. Thesystem returns an error code indicating that there is nomessage to read.

• Queuing specified

Specify 1 for MSGTYPE. Consequently, the system waits untilmessages (up to the maximum number of instructions specifiedin the system) have been written to the logical destination.

Monitoring time can specified for WAITTIME at the same time.The specified monitoring time must be in the range from 0 to999999999 (seconds). If 0 is specified, infinite wait time isassumed. Note: Again, this depends on the maximum number ofinstructions specified in the system.

488 Chapter 14. Communication Functions

If messages are not written to the logical destination within thespecified time, the system returns the error code.

UNUSED is an area reserved for future expansion. Zero must beset for the area.

BUFFER-REC

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 511/783

Specify the record area for receiving messages from the logical

destination. Messages are returned here. Data exceeding thelength returned as MSGLEN are not guaranteed.

If a read message exceeds the length specified for BUFFERLEN,the excess data is truncated.

UNUSED-REC

Zero must be set for this area, which is reserved for future

expansion.

Return Value

If a message is read normally, the system returns 0 to specialregister PROGRAM-STATUS. Otherwise, the system returns -1to special register PROGRAM-STATUS.

The WM_TIMER message is used for checking time-out ofmonitoring time. There may be a difference between the elapsedtime and the specified monitoring time.

COBCI_WRITE

Writes messages to the server logical destination. Priority levelscan be specified for the messages to be written. If the logicaldestination has no free space, a method of queuing processingcan be specified depending on the processing-type specification.

Chapter 14. Communication Functions 489

Calling Format

  : DATA DIVISION. 01 STATUS-REC.  05 ERRORCD PIC S9(9) COMP-5.  05 DETAIL PIC S9(9) COMP-5.01 SERVERHD-REC PIC S9(9) COMP-5

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 512/783

 01 SERVERHD-REC PIC S9(9) COMP-5. 01 LDNAME-REC PIC X(8). 01 SENDTYPE-REC.

  05 MSGLEN PIC S9(9) COMP-5.  05 PRIORITY PIC S9(9) COMP-5.  05 MSGTYPE PIC S9(9) COMP-5.  05 WAITTIME PIC S9(9) COMP-5.  05 UNUSED PIC X(16) VALUE LOW-VALUE. 01 BUFFER-REC PIC X(n). 01 UNUSED-REC PIC S9(9) COMP-5 VALUE 0. PROCEDURE DIVISION.  CALL "COBCI_WRITE" WITH C LINKAGE  USING BY REFERENCE STATUS-REC  BY VALUE SERVERHD-REC

  BY REFERENCE LDNAME-REC  BY REFERENCE SENDTYPE-REC  BY REFERENCE BUFFER-REC  BY VALUE UNUSED-REC.  :

490 Chapter 14. Communication Functions

Parameters

STATUS-REC

An error code is returned to ERRORCD; a detail code is returnedto DETAIL

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 513/783

to DETAIL.

SERVERHD-REC

Specify the server identifier returned at calling of theCOBCI_OPEN function.

LDNAME-REC

Specify the name of the client logical destination where messagesare to be written. If the logical destination name is shorter than

eight bytes, the remaining bytes must be padded with spaces.SENDTYPE-REC

For MSGLEN, specify the length of the messages to be written tothe logical destination. Up to 32,000 bytes can be specified forMSGLEN.

For PRIORITY, specify the priority levels of the messages to be

written to the server logical destination. The message in thehighest-priority level is first read. Messages in the same prioritylevel are read in the order they were written.

A priority level can be specified in the range from 1 (highest) to9. If the specified priority level does not exist at the server logicaldestination, the message is stored in the priority level nearest tothe one specified. A negative value cannot be specified.

Chapter 14. Communication Functions 491

Specify a processing type for MSGTYPE. The following textexplains processing types:

• Queuing not specified

Specify 0 for MSGTYPE. Consequently, if a message cannotbe written because the logical destination has no free space,

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 514/783

the system immediately returns control. The system returns

an error code indicating no free space.• Queuing specified

Specify 1 for MSGTYPE. Consequently, the system waitsuntil messages (up to the maximum number of instructionsspecified in the system) have been written to the logicaldestination. Monitoring time can be specified for WAITTIMEat the same time. The specified monitoring time must be inthe range from 0 to 999999999 (seconds). If 0 is specified,infinite wait time is assumed. Note: Again, this depends onthe maximum number of instructions specified in the system.

If the logical destination fails to make free space within thespecified time, the system returns the error code.

• Forced execution specified

Specify 2 for MSGTYPE. Consequently, more messages thanthe maximum number of messages specified for the logicaldestination can be written.

In this case, the system returns an error code indicating thatmore messages than the maximum number have beenwritten. However, messages exceeding the maximumnumber of messages specified in the system (System maxmessages) cannot be written.

UNUSED is an area reserved for future expansion. Zero must beset for the area.

492 Chapter 14. Communication Functions

BUFFER-RECSpecify the record area containing the messages to be written tothe logical destination.

UNUSED-REC

Zero must be set for this area, which is reserved for future

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 515/783

Zero must be set for this area, which is reserved for futureexpansion.

Return Value

If a message is written normally, the system returns 0 to specialregister PROGRAM-STATUS. Otherwise, the system returns -1to special register PROGRAM-STATUS.

The WM_TIMER message is used for checking time-out ofmonitoring time. There may be a difference between the elapsedtime and the specified monitoring time.

Chapter 14. Communication Functions 493

Error Codes

This section explains the error codes of functions used withsimplified inter-application communication.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 516/783

p pp

If a function quits normally, the system returns 0 to the specialregister PROGRAM-STATUS. The system also returns 0 as theerror code (STATUS-REC ERROR value) and detail code(STATUS-REC DETAIL value).

If a function quits with an error, the system returns -1 to specialregister PROGRAM-STATUS. In this case, the system returnsnon-zero values as the error code and detail code. For error codes

and detail codes, see Table 55.Abbreviations of the functions in Table 55:

O: COBCI_OPEN function

C: COBCI_CLOSE function

R: COBCI_READ function

W: COBCI_WRITE function

o: Related

494 Chapter 14. Communication Functions

Table 55. Error codes of simplified inter-application communication functionsErrorCode

DetailCode

Explanation Response O C R W  

0 0 Normal termination ---- o o o o1 257 The message was read

normally, but the messagewas longer than the buffer.

---- o

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 517/783

gThe excess data was

truncated.2 513 No message was found toread. (Queuing notspecified)

---- o

3 769 Messages exceeding themaximum number ofmessages specified for thelogical destination werestored. (Forced execution

specified)

---- o

4 1025 A message could not beread because no messagewas found at the logicaldestination when thespecified monitoring timeelapsed (Queuing specified)

---- o

1026 A message could not bewritten because themaximum number ofmessages specified for thelogical destination or thesystem was reached whenmonitoring time elapsed(Queuing specified)

Delete unprocessedmessages, then re-execute.

o

Chapter 14. Communication Functions 495

Table 55. Error codes of simplified inter-application communication functions (cont.)ErrorCode

DetailCode

Explanation Response O C R W  

6 1537 A message could not beread because the logicaldestination was not in theread-enabled state.

Specify Active for the readattribute of the server ofthe logical destination.

o

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 518/783

1538 A message could not be

written because the logicaldestination was not in thewrite-enabled state.

Specify Active for the write

attribute of the server ofthe logical destination.

o

1539 An attempt was made toread a message or write amessage to a logicaldestination that had notbeen generated.

Generate a logicaldestination in the server.

o o

7 1793 A message could not be

written because themaximum number ofmessages specified in thelogical destination wasreached. (Queuingspecified)

Delete unprocessed

messages, then re-execute.

o

8 2049 Either a message could notbe written because themaximum number ofmessages specified in thesystem was reached, or amessage could not be reador written because themaximum number ofinstructions specified in thesystem was reached.

Delete unprocessedmessages, then re-execute.

o o

10 2561 A connection request was

issued for an alreadyconnected server.

Check whether a

connection request wasissued repeatedly for thesame server.

o

496 Chapter 14. Communication Functions

Table 55. Error codes of simplified inter-application communication functions (cont.)ErrorCode

DetailCode

Explanation Response O C R W  

11 2833 Logical destination nameerror.

Check whether thespecified logicaldestination name iscorrect.

o o

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 519/783

2834 Processing type error. Check whether the

specified processing type iscorrect.

o o

2835 Message or buffer lengtherror.

Check whether thespecified message andbuffer lengths are correct.

o o

2836 Priority level error. Check whether thespecified priority level iscorrect.

o

2837 Monitoring time error. Check whether the

specified monitoring timeis correct.

o o

2838 Server name error. Check whether thespecified server name iscorrect.

o

2839 Server identifier error. Check whether the serveris connected and if thespecified server identifieris correct.

o o o

12 3105 The logical destinationdefinition file is notspecified correctly.

Check whether the logicaldefinition file is correctlyspecified in @CBR_CIINF.

o

3016 The logical destinationdefinition file containsincorrect specification.

Check whether the data inthe logical destinationdefinition file is correctand whether the servermachine name (host name

specified in @HOSTNM) isdefined in the hosts filecorrectly.

o o o

Chapter 14. Communication Functions 497

Table 55. Error codes of simplified inter-application communication functions (cont.)ErrorCode

DetailCode

Explanation Response O C R W  

13 XXXX An error occurred duringcommunication betweensystems (Detail code XXXX:Windows Sockets function

d S T bl 56)

If this error occurs, theclient is disconnected fromthe server. To resumecommunication, restart

ti f ti

o o o o

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 520/783

error code. See Table 56). operation from connection

(COBCI_OPEN) with theserver.14 3633 Memory became

insufficient.Review the operatingenvironment.

o o o o

15 3841 The COBOL environment isnot established (16).

Check whether simplifiedinter-applicationcommunication is used viaa COBOL program.

o

3842 The client was disconnected

from the server.

To resume

communication, restartoperation from connection(COBCI_OPEN) with theserver.

o o o o

3843 The socket in use is notsupported in WindowsSockets V1.1.

Use a socket supported inWindows Socket V1.1.

o

3844 The client was forciblyended.

---- o o o o

4080 orhigher

An internal conflict wasdetected.

Contact a FUJITSUsystems engineer (SE).

o o o o

498 Chapter 14. Communication Functions

Table 56. Windows Sockets function error codesDescription in WINSOCK.H Error

CodeExplanation

WSAEMFILE 10024 A new socket identifier cannot be generatedbecause all permitted socket identifiers are inuse. Quit unnecessary communicationconnections, then re-execute processing.

WSAENOTSOCK 10038 Data other than socket identifiers is specified in

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 521/783

WSAENOTSOCK 10038 Data other than socket identifiers is specified in

the socket function.WSAEPROTONOSUPPORT 10043 The specified protocol is not supported. Checkwhether the TCP/IP operating environment isset up correctly.

WSAESOCKTNOSUPPORT 10044 The specified socket type is not supported bythis address family. Check whether the TCP/IPoperating environment is set up correctly.

WSAEAFNOSUPPORT 10047 The specified address family is not supported.Check whether the TCP/IP operating

environment is set up correctly.WSAEADDRINUSE 10048 The address for connecting the server is in use.WASEADDRNOTAVAIL 10049 The client could not be connected with the

server. Check whether the remote machinename specified in the client definition file isdefined in the hosts file correctly.

WSAENETDOWN 10050 The network subsystem failed. Activate thenetwork.

WSAENETUNREACH 10051 The host where the client was operating couldnot be connected with the host where theserver was operating. Check whether thenetwork is defined correctly.

WSAENETRESET 10052 The network failed. Reactivate the network.WSAECONNABORTED 10053 Connection was rejected because of a time-out

or other error, or processing ended abnormally.Check whether the client and server areoperating normally. This error may be caused

by interference during communication or by aLAN card error.

Chapter 14. Communication Functions 499

Table 56. Windows Sockets function error codes (cont.)

Description in WINSOCK.H ErrorCode

Explanation

WSAECONNRESET 10054 The client or server was reset.WSAENOBUFS 10055 The communication buffer space is insufficient.

Increase the communication buffer space orreduce communication traffic.

WSAEISCONN 1056 The client is already connected with the server

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 522/783

WSAEISCONN 1056 The client is already connected with the server.

WSAENOTCONN 10057 The client it not connected with the server.WSAESHUTDOWN 10058 The client was disconnected from the server.WSAETIMEDOUT 10060 A time-out was detected because the client was

not connected with the server within thespecified time. Check whether the server isactive and whether the machine where theserver is operating is connected to the LAN.

WSAECONNREFUSED 10061 Connection with the server was rejected. Checkwhether the server is active.

WSAEDISCON 10101 The client or server was disconnected.WSANO_DATA 11004 Service name ‘cobci’ is not defined in the

services file. Define the service name ‘cobci’ inthe services file.

500 Chapter 14. Communication Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 523/783

Chapter 15. Database (SQL)This chapter covers remote database access (ODBC) and explainshow to write embedded SQL in a COBOL program and access adatabase with the ODBC driver.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 524/783

The database (SQL) function accesses a database in a server froma PC client using embedded SQL. Embedded SQL is a databasemanipulation language written in a COBOL source program. Thedatabase function enables distributed development anddevelopment of a variety of application types.

ODBC (Open DataBase Connectivity), proposed by MicrosoftCorp., is an application program interface for database access.

502 Chapter 15. Database (SQL)

ODBC Outline

This section outlines database access with an ODBC driver froma COBOL application. For an example about using the ODBCdriver, refer to sample program SAMPLE11, supplied with the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 525/783

p p g pp

database (SQL) function.The ODBC driver enables access to one or more databases.

The following figure outlines database access using the ODBCdriver.

  Figure 125. Outline of database access using the ODBC driver 

Chapter 15. Database (SQL) 503

Configuration of a COBOL Program with SQL

The following shows the configuration of a COBOL programwith SQL:

IDENTIFICATION DIVISION.  :

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 526/783

ENVIRONMENT DIVISION. (1)  :DATA DIVISION.  :WORKING-STORAGE SECTION.  :  EXEC SQL BEGIN DECLARE SECTION END-EXEC. (2)01 SQLSTATE PIC X(5).  :  EXEC SQL END DECLARE SECTION END-EXEC.  :PROCEDURE DIVISION.  :  EXEC SQL CONNECT ... END-EXEC. (3)  :  EXEC SQL DECLARE CUR1 ... END-EXEC. (4)  :  EXEC SQL OPEN CUR1 END-EXEC. (5)  :  EXEC SQL FETCH CUR1 ... END-EXEC.  :  EXEC SQL CLOSE CUR1 END-EXEC. (6)  :  EXEC SQL ROLLBACK WORK END-EXEC.  :  EXEC SQL DISCONNECT ... END-EXEC. (7)  :  STOP RUN.

Figure 126. Configuration of a COBOL program

(1) No SQL-specific description.

(2) Declare SQLSTATE in the DECLARE section. Define a hostvariable if necessary.

(3) Connect to the server.

(4) Declare the cursor, if using one.

(5) Open the cursor.

504 Chapter 15. Database (SQL)

(6) Close the cursor.

(7) Disconnect from the server.

Write SQL in a COBOL program as shown in the previous figure.Each SQL statement must begin with EXEC SQL (SQL prefix)and end with END-EXEC (SQL terminator). The database isprocessed using the SQL statements written in the PROCEDUREDIVISION.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 527/783

Operations Using Embedded SQL

The following operations can be executed with embedded SQLstatements:

• Connection

A client connects to a server to access a database. Theconnection enables execution of SQL statements for accessinga server database from the client. To connect a client andserver, use the CONNECT statement. See “Connecting to aServer.”

• Selecting a connection

To select connections, use the SET CONNECTION statement.See “Selecting a Connection.”

• Manipulating data

To manipulate data, use the SELECT, INSERT, UPDATE, andDELETE statements. If the cursor is defined, the FETCH

statement can be used to fetch data. These statements can beexecuted dynamically. See “Manipulating Data.”

• For the correspondence between data handled in COBOL85and ODBC, see “Correspondence Between ODBC-HandledData and COBOL85-Handled Data.”

Chapter 15. Database (SQL) 505

• Transaction processing

Consistency of database data manipulation is ensured withintransaction units. A transaction starts when the first SQLstatement is executed, and terminates when the COMMIT orROLLBACK statement is executed.

• Disconnection

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 528/783

To disconnect a program from the server, use theDISCONNECT statement.

Before executing the DISCONNECT statement, terminate thetransaction. See “Disconnecting from a Server.”

The following sections provide examples of the above operations:

Connection

This section explains methods for connecting, disconnecting, andselecting a server (connection).

Connecting to a Server 

To connect a client to a server, use the CONNECT statement. Thefollowing steps should be used for Client/Server connection:

1. Define server information.

2. Connect to the server by either of the following methods:

• Specify the server name

• Specify DEFAULT

506 Chapter 15. Database (SQL)

Connecting by Specifying the Server Name

Before executing the program, define the server information inthe ODBC information file. For details on the information to bedefined and how to define the information, see “Executing theProgram.”

Specify the server name in the CONNECT statement, and

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 529/783

execute the statement. This will result in the ODBC informationfile being searched for the specified server information. If asection is found having the same name, the server information isreferenced in definition order to establish a connection to theserver.

The server information in the ODBC information file isreferenced at execution of the CONNECT statement whenconnecting to the server.

Connecting by Specifying DEFAULT

Before executing the program, define the default connectioninformation in the ODBC information file. For details definition

information and how to define the information, see “Executingthe Program.”

Specify DEFAULT in the CONNECT statement and execute thestatement. This will result in the default connection informationfile for ODBC to be referenced. The server information is definedin the default connection information. The ODBC information file

Chapter 15. Database (SQL) 507

is searched for the server information. If the server information is

found, it is referenced when connecting to the server.

The default connection information is referenced at execution ofthe CONNECT statement.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 530/783

The SV1 information defined in the default connectioninformation is referenced to connect the server.

Disconnecting from a Server 

To disconnect a client from a server, use the DISCONNECTstatement.

Specify the connection to be terminated in the DISCONNECTstatement. The connection name, DEFAULT, CURRENT, or ALLcan be specified in the DISCONNECT statement. For theDISCONNECT statement specification, see Figure 127.

Selecting a Connection

To select the available connections, use the SET CONNECTION

statement.

More than one server can be connected by executing theCONNECT statement for each database to be connected. If anapplication connects more than one server, a server for whichSQL statements are to be executed must be defined.

508 Chapter 15. Database (SQL)

If more than one CONNECT statement is executed, the server

connected with the last CONNECT statement will be used as thecurrent server (current connection).

SQL statements are executed for the current connection. Toexecute SQL statements for another connection, use the SETCONNECTION statement to select the appropriate connection.

The following figure is a COBOL program that illustrates the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 531/783

connection to multiple servers. The following example shows theselection of a connection, connecting and disconnecting of thesemultiple servers. The example has a default connection, andconnection to servers SV1, SV2, SV3, and SV4 as defined in theODBC information file.

Chapter 15. Database (SQL) 509

  :  EXEC SQL CONNECT TO DEFAULT END-EXEC. (1)  EXEC SQL  CONNECT TO 'SV1' AS 'CNN1' USER 'tanaka/sky' (2)  END-EXEC.  EXEC SQL  CONNECT TO 'SV2' AS 'CNN2 USER 'tanaka/sky' (3)  END-EXEC.  EXEC SQL  CONNECT TO 'SV3' AS 'CNN3' USER 'tanaka/sky' (4)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 532/783

  END-EXEC.  EXEC SQL  CONNECT TO 'SV4' AS 'CNN4' USER 'tanaka/sky' (5)  END-EXEC.  EXEC SQL DISCONNECT 'CNN4' END-EXEC. (6)  EXEC SQL SET CONNECTION 'CNN1' END-EXEC. (7)  :  EXEC SQL ROLLBACK WORK END-EXEC. (8)  EXEC SQL DISCONNECT CURRENT END-EXEC. (9)  EXEC SQL SET CONNECTION DEFAULT END-EXEC. (10)  :

  EXEC SQL COMMIT WORK END-EXEC. (11)  EXEC SQL DISCONNECT DEFAULT END-EXEC. (12)  EXEC SQL SET CONNECTION 'CNN2' END-EXEC.  :  EXEC SQL ROLLBACK WORK END-EXEC.  EXEC SQL DISCONNECT ALL END-EXEC. (13)

Figure 127. Example showing the connection of multiple servers,selecting from them, and disconnecting them

(1) The default connection is enabled.

(2) The server SV1 is connected. This connection name is CNN1.

(3) The server SV2 is connected. This connection name is CNN2.

(4) The server SV3 is connected. This connection name is CNN3.

(5) The server SV4 is connected. This connection name is CNN4.

The last-connected CNN4 is the current connection.

(6) The connection name CNN4 is disconnected.

(7) The connection name CNN1 is selected. CNN1 becomes thecurrent connection.

(8) Any changes made in the CNN1 are canceled.

510 Chapter 15. Database (SQL)

(9) The current connection is disconnected. CNN1 is now the

current connection in the example, so CNN1 is disconnected.

(10) Default connection is selected. The default connectionbecomes the current connection.

(11) Any changes made in the default connection are saved.

(12) The default connection is disconnected.

(13) All il bl i di d

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 533/783

(13) All available connections are disconnected.Up to 16 servers can be connected using the CONNECTstatement at the same time. The number can vary depending onthe ODBC driver and the related environments.

Chapter 15. Database (SQL) 511

Manipulating Data

This section explains the following data manipulations:

• Retrieving data

•U d ti d t

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 534/783

Updating data• Deleting data

• Inserting data

• Using dynamic SQL

• Using variable length character strings

• Operating the cursor with more than one connection

Also see “Correspondence Between ODBC-Handled Data andCOBOL85-Handled Data.”

512 Chapter 15. Database (SQL)

Sample Database

The following three sample database tables are used in theprogram examples which follow:

STOCK table: Shows product numbers (GNO), product names(GOODS), quantity in stock (QOH), and warehouse numbers

(WHNO)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 535/783

(WHNO).

ORDERS table: Shows company numbers (COMPANYNO),product trade numbers (GOODSNO), purchase prices (PRICE),and order quantities (OOH).

COMPANY table: Shows company numbers (CNO), companynames (NAME), telephone numbers (PHONE), and address

(ADDRESS).STOCK table

GNO GOODS QOH WHNO110111123124137

138140141200201212215226227

240243351380390

TELEVISIONTELEVISIONREFRIGERATORREFRIGERATORRADIO

RADIOCASSETTE DECKCASSETTE DECKAIR CONDITIONERAIR CONDITIONERTELEVISIONVIDEOREFRIGERATORREFRIGERATOR

CASSETTE DECKCASSETTE DECKCASSER TAPESHAVERDRYER

85906075150

2001208041505815

25142500870540

22112

222112211

22233

Chapter 15. Database (SQL) 513

ORDERS table

COMPANY NO. GOODSNO PRICE OOH6161616161616262

62

123124138140215240110226

351

4800064000640090002400008000037500112500

375

604018080102012020

800

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 536/783

626363636363717172

72727272727373737474747474

351111200201212215140351137

140215226243351141380390110111226227351

3755740012300016400020500024600078003903500

70002100001050008400035016000240024003900054000117000140400390

800806050301050600120

701020101000602501501201202010700

COMPANY tableCNO NAME PHONE ADDRESS61

626371727374

ADAM LTD.

IDEA INC.MOON CO.RIVER CO.DRAGON CO.BIG INC.FIRST CO.

731-1111

423-222143-3333344-1212373-7777391-0808255-9944

SANTA CLARA CA USA

LONDON W.C.2 ENGLANDNEW YORK NY USAPARIS FRANCESAN FRANCISCO CA USADALLAS TX USASYDNEY AUSTRALIA

514 Chapter 15. Database (SQL)

Retrieving Data

This section explains methods for retrieving data from adatabase.

Retrieving Data from All Table Rows

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 537/783

The following figure shows a COBOL program used to retrievedata from all rows of a database table.

  :  EXEC SQL BEGIN DECLARE SECTION END-EXEC.01 PRODUCT-NUMBER PIC S9(4) COMP-5. }01 PRODUCT-NAME PIC X(20). }01 QUANTITY-IN-STOCK PIC S9(9) COMP-5. } (1)01 WAREHOUSE-NUMBER PIC S9(4) COMP-5. }

01 SQLSTATE PIC X(5). }  EXEC SQL END DECLARE SECTION END-EXEC.PROCEDURE DIVISION.  EXEC SQL WHENEVER NOT FOUND GO TO:P-END END-EXEC. (2)  EXEC SQL  DECLARE CUR1 CURSOR FOR SELECT * FROM STOCK (3)  END-EXEC.P-START.  EXEC SQL CONNECT TO DEFAULT END-EXEC. (4)  EXEC SQL OPEN CUR1 END-EXEC. (5)P-LOOP.

  EXEC SQL  FETCH CUR1 INTO :PRODUCT-NUMBER, (6)  :PRODUCT-NAME,  :QUANTITY-IN-STOCK,  :WAREHOUSE-NUMBER  END-EXEC.  :  GO TO P-LOOP.P-END.  EXEC SQL CLOSE CUR1 END-EXEC. (7)  EXEC SQL ROLLBACK WORK END-EXEC. (8)  EXEC SQL DISCONNECT DEFAULT END-EXEC. (9)  STOP RUN.

Figure 128. Retrieving data from all rows

Chapter 15. Database (SQL) 515

(1) Specifies an embedded SQL DECLARE section in the

WORKING-STORAGE section, and defines the data inputareas (all columns of the STOCK table) as host variables.Refer to the “COBOL85 Reference Manual” for the hostvariable declaration rules.

(2) Operation for an exception event can be specified byspecifying the embedded SQL exception declaration. The

example specifies NOT FOUND as a condition. Therefore, theexception declaration is effective if "no data" is shown as the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 538/783

example specifies NOT FOUND as a condition. Therefore, theexception declaration is effective if "no data" is shown as theSQLSTATE value. The example specifies executing P-ENDprocedure when there is no row fetched by the FETCHstatement in (6). Operation for an exception event can also bespecified by checking SQLSTATE with a COBOL IFstatement.

(3) Declares a cursor to define the cursor name for referring tothe STOCK table. The example neither selects any specificcolumns from the STOCK table nor specifies any searchconditions. Thus, a table derived from the query expression isidentical to the original STOCK table.

(4) Executes the CONNECT statement to connect the server.

(5) Executes the OPEN statement to enable the specified cursor.(6) Executes the FETCH statement to fetch data row by row from

the table, and sets the values of each column into thecorresponding host variable area.

(7) Executes the CLOSE statement to disable the specified cursor.

(8) Executes the ROLLBACK statement to terminate the

transaction.

(9) Executes the DISCONNECT statement to disconnect theserver.

516 Chapter 15. Database (SQL)

If an asterisk (*) is specified in the select list of the query

expression, the columns are selected in the order specified whenthe table was defined.

Retrieving Data with Conditions Specified

The following illustrates retrieving data for only rows that meetspecified conditions. In the example, the condition of the

quantity in stock (QOH) is tested to be less than 51. It retrieves

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 539/783

q y (Q )the data (product number, product name, and quantity in stock)of products that meet the condition.

  :  EXEC SQL BEGIN DECLARE SECTION END-EXEC.01 PRODUCT-NUMBER PIC S9(4) COMP-5. }01 PRODUCT-NAME PIC X(20). } (1)01 QUANTITY-IN-STOCK PIC S9(9) COMP-5. }

01 SQLSTATE PIC X(5). }  EXEC SQL END DECLARE SECTION END-EXEC.PROCEDURE DIVISION.  EXEC SQL WHENEVER NOT FOUND GO TO :P-END END-  EXEC.  EXEC SQL  DECLARE CUR2 CURSOR FOR (2)  SELECT GNO, GOODS, QOH FROM STOCK  WHERE QOH < 51  END-EXEC.P-START.

  EXEC SQL CONNECT TO DEFAULT END-EXEC. (3)  EXEC SQL OPEN CUR2 END-EXEC. (4)P-LOOP.  EXEC SQL  FETCH CUR2 INTO :PRODUCT-NUMBER, (5)  :PRODUCT-NAME,  :QUANTITY-IN-STOCK  END-EXEC.  :  GO TO P-LOOP.P-END.

  EXEC SQL CLOSE CUR2 END-EXEC. (6)  EXEC SQL ROLLBACK WORK END-EXEC. (7)  EXEC SQL DISCONNECT DEFAULT END-EXEC. (8)  STOP RUN.

Figure 129. Retrieving data with conditions specified

Chapter 15. Database (SQL) 517

(1) The embedded SQL DECLARE section defines all host

variables to be specified in embedded SQL statements.(2) The table is never referred to by declaring a cursor. The table

is referred to when the OPEN statement in (4) is executed.

(3) Executes the CONNECT statement to connect the server.

(4) Executes the OPEN statement to create a virtual tableincluding rows that meet the condition specified during

cursor declaration in (2). The virtual table is created and rows

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 540/783

( )showing 50 or less in column QOH are extracted from theSTOCK table, then the data of columns GNO, GOODS, andQOH are retrieved from the extracted rows. Generally, therow order of a virtual table is undefined.

(5) Executes the FETCH statement to fetch data row by row from

the beginning of the virtual table created in (4), then writesthe values of each column to the corresponding host variablearea. To retrieve the values of a column in ascending ordescending order, specify the ORDER BY clause at the end ofthe query expression in (2).

(6) Executes the CLOSE statement to disable the virtual tablecreated in (4). The virtual table can no longer be referenced by

executing SQL statements unless the OPEN statement isexecuted again.

(7) Executes the ROLLBACK statement to terminate thetransaction.

(8) Executes the DISCONNECT statement to disconnect theserver.

518 Chapter 15. Database (SQL)

Retrieving Data from a Single Row

The following are program examples for retrieving the data ofindividual or multiple rows.

Use the SELECT statement if retrieving the data for only onerow. No cursor is used in this case, and cursor declaration andprocessing using the OPEN, FETCH, and CLOSE statements isunnecessary.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 541/783

y

The following is the SELECT statement used to retrieve theproduct name where the quantity in stock for the product is 200as noted in the STOCK table:

EXEC SQL  SELECT GOODS, QOH INTO :PRODUCT-NAME,:QUANTITY-IN-STOCK  FROM STOCK  WHERE GNO = 200END-EXEC.

If a set function is specified as the select list value expression, theSELECT statement obtains the radix of the table (the number ofrows) and the maximum, minimum, average, and summation(total) of the specified value expression.

The following is the SELECT statement used to retrieve themaximum, minimum, and average of the purchase prices in theORDERS table:

EXEC SQL SELECT MAX(PRICE), MIN(PRICE), AVG(PRICE) INTO :MAX-VALUE, :MIN-VALUE, :AVG-VALUE FROM ORDERSEND-EXEC.

The results are set in the host variables MAX-VALUE, MIN-VALUE, and AVG-VALUE.

Chapter 15. Database (SQL) 519

Retrieving Data from Related Tables

Retrieving Data from a Table Created by Relating Different Tables

Data can be retrieved from a table created by relating differenttables. The tables are related according to their column values.

The following example relates three tables of the sample database

in order to retrieve data. The example specifies TELEVISION as ad d i h f i

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 542/783

target product name, and retrieves the names of companieswhich deal with the specified product and the order quantity ofeach company.

The STOCK and ORDERS tables are related according to theproduct numbers (column GNO) and product trade numbers

(column GOODSNO).The ORDERS and COMPANY tables are related according to thecompany numbers (column COMPANYNO) and companynumbers (column CNO).

The following shows the query expression:

SELECT NAME, OOH

  FROM STOCK, ORDERS, COMPANY  WHERE GOODS = 'TELEVISION' AND  GNO = GOODSNO AND  COMPANYNO = CNO

520 Chapter 15. Database (SQL)

Rows that meet the search conditions are derived from the table

created by relating three tables:GNO ... WHNO COMPANYNO ..

.OOH CNO ..

.ADDRESS

110110110

...

...

...

222

616161

..

.

..

.

..

.

606060

616263

..

.

..

.

..

.

SANTA CLARA CA USALONDON W.C.2ENGLANDFIFTH AVENUE NY USA

  ~ ~ ~ ~ ~ ~ ~ ~

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 543/783

110110110

...

...

...

222

616161

..

.

..

.

..

.

404040

616263

..

.

..

.

..

.

SANTA CLARA CA USALONDON W.C.2ENGLANDFIFTH AVENUE NY USA

  ~ ~ ~ ~ ~ ~ ~ ~

111111111

...

...

...

222

616161

..

.

..

.

..

.

606060

616263

..

.

..

.

..

.

SANTA CLARA CA USALONDON W.C.2ENGLANDFIFTH AVENUE NY USA

  ~ ~ ~ ~ ~ ~ ~ ~390390390

...

...

...

333

747474

..

.

..

.

700700700

727374

..

.

..

.

..

.

SAN FRANCISCO, CAUSADALLAS, TX USASYDNEY, AUSTRALIA

Yielding the results of the query expression:

NAME OOHIDEA INC. 120MOON CO. 80MOON CO. 30FIRST CO. 120FIRST CO. 120

Chapter 15. Database (SQL) 521

Retrieving Data from a Table Where Rows are RelatedData can be retrieved from a table where rows are related in thesame manner as when different tables are related.

The following example retrieves the names of products that arein the warehouse where televisions (TELEVISION) are stored.Two different aliases (correlation names) are given to the STOCKtable. They are treated as if they were different tables.

This COBOL program relates table rows and retrieves the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 544/783

p gproduct names in the warehouse which stores televisions(TELEVISION).

  :  EXEC SQL BEGIN DECLARE SECTION END-EXEC. 01 PRODUCT-NAME PIC X(20). 01 SQLSTATE PIC X(5).

  EXEC SQL END DECLARE SECTION END-EXEC. PROCEDURE DIVISION.  EXEC SQL WHENEVER NOT FOUND GO TO :P-END END-EXEC.  EXEC SQL  DECLARE CUR4 CURSOR FOR  SELECT DISTINCT X2.GOODS  FROM STOCK X1,STOCK X2 (1)  WHERE X1.GOODS = 'TELEVISION' AND  X1.WHNO = X2.WHNO  END-EXEC. P-START.

  EXEC SQL CONNECT TO DEFAULT END-EXEC.  EXEC SQL OPEN CUR4 END-EXEC. P-LOOP.  EXEC SQL  FETCH CUR4 INTO :PRODUCT-NAME  END-EXEC.  :  GO TO P-LOOP. P-END.  EXEC SQL CLOSE CUR4 END-EXEC.  EXEC SQL ROLLBACK WORK END-EXEC.

  EXEC SQL DISCONNECT DEFAULT END-EXEC.  STOP RUN.

Figure 130. Retrieving data from a table in which rows are related

(1) Specifies correlation names (X1 and X2) for the STOCK tablein the FROM clause of the cursor declaration statement. X1

522 Chapter 15. Database (SQL)

and X2 are treated as if they are different tables. The example

specifies search conditions in the WHERE clause. The columnname is qualified with the correlation names. The rows thatresult show products that are in the warehouse storingtelevisions (TELEVISION).

Updating Data

Use the UPDATE statement to update table data. The followingl ifi h UPDATE d h

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 545/783

example specifies the UPDATE statement to decrement eachquantity in stock (column QOH) of the STOCK table by 10%:

EXEC SQL  UPDATE STOCK SET QOH = QOH * 0.9END-EXEC.

This UPDATE statement multiplies each value in column QOHof the STOCK table by 0.9, and replaces the original value withthe result.

To update values in only rows that meet a specified condition,specify a search condition in the WHERE clause of the UPDATEstatement.

The following example changes the above UPDATE statement todecrement only the number of televisions in stock by 10%:

EXEC SQL  UPDATE STOCK SET QOH = QOH * 0.9  WHERE GOODS = 'TELEVISION'END-EXEC.

The previous method cannot update data in a table created by

relating multiple tables.

Chapter 15. Database (SQL) 523

Deleting Data

Use the DELETE statement to delete data. The following examplespecifies the DELETE statement to delete all rows showingCASSETTE DECK from the STOCK table:

EXEC SQL  DELETE FROM STOCK WHERE GOODS = 'CASSETTE DECK'

END-EXEC.

h h d d l d f bl d b

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 546/783

The previous method cannot delete data from a table created byrelating multiple tables.

Inserting Data

Use the INSERT statement to insert data. Select either of thefollowing methods to insert data:

• Inserting the data in only one row

• Inserting the data in a set of rows extracted from anothertable based on search conditions

Inserting a Single Row

The following example specifies the INSERT statement to add arow showing product number 301 to the STOCK table. Theproduct name is WASHER, the quantity in stock is 50, and thewarehouse number is 1:

EXEC SQL  INSERT INTO STOCK (GNO,GOODS, QOH, WHNO)  VALUES (301, 'WASHER', 50, 1)END-EXEC.

524 Chapter 15. Database (SQL)

Inserting Multiple Rows from Another Table

The following example assumes that the database of the STOCKtable contains another stock table (table name: SUBSTOCK,column names and attributes: same as those of the STOCKtable).

The example specifies the INSERT statement to insert rowsshowing product name MICROWAVE OVEN in the SUBSTOCKtable into the STOCK table

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 547/783

table into the STOCK table.

The example also sets the warehouse numbers of all new rows to2:

EXEC SQL  INSERT INTO STOCK (GNO, GOODS, QOH, WHNO)  SELECT GNO, GOODS, QOH, 2 FROM SUBSTOCK  WHERE GOODS = 'MICROWAVE OVEN'END-EXEC.

Using Dynamic SQL

To generate SQL statements during program execution and to

execute the statements, use dynamic SQL.

Determining Search Conditions Dynamically

The previous examples use host variables to set search conditionsat execution. The following explains a method of directlydetermining search conditions at execution.

Chapter 15. Database (SQL) 525

The following figure is a COBOL program for determining search

conditions at execution through dynamic cursor declaration. It isthe query expression for cursor definition:

SELECT GNO, GOODS, QOH FROM STOCK  WHERE GOODS = 'REFRIGERATOR' AND QOH < 10

The ACCEPT statement is used to read the query expression atexecution.

  :  EXEC SQL BEGIN DECLARE SECTION END-EXEC.01 PRODUCT-NUMBER PIC S9(4) COMP-5

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 548/783

01 PRODUCT NUMBER PIC S9(4) COMP 5.01 PRODUCT-NAME PIC X(20).01 QUANTITY-IN-STOCK PIC S9(9) COMP-5.01 STMVAR PIC X(254). (1)01 SQLSTATE PIC X(5).  EXEC SQL END DECLARE SECTION END-EXEC.PROCEDURE DIVISION.  EXEC SQL WHENEVER NOT FOUND GO TO :P-END END-EXEC.  EXEC SQL  DECLARE CUR8 CURSOR FOR STMIDT (2)  END-EXEC.  ACCEPT STMVAR FROM CONSOLE. (3)P-START.  EXEC SQL CONNECT TO DEFAULT END-EXEC.  EXEC SQL PREPARE STMIDT FROM :STMVAR END-EXEC. (4)  EXEC SQL OPEN CUR8 END-EXEC. (5) P-LOOP.  EXEC SQL  FETCH CUR8 INTO :PRODUCT-NUMBER, (6)  :PRODUCT-NAME,  :QUANTITY-IN-STOCK  END-EXEC.  :  GO TO P-LOOP.P-END.  EXEC SQL CLOSE CUR8 END-EXEC. (7)  EXEC SQL ROLLBACK WORK END-EXEC.  EXEC SQL DISCONNECT DEFAULT END-EXEC.  STOP RUN.

Figure 131. Specifying search conditions at execution

(1) The SQL statement variable STMVAR is referred to when thePREPARE statement in (4) is executed.

526 Chapter 15. Database (SQL)

(2) The SQL statement identifier STMIDT is corresponding to the

SQL statement variable STMVAR when the PREPAREstatement in (4) is executed.

(3) Executes the ACCEPT statement to read the queryexpression, and sets the read data into the SQL statementvariable STMVAR.

(4) Executes the PREPARE statement corresponding to the

statement (dynamic SELECT statement in the example) andset in the SQL statement variable STMVAR of the SQLstatement identifier STMIDT

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 549/783

statement identifier STMIDT.

(5) Executes the dynamic OPEN statement to extract, from theSTOCK table, rows showing a value less than 10 as thenumber of refrigerators in stock, then creates a tableincluding the data of columns GNO (product number),

GOODS (product name), and QOH (quantity in stock) that isretrieved from the extracted rows.

(6) Executes the dynamic FETCH statement to fetch data row byrow from the table, and sets the values of each column intothe corresponding host variable area.

(7) Executes the dynamic CLOSE statement to disable the

specified cursor and the table corresponding to the cursor.

Determining SQL Statements Dynamically

Dynamic SQL not only determines search conditions in a queryexpression through cursor declaration, but dynamicallydetermines the SQL statements to be executed there. The

following explains methods of determining the SQL statementsusing the EXECUTE statement.

The following figure is a COBOL program used to dynamicallyexecute SQL statements input with the ACCEPT statement. Theexample inputs the UPDATE statement at execution:

Chapter 15. Database (SQL) 527

UPDATE STOCK SET QOH = 0 WHERE GOODS = 'TELEVISION'

  :  EXEC SQL BEGIN DECLARE SECTION END-EXEC. 01 STMVAR PIC X(254). 01 SQLSTATE PIC X(5).  EXEC SQL END DECLARE SECTION END-EXEC. PROCEDURE DIVISION.

  ACCEPT STMVAR FROM CONSOLE. (1)  EXEC SQL CONNECT TO DEFAULT END-EXEC.  EXEC SQL PREPARE STMIDT FROM :STMVAR END-EXEC. (2)  EXEC SQL EXECUTE STMIDT END-EXEC. (3)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 550/783

Q ( )  :  EXEC SQL ROLLBACK WORK END-EXEC.  EXEC SQL DISCONNECT DEFAULT END-EXEC.  STOP RUN.

Figure 132. Dynamically determining SQL statements (1)

(1) Executes the ACCEPT statement to read the UPDATEstatement, and sets the read data into the SQL statementvariable STMVAR.

(2) Executes the PREPARE statement corresponding to thestatement (the UPDATE statement in the example) set in theSQL statement variable STMVAR of the SQL statement

identifier STMIDT.(3) The EXECUTE statement executes the prepared statement

that is associated with the specified SQL statement identifier.

If parameter specification is not required for dynamicallydetermining SQL statements, the EXECUTE IMMEDIATEstatement can be used instead of the EXECUTE statement.

528 Chapter 15. Database (SQL)

The following COBOL program illustrates the use of the

EXECUTE IMMEDIATE statement to perform the sameprocessing as shown in previous figure. The UPDATE statementused is specified at execution.

:  EXEC SQL BEGIN DECLARE SECTION END-EXEC.

01 STMVAR PIC X(254). 01 SQLSTATE PIC X(5).  EXEC SQL END DECLARE SECTION END-EXEC.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 551/783

 PROCEDURE DIVISION.  ACCEPT STMVAR FROM CONSOLE. (1)  EXEC SQL CONNECT TO DEFAULT END-EXEC.  EXEC SQL EXECUTE IMMEDIATE :STMVAR END-EXEC. (2)  :  EXEC SQL ROLLBACK WORK END-EXEC.  EXEC SQL DISCONNECT DEFAULT END-EXEC.  STOP RUN.

Figure 133. Dynamically determining SQL statements (2)

(1) Executes the ACCEPT statement to read the UPDATEstatement, then writes the read data to SQL statementvariable STMVAR.

(2) The EXECUTE IMMEDIATE statement directly executes theSQL statements written to the SQL statement variable.

Chapter 15. Database (SQL) 529

Specifying Dynamic Parameters

The following a COBOL program which illustrated thespecification of dynamic parameters and retrieving data from theSTOCK table. The example processes the SELECT statement atexecution:

SELECT GNO, GOODS FROM STOCK WHERE WHNO = ?

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 552/783

  :  EXEC SQL BEGIN DECLARE SECTION END-EXEC. 01 PRODUCT-NUMBER PIC S9(4) COMP-5. 01 PRODUCT-NAME PIC X(20). 01 QUANTITY-IN-STOCK PIC S9(9) COMP-5. 01 WAREHOUSE-NUMBER PIC S9(4) COMP-5. 01 STMVAR PIC X(254).

 01 SQLSTATE PIC X(5). 01 SQLMSG PIC X(254).  EXEC SQL END DECLARE SECTION END-EXEC. PROCEDURE DIVISION.  EXEC SQL WHENEVER NOT FOUND GO TO :P-END END-EXEC.  EXEC SQL  DECLARE CUR11 CURSOR FOR STMIDT (1)  END-EXEC.  ACCEPT STMVAR FROM CONSOLE. (2) P-START.  EXEC SQL CONNECT TO DEFAULT END-EXEC.

  EXEC SQL PREPARE STMIDT FROM :STMVAR END-EXEC. (3)  ACCEPT WAREHOUSE-NUMBER FROM CONSOLE. (4)  EXEC SQL OPEN CUR11 USING:WAREHOUSE-NUMBER  END-EXEC. (5)

  P-LOOP.  EXEC SQL  FETCH CUR11 INTO :PRODUCT-NUMBER,:  PRODUCT-NAME (6)  END-EXEC.  :

  GO TO P-LOOP. P-END.  EXEC SQL CLOSE CUR11 END-EXEC. (7)  EXEC SQL ROLLBACK WORK END-EXEC.  EXEC SQL DISCONNECT DEFAULT END-EXEC.  STOP RUN.

Figure 134. Specifying dynamic parameters

530 Chapter 15. Database (SQL)

(1) Defines CUR11 through dynamic cursor declaration.

(2) Executes the ACCEPT statement to read the dynamicSELECT statement.

(3) Executes the PREPARE statement to correspond thestatement set in the SQL statement variable STMVAR to theSQL statement identifier STMIDT.

(4) Reads the search condition values corresponding to dynamic

parameters.

(5) Executes the dynamic OPEN statement to extract rows

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 553/783

( ) ymatching the search conditions from the table. The valuesspecified in the USING clause are referred to as the values ofthe dynamic parameters in the prepared statement. Thevalues specified in the USING clause and the dynamic

parameters in the prepared statement are associated in theorder they appear.

(6) Executes the dynamic FETCH statement to fetch data row byrow from the table, and then writes the values of each columnto the host variables specified in the INTO clause.

(7) Executes the dynamic CLOSE statement to disable the

specified cursor and the table corresponding to the cursor.

Using Variable Length Character Strings

This section explains how to use variable length character stringsas the host variables of a COBOL program.

To operate variable length character string data, the length of thecharacter string is needed. Host variables of a variable lengthcharacter string type are defined as the following items:

• Signed binary item for storing the character string lengthinformation.

Chapter 15. Database (SQL) 531

• Group item (an alphanumeric item or national item) for

storing character strings.The following figure illustrates retrieving an address from theCOMPANY table. The host variable used as the search conditionand the host variable used for storing variable length characterstring data.

  :  EXEC SQL BEGIN DECLARE SECTION END.

 01 COMPANY-NAME PIC X(20). 01 TELEPHONE-NUMBER. }  49 TELEPHONE-NUMBER-LENGTH PIC S9(4) COMP-5. }  49 TELEPHONE-NUMBER-STRING PIC X(20). } (1)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 554/783

 01 ADDRESS. }  49 ADDRESS-LENGTH PIC S9(9) COMP-5. }  49 ADDRESS-STRING PIC X(30). } 01 SQLSTATE PIC X(5).  EXEC SQL END DECLARE SECTION END-EXEC. PROCEDURE DIVISION.  DISPLAY "Retrieves company according to telephone

  number."  DISPLAY "Input telephone number. ->" WITH NO ADVANCING.  ACCEPT TELEPHONE-NUMBER-STRING FROM CONSOLE. (2)  INSPECT TELEPHONE-NUMBER-STRING (3)  TALLYING TELEPHONE-NUMBER-LENGTH  FOR CHARACTERS BEFORE SPACE.  EXEC SQL CONNECT TO DEFAULT END-EXEC.  EXEC SQL  SELECT NAME,ADDRESS INTO :COMPANY-NAME,  :ADDRESS (4)  FROM COMPANY

  WHERE PHONE = :TELEPHONE-NUMBER  END-EXEC.  :  EXEC SQL ROLLBACK WORK END-EXEC.  EXEC SQL DISCONNECT DEFAULT END-EXEC.  STOP RUN.

Figure 135. Operating variable length character string data

(1) Declares variable length character strings as host variables.

(2) Executes the ACCEPT statement to read the value of the hostvariable used as the search condition, and sets the value asTELEPHONE-NUMBER-STRING.

(3) Sets the length of the read value as TELEPHONE-NUMBER-LENGTH.

532 Chapter 15. Database (SQL)

(4) Executes the SELECT statement (single row) to retrieve the

row meeting the search condition from column ADDRESS.The length and value of the retrieved character string are setinto the host variable "ADDRESS".

If the data of a host variable used as a search condition is acharacter string type or a national character string type, definethe length of the host variable to be equal to or shorter than thelength of the character string.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 555/783

Chapter 15. Database (SQL) 533

Operating the Cursor with More than One Connection

This section explains how to operate a cursor with more than oneconnection. The following COBOL program is used for operatingthe cursor in the following conditions:

• SV1 and SV2 exist as servers

• Both servers contain a table under the same name and in thesame format.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 556/783

  :  EXEC SQL BEGIN DECLARE SECTION END-EXEC. 01 PRODUCT-NUMBER PIC S9(4) COMP-5. 01 PRODUCT-NAME PIC X(20). 01 QUANTITY-IN-STOCK PIC S9(9) COMP-5. 01 WAREHOUSE-NUMBER PIC S9(4) COMP-5. 01 SQLSTATE PIC X(5).

  EXEC SQL END DECLARE SECTION END-EXEC. 01 NEXTFLAG PIC X(4) VALUE SPACE. PROCEDURE DIVISION.  EXEC SQL DECLARE CUR9 CURSOR FOR (1)  SELECT * FROM STOCK  END-EXEC.  EXEC SQL WHENEVER NOT FOUND  GO TO :P-NEXT END-EXEC. (2) P-START.  EXEC SQL  CONNECT TO 'SV1' AS 'CNN1' USER 'summer/w43' (3)

  END-EXEC.  EXEC SQL  CONNECT TO 'SV2' AS 'CNN2' USER 'tanaka/sky' (4)  END-EXEC. P-CNN2-1.  EXEC SQL OPEN CUR9 END-EXEC. (5)  GO TO P-LOOP. P-NEXT.  IF NEXTFLAG = "NEXT" THEN  GO TO P-CNN1-2  END-IF.

Figure 136. Operating a cursor with more than one connection

534 Chapter 15. Database (SQL)

  P-CNN1-1.  EXEC SQL SET CONNECTION 'CNN1' END-EXEC. (7)  EXEC SQL  INSERT INTO STOCK (8)  VALUES(:PRODUCT-NUMBER, :PRODUCT-NAME,  :QUANTITY-IN-STOCK, :WAREHOUSE-NUMBER)  END-EXEC.  EXEC SQL OPEN CUR9 END-EXEC. (9)  MOVE "NEXT" TO NEXTFLAG.  GO TO P-LOOP. P-CNN1-2.  EXEC SQL CLOSE CUR9 END-EXEC. (10)  EXEC SQL ROLLBACK WORK END-EXEC.  EXEC SQL DISCONNECT 'CNN1' END-EXEC. P-CNN2-2.  EXEC SQL SET CONNECTION 'CNN2' END-EXEC. (11)  EXEC SQL CLOSE CUR9 END-EXEC. (12)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 557/783

  EXEC SQL ROLLBACK WORK END-EXEC.  EXEC SQL DISCONNECT CURRENT END-EXEC. P-END.  STOP RUN. P-LOOP.  EXEC SQL  FETCH CUR9 (6)  INTO :PRODUCT-NUMBER, :PRODUCT-NAME,  :QUANTITY-IN-STOCK, :WAREHOUSE-NUMBER  END-EXEC.  :  GO TO P-LOOP.

Figure 136. Operating a cursor with more than one connection (cont.)

(1) Defines the cursor for retrieving data from the table.

(2) Specifies branching to the procedure name P-NEXT if thereis no row to be retrieved when the embedded SQL exceptiondeclaration is specified.

(3) The server SV1 is connected. This connection name is CNN1.

(4) The server SV2 is connected. This connection name is CNN2.CNN2 is the current connection.

(5) Executes the OPEN statement in the server with CNN2 toenable the cursor CUR9.

(6) Executes the FETCH statement to fetch data row by rowfrom the table, then writes the values of each column to thecorresponding host variable area.

Chapter 15. Database (SQL) 535

(7) Select the current connection to CNN1.

(8) Executes the INSERT statement to insert a row into theSTOCK table of the server with CNN1.

(9) Executes the OPEN statement in the server with CNN1 toenable the cursor CUR9. The cursor CUR9 is treated asanother cursor different from the cursor that was opened inthe server with CNN2.

(10) Executes the CLOSE statement in the server with CNN1 todisable the cursor CUR9.

(11) Select the current connection to CNN2. Note that the cursor

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 558/783

(11) Select the current connection to CNN2. Note that the cursorCUR9 is still enabled in the server with CNN2.

(12) Executes the CLOSE statement in the server with CNN2 todisable the cursor CUR9.

Compiling the Program

Specify a database access method so that a COBOL programaccessing a database using embedded SQL via an ODBC driver

can be compiled with the COBOL85 compiler.To enable case-sensitivity for host variable names, specify theNOALPHAL compiler option before compiling the program.

Note: Embedded SQL keywords cannot be used as user-definednames.

536 Chapter 15. Database (SQL)

Executing the Program

This section explains how to construct the program executionenvironment, and how to use the ODBC Information Setup Tool.

Constructing the Program Execution Environment

An initialization file (COBOL85.CBR) where run-timei t i f ti i ifi d d th ODBC i f ti

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 559/783

environment information is specified, and the ODBC informationfile are required for program execution. Specify information inthe files so that the files are related as follows:

• Specify the ODBC information file name(C:\DBMSACS.INF).

Chapter 15. Database (SQL) 537

• If a server name is specified in the CONNECT statement,

specify the server name in the ODBC information file.• If DEFAULT is specified in the CONNECT statement, specify

a fixed character string indicating the definition of defaultconnection information in the ODBC information file.

• To define the data source name of each server specified in theODBC information file, specify the data source name defined

in the Windows system ODBC control panel.

Setting Runtime Environment Information

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 560/783

To select the ODBC environment as client-server linkagesoftware, specify the information shown below in the RuntimeEnvironment Information and is reflected in the initialization file

(COBOL85.CBR). The file can also be edited.@ODBC_Inf (specification of the ODBC information file name)

@ODBC_Inf=C:\DBMSACS.INF

Specify the file name that the COBOL85 run-time system willrefer when using ODBC. See “Creating an ODBC InformationFile” for more information.

Creating an ODBC Information File

An ODBC information file mainly contains information forconnecting a client and server. Use the CONNECT statement tospecify the connection.

Use the ODBC Information Setup Tool to create an ODBCinformation file. See “Using the ODBC Information Setup Tool”for more information.

The contents of an ODBC information file is classified into serverinformation and default connection information.

538 Chapter 15. Database (SQL)

Defining Server Information

The following table defines server information.Table 57. How to define server information

Information Name[Server Name]

Definition[Server Name]

Remarks[Connect Sentence server name ordefault connection information]

@SQL_DATASCR Data source name Specify the data source name defined(added) on the Windows system

ODBC control panel.@SQL_ACCESS_MODE Access mode

  READ_ONLY  READ_WRITE

Specify an access mode for the datasource. The default is READ_ONLY.To enable the read only mode, specifyREAD ONLY

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 561/783

READ_ONLY.To enable the read-write mode,specify READ_WRITE. Operation inthe specified mode can varyREAD_WRITE based on the

capabilities of the ODBC driver.

@SQL_COMMIT_MODE Commit mode  MANUAL  AUTO

Specify a commit mode (operation oftransaction) for the data source.The default is MANUAL. IfMANUAL is specified, SQL operationis determined by specifying theCOMMIT or ROLLBACK statement inthe COBOL source program.If AUTO is specified, operation isdetermined each time an SQLstatement is executed, regardless ofthe specification in the COBOL sourceprogram. If AUTO is specified, SQLstatement processing is reflected intothe database at execution of the SQLstatement. As a result, the database

cannot be restored to the originalstatus with a ROLLBACK statement.Manual should be specified to avoidthis problem.

Chapter 15. Database (SQL) 539

@SQL_QUERY_TIMEOUT(32) Timeout(seconds) Specify the number of seconds to waitfor a SQL statement to execute beforereturning to the application. Thetimeout range must be between 0 and4294967285 (seconds). The default is 0meaning that there is not timeoutlimit.Operation of the timeout can varydepending on the ODBC driver. If

errors occur for timeout thespecification should be removed.SQL_CONCURRENCY(32) Cursor

concurrencymode

Specify the cursor concurrency.Concurrency is the ability of morethan one user to use the same data at

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 562/783

mode  READ_ONLY  LOCK  ROWVER VALUES

than one user to use the same data atthe same time. The default isREAD_ONLY. Refer to the next tablefor more information. Operation forthe cursor concurrency mode can vary

depending on the ODBC driver.

NOTE: The ODBC Information Setup Tool cannot be used to set@SQL_QUERY_TIMEOUT and @SQL_CONCURRENCY. Thisinformation must be manually placed in the COBOL85.CBR file

using a text editor.

540 Chapter 15. Database (SQL)

Table 58. Operation for the cursor concurrency mode of @SQL_CONCURRENCY (32)

Mode Operation

READ_ONLY FETCH statement is allowed. No position UPDATE and DELETE statementsare allowed.

LOCK FETCH, positionUPDATE andposition DELETE

statements areallowed.

NOCONCURRENCY

When processing FETCH,position UPDATE andposition DELETE statements,

the table is locked andoperations from sever or otherclients wait until operation iscomplete.

ROWVER CONCURRENCY FETCH statement using same

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 563/783

ROWVER CONCURRENCY FETCH statement using samedata is allowed. Whenprocessing position UPDATEor DELETE statements, and arow is changed, the

transaction containing theupdate or delete operationfails. If the row has notchanged, the table is lockeduntil the operation iscomplete.To determine if a row haschanged, the rows andversions should be compared.

VALUE Operation is the same asROWVER. To determine if arow has changed, the datavalues should be compared.

Note: Operation for the cursor concurrency mode of@SQL_CONCURRENCY depends on the data source. (32)

Chapter 15. Database (SQL) 541

Defining Default Connection Information

If DEFAULT is specified in the CONNECT statement, connectionis established.

A user ID and password defined in default connectioninformation are used for establishing connection if server name isspecified in the CONNECT statement, but the user ID andpassword are omitted.

The following table defines default connection information.

T bl 59 H t d fi d f lt ti i f ti

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 564/783

Table 59. How to define default connection information

Information Name Definition Remarks[SQL_DEFAULT_INF] Fixed character

stringSpecify the fixed character string (sectionname) indicating the start of definition ofdefault connection information.

@SQL_SERVER Server name Specify the name of a server where defaultconnection is to be established. This servername is used for retrieving the definitioninformation of each server and forestablishing connection for the data sourcefor each server. The definition informationmust be specified.

@SQL_USERID User ID Specify the user ID for operating the datasource of the server.@SQL_PASSWORD Password Specify the password for operating the

data source of the server. Use the ODBCInformation Setup Tool to encrypt thepassword.

Note: Specify both user IDs and passwords. Neither can beomitted.

542 Chapter 15. Database (SQL)

Using the ODBC Information Setup Tool

The ODBC information setup tool allows you to set informationin the ODBC information file in order to access remote databasesvia ODBC.

The following functions are provided in ODBC information setuptool.

• Select an ODBC information file

• Set server information

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 565/783

• Set default connection information

To use the ODBC information setup tool, follow the steps below(Refer to the online help for additional details).

1. Start the ODBC information setup tool.Use the SQLODBCS.EXE to start the ODBC informationsetup tool.

2. Select an ODBC information file.Specify an ODBC information file to set up connectioninformation. If a file does not exist, create one with a text

editor.

3. Setup the server information.Use the CONNECT statement or select default connectioninformation to set the server name.

4. Setup the default connection information.Use the CONNECT statement with the DEFAULT

specification to set default connection information (servername, user ID, and password).

Chapter 15. Database (SQL) 543

Maximum Length of Information Specified in the ODBC

Information File

The following table shows the maximum length of informationspecified in an ODBC information file.

Table 60. ODBC information file specifications

Information Type Maximum Length Remarks

User ID 32 bytes The maximum length depends on thespecification of the data source used forestablishing the connection. Refer to theODBC manual for more information aboutthe ODBC driver environment.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 566/783

Password 32 bytesServer name 32 bytes -------------------Data source name 32 bytes -------------------

Use the ODBC Information Setup Tool to set up a password. Thepassword must be encrypted. Do not edit the password with aneditor.

Preparing Linkage Software and the HardwareEnvironment

Prepare the linkage software and hardware environment for aCOBOL application program to access a server database throughODBC using the following procedures:

Setting Up the ODBC Environment

• Install ODBC in the Windows system. If the ODBCenvironment is installed in the Windows system for the firsttime, use the ODBC setup supported with the ODBC driver.

• ODBC is added to the Windows control panel. Install theODBC driver, then create a data source. Start the ODBC

544 Chapter 15. Database (SQL)

control panel (usually in a Windows control panel group),then set it up. The ODBC driver is installed and the datasource is defined.

• Prepare the ODBC driver environment. An ODBC driver isdesigned to assume the environment where it operates. Forinformation on the ODBC driver environment, refer to themanual and help information of the ODBC driver. The helpinformation can be referenced by starting the ODBC control

panel.

 Confirming a Connection with the Data Source

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 567/783

A database usually supports programs for a client to operate aserver database. Before executing a COBOL application programusing ODBC, use the programs to check whether the client and

server are connected normally.

Execute the COBOL application program after completing thesetup of the ODBC control panel, with the runtime environmentinformation which is placed in initialization file(COBOL85.CBR), and the ODBC information file.

Chapter 15. Database (SQL) 545

Embedded SQL Keyword List

This section gives a keyword list for embedded SQL.

[A]ABSOLUTE

ADAADDALLALLOCATEALTERAND

COBOLCOLLATE

COLLATIONCOLLATION_CATALOGCOLLATION_NAMECOLLATION_SCHEMACOLUMNCOMMIT

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 568/783

ANDANYAREASASCASSERTIONATAUTHORIZATIONAVG[B]BEGINBETWEENBINDBIT

BIT_LENGTHBY[C]CASCADECASCADEDCASECASTCATALOGCHARCHAR_LENGTH

CHARACTERCHARACTER_LENGTHCHARACTER_SET_CATALOGCHARACTER_SET_NAMECHARACTER_SET_SCHEMACHECKCLOSECOALESCE

COMMITCONNECTCONNECTIONCONSTRAINTCONSTRAINTSCONTINUECONVERTCORRESPONDING COUNTCREATECURRENTCURRENT_DATECURRENT_TIMECURRENT_TIMESTAMP_ CURSOR[D]

DATADATEDATETIME_INTERVAL_CODEDATETIME_INTERVAL_PRECISIONDAYDEALLOCATEDECDECIMALDECLAREDEFAULT

DEFERRABLEDEFERREDDELETEDESCDESCRIBEDESCRIPTORDIAGNOSTICSDICTIONARY

546 Chapter 15. Database (SQL)

DISCONNECTDISPLACEMENT

DISTINCTDOMAINDOUBLEDROP[E]ELSEENDEND-EXECESCAPEEXCEPT

EXCEPTIONEXECEXECUTEEXISTSEXTERNALEXTRACT

INPUTINSENSITIVE

INSERTINTEGERINTERSECTINTERVALINTOISISOLATION[J]

 JOIN[K]

KEY[L]LANGUAGELASTLEFTLENGTH

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 569/783

EXTRACT[F]FALSEFETCHFIRSTFLOATFORFOREIGNFORTRANFOUNDFROMFULL[G]GET

GLOBALGOGOTOGRANTGROUP[H]HAVINGHOUR[I]IDENTITY

IGNOREIMMEDIATEININCLUDEINDEXINDICATORINITIALLYINNER

LENGTHLEVELLIKELISTLOCALLOWER[M]MATCHMAXMINMINUTEMODULEMONTHMUMPS

[N]NAMENAMESNATIONALNCHARNEXTNONENOTNULLNULLABLE

NULLIFNUMERIC[O]OCTET_LENGTHOFOFFONONLY

Chapter 15. Database (SQL) 547

OPENOPTION

ORORDEROUTEROUTPUTOVERLAPS

[P]PARTIALPASCALPLI

POSITIONPRECISIONPREPAREPRESERVEPREVIOUSPRIMARY

SUMSYSTEM

[T]TABLETEMPORARYTHENTIMETIMESTAMPTIMEZONE_HOURTIMEZONE_MINUTETOTRANSACTION

TRANSLATETRANSLATIONTRUETYPE[U]UNION

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 570/783

PRIORPRIVILEGESPROCEDUREPUBLIC[R]RELATIVERESTRICTREVOKERIGHTROLLBACKROWS[S]SCALE

SCHEMASCROLLSECONDSECTIONSELECTSEQUENCESETSIZESMALLINTSOME

SQLSQLCASQLCODESQLERRORSQLSTATESQLWARNINGSTARTSUBSTRING

UNIQUEUNKNOWNUPDATEUPPERUSAGEUSERUSING[V]VALUEVALUESVARCHARVARIABLESVARYING

VIEW[W]WHENWHENEVERWHEREWITHWORK[Y]YEAR

548 Chapter 15. Database (SQL)

Correspondence Between ODBC-HandledData and COBOL85-Handled Data

COBOL85 handles the ODBC data corresponding definitionslisted in the following table. To understand how an ODBC driver

handles ODBC SQL data, refer to ODBC driver users guide andonline help.

Data contents can only be assured when data correspondence asdefined in the following table is used.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 571/783

Table 61. Correspondence between ODBC and COBOL85 data handling

Arithmetic Data:

ODBC SQL Data Type COBOL85 Description

Binary SQL_SMALLINT (SMALLINT) PIC S9(4) BINARY or PIC S9(4) COMP-5SQL_INTEGER (INTEGER) PICS9(9) BINARY or PIC S9(9) COMP-5

Decimal SQ:_DECIMAL (DECIMAL) PIC S(9p) PACKED-DECIMAL orPIC S9(p)V9(q) PACKED-DECIMAL1 =< p =<15, 1=< q, p+q =<18

SQL_NUMERIC (NUMERIC) {PIC S9(p) }

{PIC S9(p)V9(q)}[ SIGN IS  {LEADING SEPARATE CHARACTER}  {TRAILING }]1 =< p =<15, 1=< q, p+q =<18

Internal floatingpoint

SQL_REAL (REAL) COMP-1

SQL_DOUBLE (FLOAT) COMP-2

Chapter 15. Database (SQL) 549

Character Data:

ODBC SQL Data Type COBOL85 Description

Fixed length SQL_CHAR(CHAR)

PIC X(n) 1=< n =< 254PIC N(n) 1=< n =<127 (*1)

Variable SQL_VARCHAR(VCHAR)

01 data-name-1.  49 data-name-2 PIC S9(m) COMP-5.  49 data-name-3 PIC X(n).  m = 4 or 9  1 =< n =< 254 (*2)

 _____________________________________________ 

01 data-name-1  49 data-name-2 PIC S9(m) BINARY.  49 data-name-3 PIC X(n).

or

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 572/783

  or01 data-name-1. (*1)  49 data-name-2 PIC S9(m) BINARY.  49 data-name-3 PIC N(n).  m = 4 or 9  1 =< n =< 254 (*2)

*1: Depends on the database that supports national character data and the database-relatedproducts.*2: Specify the number of characters for the variable length of character data.

550 Chapter 15. Database (SQL)

SQLSTATE, SQLCODE, and SQLMSG

This section describes information which is shown in thenotification area of the COBOL, ODBC driver manager, ODBCdriver, or DBMS if an SQL statement is executed using ODBC.

The following table explains information posted as SQLSTATE,SQLCODE, and SQLMSG.

Table 62. SQLSTATE, SQLCODE, and SQLMSG information

Information Value Posted Explanation Programmer ResponseSQLSTATE 000000 Normal termination

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 573/783

SQLSTATE 000000 Normal termination _______________________  

5 alphanumeric

characters

Error or warning during

execution of an SQLstatement

CHECK SQLCODE and

SQLMSG, and take actionif error is detected. ForSQLSTATE information,Refer to the ODBC SDKmanual.

SQLCODE 0 Normal termination _______________________  

Negative integerother than 0

Error or warning duringexecution of an SQL

statement

Check the cause of theerror according to the

ODBC environment (suchas ODBC or DBMS)manual, and takecorrective action on theerror.

SQLMSG Blank (nooutput)

Normal termination ________________________  

Message

(character string)

The message explains an

error or warning postedduring execution of an SQLstatement

Check the cause of the

error according to thedisplayed message, andtake corrective action onthe error.

Chapter 15. Database (SQL) 551

The following describes errors which might be detected by

COBOL during execution of an embedded SQL statement. Theinformation is posted as SQLSTATE, SQLCODE, and SQLMSG.

Table 63. SQLSTATE, SQLCODE, and SQLMSG error information

SQLSTATE SQLCODE SQLMSG Programmer response99999 -999999999 The connection has been

established with the sameconnection name

A connection name mustnot be specified for morethan one connection.

Specify a unique name foreach connection.9999A -999999990 The number of connections

exceeds the maximum.The number of connectionsexceeds the maximumspecified in the COBOLsystem. Decrease the

b f i Th

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 574/783

number of connections. Themaximum number ofconnections can vary

depending on the ODBCenvironment. Refer to theODBC environmentmanual and take action.

9999B -999999800 The specified connectiondoes not exist.

SQL statements cannot beexecuted because theconnection is not active.Check the SQL statementsequence in the program,

and take corrective actionon the error.

999SA -999999700 The cursor is not opened. The cursor is not ready.Check the sequence of SQLstatements using thecursor, and take correctiveaction for the error.

999SB -999999600 The prepared statement is

not prepared.

Check the sequence of

dynamic SQL statements,and take corrective actionfor the error.

????? -999999992 Invalid process occurred. A system error occurred.

552 Chapter 15. Database (SQL)

Notes on Using the ODBC Driver 

This section explains usage notes for ODBC drivers. Pay specialattention to this section, since it covers important usageinformation.

Notes on SQL Statement Syntax

DATA DIVISION

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 575/783

The correspondence between ODBC data types and host variabledata types is defined for COBOL85. See “CorrespondenceBetween ODBC-Handled Data and COBOL85-Handled Data” formore information. Data contents are assured for only the defineddata correspondence as specified.

Some data types may not be handled by COBOL as hostvariables depending on the ODBC driver specification.

PROCEDURE DIVISION

Embedded SQL statements that can be used and the statementspecification method are different between ODBC drivers.

If embedded SQL statements are specified in the COBOL sourceprogram, refer to product manuals as well as the COBOL

specification for:• ODBC driver

• Software and hardware related to the ODBC driver

• Database management system

Chapter 15. Database (SQL) 553

Use the COMMIT or ROLLBACK statements to terminatetransactions. Otherwise, the operation may not be assured.Before using the DISCONNECT statement to terminate aconnection, execute the COMMIT or ROLLBACK statement toterminate the transaction.

The SQL descriptor area cannot be used. Therefore, do notspecify the following embedded SQL statements:

• INTO and USING clauses in which a descriptor name is

specified

• SQL statements for the descriptor area: ALLOCATEDESCRIPTOR, DEALLOCATE DESCRIPTOR, GETDESCRIPTOR, SET DESCRIPTOR, and DESCRIBEt t t

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 576/783

statements

You cannot specify the DEALLOCATE PREPARE statement.

You cannot specify any SQL statement for data definition (DDL).

When using a dynamic SQL statement such as the PREPARE,EXECUTE, or EXECUTE IMMEDIATE statement, NOT FOUNDspecification in the WHENEVER clause is not available.

Details on the embedded SQL statement syntax comply with thedatabase specification and the specification of the databaserelated products.

Notes on Executing Embedded SQL Statements

Embedded SQL statements that can be used and the methods ofspecifying the statements are different between ODBC drivers.

If embedded SQL statements are specified in the COBOL sourceprogram, refer to product manuals as well as the COBOLspecification for:

• ODBC driver

554 Chapter 15. Database (SQL)

• Software and hardware related to ODBC driver

• Database management systemTo quit transactions, use the COMMIT or ROLLBACKstatements; otherwise, the operation may not be guaranteed.Before using the DISCONNECT statement to terminate aconnection, execute the COMMIT or ROLLBACK statements toterminate the transaction.

If X'00' is stored as a value in character data, the storage andfetch results are not assured.

Details on the embedded SQL statement syntax comply with thedatabase specification and the specification of the database-related products.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 577/783

p

Quantitative Limits of Embedded SQL Statement atExecution

An embedded SQL statement can be up to 4,096 bytes in length.The maximum length may be shorter depending on the ODBCdriver environment.

For example, the maximum length of an embedded SQLstatement may be shorter than 4,096 bytes because of themaximum length of data transferred by the software productresponsible for the network.

If the ODBC driver processes data in an embedded SQLstatement from COBOL, the embedded SQL statement may belonger than specified in the COBOL source program.

An area for input and output processing between a client andserver can be up to 8,192 bytes in length. The sum of the inputvariable length and output variable length must be within theallowable range. The area may be shorter than 8,192 bytesdepending on the ODBC driver environment.

Chapter 16. DistributedDevelopment Support Functions

COBOL85 uses the SIA COBOL syntax (defined in the FUJITSUCOBOL Reference Manual). A program written according to theSIA specification can be developed under this system. The

developed program can operate under various types of systems.

This chapter explains distributed development with the systemof GS-series (M-series) application program as a host. Note: Thischapter is only applicable if you are running M-series or GS-series

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 578/783

series.

556 Chapter 16. Distributed Development Support Functions

Outline of Distributed Development

COBOL85 enables development of a program that operates withthe Global server (hereafter referred to as GS or GS program). Tooperate a host program that uses a function specific to the Globalserver system, requirements for the operating environment

(movement method) must be cleared. For information aboutspecific functions, refer to Appendix I, “GS-series FunctionComparison.”

For clarification between the GS-series and the previous M-seriessystems, the following terms are defined:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 579/783

y g

GS-series

The successor to the M-series; it is the same as the M-series.

Global server

GS-series (M-series) as it is seen from the system.

GS program

A program that works with the GS-Series (M-series).

GS-specific function

 A function that can only be used with the GS-series (M-series)system.

Chapter 16. Distributed Development Support Functions 557

Scope of Distributed Development

Functions

The following figure is a diagram of the scope of GS-seriesfunctions and COBOL85 functions.

Operation of the common functions shown in Figure 137 can be

checked under this system. To what extent GS-series functionscan be developed under this system differs depending on thefunctions.

Refer to Appendix I, “GS-series Function Comparison” for noteson handling the functions specific to GS-host and operating hostprograms under this system

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 580/783

programs under this system.

558 Chapter 16. Distributed Development Support Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 581/783

Figure 137. Scope of GS-series functions and COBOL85 functions

Chapter 16. Distributed Development Support Functions 559

Distributed Development SupportFunctions

The distributed development support functions support theenvironment for operating the following two host-specificfunctions. The environment enables operation from compilationto module testing under this system.

• Presentation file function

• Network database function

For the presentation file module test function used with the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 582/783

For the presentation file module test function used with thepresentation file function, see “Presentation File Module Test

Function.”

Target Language Construct

This section shows the language construct of host-specificfunctions used as support functions.

Presentation File

Destination APL, CMD, TRM, or WST.

Network Database

Database manipulation language (DML)

• IF DB-EXCEPTION statement

560 Chapter 16. Distributed Development Support Functions

System Control

• TRANSACTION management statement

• USE FOR DB-EXCEPTION statement

• USE FOR DEAD-LOCK statement

Usage

Required Resources

This section explains software and resources required foroperation, from GS program compilation to the module test

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 583/783

operation, from GS program compilation to the module testunder this system.

Software

• COBOL85 compiler (required)

• COBOL85 run-time system (required)

• COBOL85 debugger (required)

• COBPRTST command program file (required for presentationfile module test)

Resources

• Subschema definition file

A subschema definition file is required to compile a GSprogram that uses network database functions. A subschemadefinition file contains the definition information of an areafor communication (FCOM) with a GS-based advancedinformation management (AIM) system and an AIM

Chapter 16. Distributed Development Support Functions 561

expansion record area (UWA). The definition information isfetched from the AIM directory of the host machine. The

extension CBL is given to the subschema name specified inthe subschema name paragraph of the GS program.

To fetch the subschema definition file from the GS, use thesubschema fetch tool (GETSSCH). See GETSSCH.TXT.

Compiling a GS Program

Compiler Options to be Specified

TEST: Whenever a debugger is used, specify this option.

AIMLIB (directory-name): To compile a GS program using anetwork database, specify this option The directory name of the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 584/783

network database, specify this option. The directory name of thesubschema definition file must be specified for directory-name.

GEN/NOGEN: To write the FCOM and UWA expansioninformation to the compilation list, specify GEN; otherwise,specify NOGEN.

Compilation Results

A W-level message indicating GS-specific functions is produced

for the following specified in the COBOL source program:• Network database manipulation language (DML)

• Destination APL/CMD/TRM/WST with literalspecified in presentation file

• IF DB-EXCEPTION statement

• USE FOR DB-EXCEPTION statement• USE FOR DEAD-LOCK statement

• TRANSACTION management statement

562 Chapter 16. Distributed Development Support Functions

When the TRANSACTION management statement is executed,the syntax is analyzed, but no object is produced.

Linking a GS Program

Whenever a debugger is used, specify linkage option:

/DEBUG (Specify to use debugger.) and/DEBUGTYPE{COFF|BOTH}(32), /CO(16)

Executing a GS Program

To execute the executable file of a GS program, use the COBOL85debugger. If the file is executed without the debugger, a messageis written indicating GS-specific functions cannot be executed,

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 585/783

is written indicating GS specific functions cannot be executed,and the program is forcibly terminated.

To execute a GS program with the debugger:

1. Activate the debugger. Refer to the “Fujitsu COBOLDebugging Guide” for additional information. The COBOL85Debugger window is displayed.

Chapter 16. Distributed Development Support Functions 563

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 586/783

Figure 138. The COBOL85 Debugger window

564 Chapter 16. Distributed Development Support Functions

2. Select Start Debugging from the File menu to open the StartDebugging dialog box. Specify the required setup items.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 587/783

Figure 139. The Start Debugging dialog box, Application tab selected

Set the application name in the Application edit box.

Chapter 16. Distributed Development Support Functions 565

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 588/783

 Figure 140. The Start Debugging dialog box, Source tab selected

Set the Subschema descriptor file storage folder (directory) inthe Subschema descriptor file storage folders edit box.

3. Click on the OK button. The program is executed, then the

debugger screen is displayed.4. The debugger automatically suspends program execution

when a statement using a GS-specific function is executed. Itdisplays the Data Name List dialog box that shows the datanames related to the network database function andpresentation file function (selected when the program isexecuted). You can confirm the content of the data or open it

by selecting the data name and clicking on theDisplay/Modify button. The Data dialog box opens and youcan change the data if necessary.

5. Close the Data dialog box at the completion of data setup,then resume program execution.

566 Chapter 16. Distributed Development Support Functions

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 589/783

 

Figure 141. Windows at completion of data setup

READY Statement

If the READY statement is not specified in a program andEXTERNAL is not specified in the subschema name paragraph,FCOM and UWA are defined as item names only, and no areasare allocated. If the program is executed in this condition (areasnot allocated), operation is not guaranteed.

To execute the program normally, specify linkage sectionallocation in the debugger for the 01-level items of FCOM andUWA. The debugger allocates FCOM and UWA areas whenlinkage section allocation is executed. Consequently, the program

Chapter 16. Distributed Development Support Functions 567

can be executed in the same manner as when the READYstatement is specified.

USE Statement Execution

The USE procedure is used for branching processing if an erroroccurs in a system for processing the presentation file or networkdatabase function called by the application. This system cannotbranch processing to the USE procedure during executionbecause it has no system for processing the presentation file ornetwork database function.

To execute the USE procedure, specify a breakpoint to suspendexecution. Then, use the debugger move to execution start pointfunction to move the execution start point to the first instructionof the USE procedure to resume execution.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 590/783

Executing the Presentation File FunctionTo execute the presentation file function, assign a dummy filename (non-existent file name) to the file identifier specified in theASSIGN clause of the file control entry.

AT END Specification

No actual input target file or database exists for statements with

AT END specified. Consequently, AT END conditions are notproduced and processing never branches to a statement at theAT END destination.

To execute a statement at the AT END destination, specify abreakpoint for the first-executed statement for NOT AT END,then use the debugger move to execution start point function to

move the execution start point to the first-executed statement atthe AT END destination to resume execution.

Data Name List Display

Fillers are not displayed.

568 Chapter 16. Distributed Development Support Functions

GS-Specific Functions that Cannot be Used

The USE IN TRANSACTION statement cannot be used.

Executing the USE IN TRANSACTION statement results in aUSE statement specification error and TRANSACTION statementspecification error.

Presentation File Module Test Function

The presentation file module test function executes a module testduring distributed development with the GS-series system. Amodule test is executed for an application program whichperforms interactive processing using the presentation filefunction on this system.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 591/783

For more information about how to use this function, refer to the“OSIV AP/EF User’s Guide (Application Program).”

Operating Environment

This section shows the operating environment for executing the

presentation file module test function.The FORM-created screen descriptor and FORM RTS arerequired for using the presentation file module test function.

Chapter 16. Distributed Development Support Functions 569

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 592/783

Figure 142. The operating environment for executing the presentation filemodule test function

Creating Files Required for Using the Presentation FileModule Test Function

The following files are required for using the presentation filemodule test function:

• A screen descriptor that defined the initial screen

• Other screen and form descriptors required

570 Chapter 16. Distributed Development Support Functions

• Executable file in DLL format

Window information file for the screen descriptor of theinitial screen

• Other window and printer information files required

• Environment file

Before executing the presentation file module test function, takethe following steps to create the required files:

1. Design an initial screen and creating screen and formdescriptors

2. Create a COBOL source program

3. Compile and linking a program

4. Create window and printer information files

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 593/783

p

5. Create an environment file

Designing an Initial Screen and Creating Screen and FormDescriptors

The presentation file module test function performs all

interactive processing through screens.Before using the function, determine the correspondencebetween screens and programs and the hierarchical structure ofthe screens (screen transition).

To design the initial screen, use FORM to create a screendescriptor of the initial screen. Create more screen and form

descriptors if they are required for application programs. Forhow to use FORM, refer to the “FORM V1.3 Manual.”

To split a screen, define a split procedure.

To define a split procedure, select split procedure definitionduring creation of the screen descriptor.

Chapter 16. Distributed Development Support Functions 571

Split procedure definition defines operation according to inputdata (field input value or attention type) for any data item of the

screen descriptor. For details on the split procedure, refer to the“FORM V1.3 Manual.”

 Creating a COBOL Source Program

Use the editor to create a COBOL source program.

A knowledge of COBOL85 and presentation file interface isrequired for creating a COBOL source program. For details, referto the “COBOL Reference Manual,” “FORM V1.3 Manual,” andthe FORM RTS online help.

Compiling and Linking a Program

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 594/783

See “Distributed Development Support Functions” for theprocedure for compiling and linking a program. The program tobe used with the presentation file module test function must becreated in DLL format.

Creating a Window and Printer Information Files

The presentation file module test function needs the windowinformation file for the initial screen. If screens and forms are tobe used with application programs, create the additional windowinformation files and printer information files. For the filecreation method, refer to the FORM RTS online help.

Creating an Environment File

An environment file contains the start options of the presentationfile module test function. An environment file can be created byusing the COBPRTST dialog box or the editor.

572 Chapter 16. Distributed Development Support Functions

The following example represents a diagram of the codingformat for creating an environment file with the editor.

1. [START] -> Screen-and-form-descriptors-name ‘START’2. CBRNAME=D:\COBOL\COBOL85.CBR -> Initialization-file-name (full-path-name)3. ICONNAME=D:\ICON\TEST.DLL -> Icon-DLL-name (full-path-name)4. ICONID=1 -> Icon-resource-ID5. DSPNAME=D:\SCREEN\DSPFILE -> Window-information-file-name (full-path-name)6. ENDKEY=F001 -> Attention-value of the END-key7. RETKEY=F002 -> Attention-value of the RETURN-key

1. [section name]The section name identifies screens operating with the

presentation file module test function. Specify a screendescriptor name of the initial screen.

2. CBRNAME (COBOL initialization file name)If a COBOL application program is to be started, specify theinitialization file name (COBOL85.CBR) for COBOLexecution.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 595/783

3. ICONNAME (icon DLL name)Specify ICONNAME to change the icon of the presentationfile module test function. The full path name of the icon DLLmodule file must be specified.

4. ICONID (icon resource ID)Specify a number as an ID for the icon resource stored in theicon DLL module. The default value is 1.

5. DSPNAME (window information file name)Specify the window information file name to change theenvironment information of the screen descriptor.

6. ENDKEY (END key value)To change the END key value, specify the item literal valuespecified in the attention definition of the screen descriptor.

The default is F002 (F2 key).

7. RETKEY (RETURN key value)To change the RETURN key value, specify the item literalvalue specified in the attention definition of the screendescriptor. The default is F003 (F3 key).

Chapter 16. Distributed Development Support Functions 573

Using the Presentation File Module Test Function

A program execution method is determined by the destination ofthe presentation file.

The following are presentation file destinations:

• PRT or DSP

• ACM, APL, TRM, CMD, or WST

With destination PRT or DSP, processing can be performed onlyby the presentation file module test function. A module test canbe executed by directly starting the COBPRTST dialog box.Processing can also be done by using the COBOL85 interactivedebugger.

With the other destinations, a function specific to GS-host is

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 596/783

used. The COBOL85 interactive debugger is required to assist inprocessing. In this case, activate the COBOL85 interactivedebugger then the COBPRTST dialog box. Execute a test whilerewriting data items or record contents according to the testtypes.

The following sections explain procedures for processing usingthe presentation file module test function.

Note: When the display file unit test function is used, add thedirectory where FORM RTS is stored to the environmentalvariable PATH.

Activating the COBPRTST Dialog Box

If the presentation file is destined for PRT or DSP, activate theCOBPRTST dialog box. This section explains the procedure forusing the COBPRTST dialog box.

574 Chapter 16. Distributed Development Support Functions

 How to Activate the COBPRTST Dialog Box

Use the COBPRTST command to execute a presentation file

module test. The COBPRTST dialog box can be activated asfollows:

• Customize the COBPRTST command in thePROGRAMMING-STAFF Utility menu, and select it from thedrop-down menu to start.

 Windows 95 or Windows NT:

Execute COBPRTST.EXE.

 Windows 3.1:

• Select COBPRTST.EXE in the File Manager directory window.

• Define COBPRTST.EXE as a program icon in ProgramManager, then double-click on the icon.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 597/783

• Select the Run command from the Program Manager menu orFile Manager and enter the COBPRTST command incommand form.

Specifying an Activation Name

Specify the screen descriptor name of the initial screen in the

Invocation Name text box of the COBPRTST dialog box. See“Using the COBPRTST Dialog Box.”

Specifying an Environment File Name

Specify an environment file name in the Environment File textbox of the COBPRTST dialog box. To create a new environmentfile, specify the name of a non-existent file.

Changing Environment File Contents

To change environment file contents, specify the environment filename, then click on the Update button. The COBPRTST-Update

Chapter 16. Distributed Development Support Functions 575

dialog box is displayed. Change environment file contents. See“Using the COBPRTST-Update Dialog Box.”

Starting a Presentation File Module Test

Click on the OK button at completion of input to the COBPRTSTdialog box. The presentation file module test is executed.

Quitting a Presentation File Module Test

Click on the Cancel button.

Using the COBOL85 Interactive Debugger 

If a presentation file is used with a function specific to GS-hostand is destined for ACM, APL, TRM, CMD, or WST, theCOBOL85 interactive debugger is required to assist in

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 598/783

processing.If the file is executed without the debugger, a message isoutputted indicating host-specific functions cannot be executedunder this system. The program is forcibly terminated.

This section explains how to start processing with the COBOL85interactive debugger.

Activating the COBOL85 Interactive Debugger 

Select WINSVD from the Tools menu of the P-STAFF window.Refer to the “Fujitsu COBOL Debugging Guide” for additionaldetails.

576 Chapter 16. Distributed Development Support Functions

DebuggingOpen the Start Debugging dialog box. To use the presentationfile module test function, specify the following:

Application COBPRTST.EXEStart program SAMPLE

COBPRTST.EXE

The command to execute the presentation file module test.

SAMPLE

The program name of the DLL form which starts in thepresentation file module test.

Activating the COBPRTST Dialog Box from the COBOL85 Debugger 

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 599/783

Click on the OK button in the Start Debugging dialog box.Specify the required setup items when the COBPRTST dialog boxis displayed. See “Activating the COBPRTST Dialog Box.” Seealso “Presentation File Module Test Dialog Boxes.”

Operation Using the COBOL85 Interactive Debugger 

Specify a breakpoint with the debugger, then execute theprogram while manipulating data contents. See “Executing a GSProgram.” If a run-time message is written during execution ofthe presentation file module test function, refer to the helpinformation. (Select Help in the COBPRTST dialog box.)

COBPRTST Dialog Box

This section explains how to use the COBPRTST dialog box andCOBPRTST-Update dialog box that are used with thepresentation file module test function.

Chapter 16. Distributed Development Support Functions 577

Using the COBPRTST Dialog Box

Use the COBPRTST dialog box to specify information for apresentation file module test. The following figure shows theCOBPRTST dialog box.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 600/783

Figure 143. The COBPRTST dialog box

The COBPRTST dialog box contains the following elements:

Starting Name edit box

Specify the screen descriptor name of the initial screen.

File edit box

Specify the environment file name which enables the startoption. An environment file is created by the file namespecified here.

Browse button

Click to browse available files.

Update button

578 Chapter 16. Distributed Development Support Functions

Click to update or change information on an environmentfile. When you select this button, the COBPRTST-Update

dialog box is displayed.OK button

Click to begin the presentation file module test.

Cancel button

Click to interrupt or quit the presentation file module test.

Help button

Click to access the presentation file module test functiononline help.

Using the COBPRTST-Update Dialog Box

T h i fil i f i h COBPRTST

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 601/783

To change environment file information, use the COBPRTST-Update dialog box. To display this dialog box, click on theUpdate button in the COBPRTST dialog box. The followingfigure shows the COBPRTST-Update dialog box.

Chapter 16. Distributed Development Support Functions 579

Figure 144 The COBPRTST Update dialog box

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 602/783

Figure 144. The COBPRTST-Update dialog box

580 Chapter 16. Distributed Development Support Functions

The COBPRTST-Update dialog box contains the followingelements:

Option List

Displays the options which can be specified. Change optionsby clicking on the name of the option.

Option Contents edit box

Displays the values set for a selected option.

Browse button

Click to browse available files.

Change button

Click to change data in the Option Contents edit box for theselected option.

OK button

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 603/783

OK button

Click to change the execution environment and return to thepresentation file module test dialog.

Cancel button

Click to return to the presentation file module test dialogwithout changing the execution environment.

Help button

Click to access the presentation file module test functiononline help.

Appendix A. Compiler Options

This appendix explains the COBOL85 compiler options.

The first section lists compiler options. Review the list to verifythe compiler option to be specified, then specify the option in thecompiler option format as shown in the second section.

List of Compiler Options

This section lists compiler options. The numbers in the compileroption list correspond to the numbers of the compiler optionspecification formats in the second section.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 604/783

Options that relate to compile time resources Compiler option Number

Specifies the directory of a subschema AIMLIB 1definition file. (16)Specifies the extension of a file containing the file FILEEXT

10descriptor.Specifies the directory name of a file containing the FILELIB

11file descriptor.Specifies the extension of the screen and form FORMEXT 14descriptor file.Specifies the directory name of a file containing the FORMLIB 15screen and form descriptor.Specifies the directory name of the libraries. LIB 18

582 Appendix A. Compiler Options

Options that relate to compile listings Compiler option Number

Determines whether to output a message indicating CONF

5incompatibility between the old and new standards.Displays library text. COPY 6

Specifies the level of a diagnostic message. FLAG 12

Displays FCOM and UWA. GEN 16

Specifies the number of lines in a page of a LINECOUNT 19compiler listings.Specifies the number of characters on a line of a LINESIZE 20  

compiler listings.Determines whether to output the option MESSAGE 22information listingand compile unit statistical information listing.Specifies the sequence number area of a source NUMBER 26program.Determines whether to output compiler listings PRINT 29and specifies the output destination

of each compiler listing.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 605/783

of each compiler listing.Determines whether to output a source SOURCE 33program listing.

Options that relate to source program interpretation Compiler option Number

Determines how to treat the user-defined words of ALPHAL 2lowercase letters in the source program.Determines how to treat binary items. BINARY 3

Determines how to treat currency symbols. CURRENCY 7

Determines whether to display a message FLAGSW 13for the language elements in COBOL syntax.Specifies the ANSI COBOL standard. LANGLVL 17

Specifies a character set of national NCW 24user-defined words.Determines how to treat the national spaces NSPCOMP 25

and ANK spaces.Determines how to treat the QUOTE figurative QUOTE/APOST 30constant.Specifies the type of the reserved words. RSV 31

Selection of sign adjustment for signed SDS 32decimal items.

 Appendix A. Compiler Options 583

Specifies the type of program formats. SRF 34

Specifies the collating sequence of alphanumeric STD1 37characters.Specifies a tab interval. TAB 38

Compares the signed external decimal item with an ZWB 42alphanumeric item.

Options that relate to object program generating Compiler option Number

Specifies a method of calling the specified DLOAD 8subprogram with the CALL "literal".

Specifies a COBOL source program as a main MAIN 21program or subprogram.Specifies operation with the ACCEPT statement. MODE 23

Determines whether to output the object programs. OBJECT 27

Determines whether to create a globally optimized OPTIMIZE 28object programs.

Options that relate to run-time control Compiler option Number

Specifies a method of processing data having EQUALS 9  

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 606/783

p p g g Qthe same keyin the SORT statement.Selection of column truncation. TRUNC 41

Options that relate to run-time resources Compiler option Number

Specifies the input destination of data specified SSIN

35in the ACCEPT statement.Specifies the output destination of data specified in SSOUT 36the DISPLAY statement.

Options that relate to debugging function Compiler option Number

Determines whether to use the CHECK function. CHECK 4

Determines whether to use the interactive debugger. TEST 39  

Determines whether to use the TRACE function. TRACE 40

584 Appendix A. Compiler Options

Compiler Option Specification FormatsThis section explains the compiler option specification formats.

The compiler options are listed in alphabetical order.

There are three methods of specifying a compiler option:

1. Using the Compiler Options dialog box2. Using the -WC command option

3. Using the compiler directing statement (@OPTIONS) in thesource program. (Priority: 3-2-1)

If a compiler option is specified in the compiler directingstatement of the source program, some separately compiled

programs may not be specified depending on the specification of

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 607/783

p g y p p g pthe compiler option.

Symbols shown with compiler option specification formats are:

• WINCOB

The compiler option can be specified on the WINCOBcompiler option specification screen (option file).

• -WC

The compiler option can be specified in the -WC commandoption.

• @

The compiler option can be specified in the compiler directingstatement.

• (F)

The compiler option can be specified if the directory name isomitted.

 Appendix A. Compiler Options 585

Specify the absolute path name or relative path name for adirectory name and file name. If a relative path name is specified,

the directory name of the source file to be compiled is prefixed.When compiling from WINCOB, the source file to be compiledwill be stored in the current directory.

The compiler options that specify a directory name cannot bespecified in the -WC command option.

1 (16) WINCOB

AIMLIB(directory-name[;directory-name])

Specify the directory of the subschema definition file that isspecified in the SUBSCHEMA-NAME paragraph.

If a subschema definition file exists in more than one directory,specify the directory names separating them by a semicolon. Thedirectories are searched for in the order they were specified.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 608/783

y p

If the option is specified in duplicate, the directory searchsequence is as follows:

1. Directories specified in the -A option

2. Directories specified in the compiler option AIMLIB

2 WINCOB,-WC,@

ALPHAL

NOALPHAL

Specify ALPHAL to treat user-defined words with lowercase

letters in the source program as uppercase letters. Otherwise,specify NOALPHAL.

ALPHAL treats character constants as follows:

586 Appendix A. Compiler Options

Program name constant: Uppercase and lowercase letters aretreated as uppercase letters.

Constants other than program name: Constants are treated aswritten.

The constant specified for a program called by a statement isincluded as written in the program name constant.

3 WINCOB,-WC,@

 WORD[, MLBON ]

BINARY( MLBOFF ) BYTE

BINARY(WORD) assigns the elementary item of binary data toan area length of 2, 4, or 8 words; BINARY(BYTE) assigns the

elementary item of binary data to an area length of 1 to 8 bytes.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 609/783

The area length is determined by the number of PIC digits. Howto treat the high order end bit of an unsigned binary item canalso be specified.

• BINARY(WORD,MLBON): The high order end bit is treatedas a sign.

• BINARY(WORD,MLBOFF): The high order end bit is treatedas a numeric value.

If BINARY(BYTE) is specified, the high order end bit is treated asa numeric value.

The following table shows the relationship between the numberof declared digits and the area length.

 Appendix A. Compiler Options 587

Table 64. Length of Assigned Area from Number of PIC Digits

Number of PIC Digits Assigned Area Length

Signed Unsigned BINARY(BYTE) BINARY(WORD)1 - 2 1 - 2 1 23 - 4 3 - 4 2 25 - 6 5 - 7 3 47 - 9 8 - 9 4 4

10 - 11 10 - 12 5 812 - 14 13 - 14 6 815 - 16 15 - 16 7 8

17 - 18 17 - 18 8 8

4 WINCOB,-WC,@

CHECK[(n)]

NOCHECK

To use the CHECK function specify CHECK; otherwise specify

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 610/783

To use the CHECK function, specify CHECK; otherwise, specifyNOCHECK.

n indicates the number of times a message is displayed. Specify nwith an integer 0 to 999,999. The default value is 1.

While the CHECK function is in use, program processing

continues until a message is displayed up to n times. However,the program may fail to operate as expected if an error occurs(for example, area destruction). If 0 is specified for n, programprocessing continues regardless of the number of times amessage is displayed.

If CHECK is specified, the above check processing isincorporated into the object program. Consequently, execution

performance is decreased. When the debugging functionterminates, specify NOCHECK, then recompile the program.

Refer to “Using the CHECK Function” in the “Fujitsu COBOLDebugging Guide” for more information.

588 Appendix A. Compiler Options

5 WINCOB,-WC,@

  68

CONF( [ 74 ] )

  OBS

NOCONF

Specify CONF to indicate incompatibility between the old andnew COBOL standards; otherwise, specify NOCONF. If CONF isspecified, an incompatible item is indicated by I-level diagnosticmessages.

• CONF(68): Indicate items that is interpreted differently

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 611/783

between '68 ANSI COBOL and '85 ANSI COBOL.

• CONF(74): Indicate items that is interpreted differentlybetween '74 ANSI COBOL and '85 ANSI COBOL.

• CONF(OBS): Indicates obsolete language elements and

functions.The compiler options CONF(68) and CONF(74) are effective onlyif the compiler option LANGLVL(85) is specified.

CONF is effective when a program created according to theexisting standard is changed to '85 ANSI COBOL.

 Appendix A. Compiler Options 589

6 WINCOB,-WC,@

COPY

NOCOPY

To display library text incorporated by the COPY statement inthe source program listing, specify COPY; otherwise, specify

NOCOPY.COPY is only effective when the compiler option SOURCE isspecified.

7 WINCOB,-WC,@

  $

CURRENCY( )currency-symbol

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 612/783

  currency-symbol

Specify CURRENCY($) to use $ for a character used as a currencysymbol; specify CURRENCY(currency-symbol) to use anothersymbol. If CURRENCY(currency-symbol) is specified, refer to the

CURRENCY SIGN clause explained in the “COBOL85 ReferenceManual” for the currency symbols that can be used.

8 WINCOB,-WC,@

DLOAD

NODLOADTo dynamically call the subprogram specified with the CALL"literal", specify DLOAD; otherwise, specify NODLOAD.

Refer to “Linkage Types and Program Structure” in Chapter 4.

590 Appendix A. Compiler Options

9 WINCOB,-WC,@

EQUALS

NOEQUALS

If records having the same key are input by a SORT statement,specify EQUALS to ensure that the record sequential at output of

the SORT statement is identical to the record sequential atinputted. Otherwise, specify NOEQUALS.

If NOEQUALS is specified, the sequence of records having thesame key is not defined when the SORT statement outputsrecords.

If EQUALS is specified, special processing to ensure the input

sequence is done sorting operation. Consequently, executionperformance decreases.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 613/783

10 WINCOB

FILEEXT(extension)

Specify the extension of a file containing the file descriptor. Any

character string can be specified as the extension. If a file namehas no extension, specify character string "None" as theextension. Do not specify more than one extension.

The following is the priority if the option is specified in duplicate:

1. Compiler option FILEEXT

2. FFD_SUFFIX environment variable (32)3. Default value (FFD)

 Appendix A. Compiler Options 591

11 WINCOB

FILELIB(directory-name[;directory-name]...)

If the COPY statement with IN/OF XFDLIB specified is used tofetch a record descriptor from a file descriptor, specify thedirectory of the file containing the file descriptor.

If a file containing the file descriptor exists in more than one

directory, specify the directory names separated by a semicolon.The directories are searched for in the order specified.

Specify directory-name + file-descriptor-name within 79 bytes.(16)

Specify directory-name + file-descriptor-name within 126 bytes.(32)

If the option is specified in duplicate, the directory searchsequence is as follows:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 614/783

1. Directories specified in the -f option

2. Directories specified in the compiler option FILELIB

3. Directories specified in the FILELIB environment variable (32)

592 Appendix A. Compiler Options

12 WINCOB,-WC,@

IFLAG( W )  E

Specify the diagnostic messages to be displayed.

• FLAG(I): Displays all diagnostic messages.

• FLAG(W): Displays diagnostic messages of only W-level orhigher.

• FLAG(E): Displays diagnostic messages of only E-level orhigher.

The diagnostic message specified in the compiler option CONF is

displayed regardless of the FLAG specification.

13 WINCOB WC @

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 615/783

13 WINCOB,-WC,@

STDM  [ STDI ] [,RPW]

 FLAGSW ( STDH )  SIA

NOFLAGSW

To display a message indicating a language construct in COBOLsyntax, specify FLAGSW; otherwise, specify NOFLAGSW.

The following are language constructs that can be indicated:

• FLAGSW(STDM): Language elements that are not in theminimum subset of the standard COBOL

 Appendix A. Compiler Options 593

• FLAGSW(STDI): Language elements that are not in theintermediate subset of the standard COBOL

• FLAGSW(STDH): Language elements that are not in the highsubset of the standard COBOL

• FLAGSW(RPW): Language elements of the report writerfunction of the standard COBOL

• FLAGSW(SIA): Language elements that are not in the rangeof Fujitsu System Integrated Architecture (SIA)

Use FLAGSW(SIA) to create a program that will operate underanother system.

14 WINCOB

FORMEXT(extent)

Specify the extent of the screen and form descriptor file. Anycharacter string can be specified as the extent. If a file name has

t t if h t t i "N " th t t D t

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 616/783

no extent, specify character string "None" as the extent. Do notspecify more than one extent.

The following is the priority if the option is specified in duplicate:

1. Compiler option FORMEXT

2. SMED_SUFFIX environment variable (32)

3. Default value (PMD)

594 Appendix A. Compiler Options

15 WINCOB

FORMLIB(directory-name[;directory-name]...)

If the COPY statement with IN/OF XMDLIB specified is used tofetch a record definition from the screen and form descriptor,specify the directory of the screen and form descriptor file.If the screen and form descriptor files exist in more than onedirectory, specify the directory names separated by a semicolon.

The directories are searched for in the order specified.Specify directory-name + screen-and-form-descriptor-namewithin 79 bytes. (16)

Specify directory-name + screen-and-form-descriptor-namewithin 126 bytes. (32)

If the option is specified in duplicate, the directory search

sequence is as follows:1. Directories specified in the -m option

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 617/783

p p

2. Directories specified in the compiler option FORMLIB

3. Directories specified in the FORMLIB environment variable(32)

16 WINCOB,-WC,@

GEN

NOGEN

Specify GEN to display the communication area with AIM DBMS(FCOM) and the AIM expansion record area (UWA) in the sourceprogram listing. Otherwise, specify NOGEN.

 Appendix A. Compiler Options 595

17 WINCOB,-WC,@

  85LANGLVL ( 74 )

  68

Specify a standard for an item where source programinterpretation is different between the old and new COBOL

standards.• LANGLVL(85): '85 ANSI COBOL

• LANGLVL(74): '74 ANSI COBOL

• LANGLVL(68): '68 ANSI COBOL

18 WINCOB

LIB(directory-name[;directory-name]...)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 618/783

( y [; y ] )

If the source text manipulation function (COPY statement) isused, specify the directory of libraries. If libraries exist in morethan one directory, specify the directory names separated by asemicolon. The directories are searched for in the order specified.

The following is the priority if the option is specified in duplicate:

1. -I option

2. Compiler option LIB

596 Appendix A. Compiler Options

19 WINCOB,-WC,@

LINECOUNT(n)

Specify the number of lines in a page of a compiler listing. n canbe specified with an integer of up to 3 digits. The default value is60.

If a value 0 to 12 is specified, display without editing.

20 WINCOB,-WC,@

LINESIZE(n)

Specify the maximum number of characters (value resulting fromconversion of alphanumeric characters displayed in the list) for a

line in a compiler listing. Value can be specified with 80, or a 3-digit integer more than 120. The default value is 136.

The source program list option information list and diagnosis

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 619/783

The source program list, option information list, and diagnosismessage list are output with a fixed number (120) of charactersregardless of the maximum number of characters specified inLINESIZE.

The permitted maximum number of characters is 136. If a valuegreater than 136 is specified in LINESIZE, 136 is used.

21 WINCOB,-WC,@

MAIN

NOMAIN

Specify MAIN to use a COBOL source program as a mainprogram; specify NOMAIN to use a COBOL source program as asubprogram.

 Appendix A. Compiler Options 597

Specify MAIN for the COBOL source program to be used as amain program. If compiling the COBOL programs by

Continuous Compilation mode or in a project, click on the MainProgram button.

22 WINCOB,-WC,@

MESSAGE

NOMESSAGE

To output an option information listing and to compile unitstatistical information listing, specify MESSAGE; otherwise,specify NOMESSAGE.

23 WINCOB,-WC,@

  STDMODE ( )

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 620/783

MODE ( )  CCVS

If an ACCEPT statement where a numeric item is specified as thereceiving item in the format of "ACCEPT unique-name[FROMmnemonic-name]" is executed, specify MODE(STD) to move aright-justified numeric data to a receiving item.

Specify MODE(CCVS) to move a left-justified character string toa receiving item:

If MODE(CCVS) is specified, only an external decimal item canbe specified as a receiving item in the ACCEPT statement.

598 Appendix A. Compiler Options

24 WINCOB,-WC,@

STDNCW ( )

SYS

Specify this option for a national character set that can be definedas user-defined words. Specify NCW(STD) to use the national

character set as a national character set common to systems;specify NCW(SYS) to use the national character set as a nationalcharacter set of the computer. The following are nationalcharacter sets that can be used:

NCW(STD):

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 621/783

NCW(SYS):− Character set with STD specified

− Extended character

−  JIS Level non-kanji (1)

− Extended non-kanji

− User-defined characters

 Appendix A. Compiler Options 599

(1) The following characters cannot be used.

25 WINCOB,-WC,@

  NSPNSPCOMP( )

  ASP

Specify this option to determine how to treat a national space atcomparison. Specify NSPCOMP(NSP) to treat the national spaceas a national space; specify NSPCOMP(ASP) to treat the nationalspace as an ANK space.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 622/783

A national space treated as an ANK space is assumed to beequivalent to a 2-byte ANK space.

NSPCOMP(ASP) is effective for the following comparisons:

• National character comparison with a national item as anoperand

• Character comparison with a group item as an operand

NSPCOMP(ASP) is not effective for the following comparisons:

• Comparison between group items that do not include anynational item

• Comparison between group items including an item whoseattribute does not specify explicit or implicit display

600 Appendix A. Compiler Options

A national space is not treated as an ANK space for the followingcomparison even if the NSPCOMP(ASP) option is specified:

Character comparison and national character comparisondone by using the INSPECT, STRING, or UNSTRINGstatement or by operating the indexed file key.

If NSPCOMP(ASP) is specified, an ANK space is treated as anational space under the class condition JAPANESE.

A national space is equivalent to a 2-byte ANK space in the host

code system whereas it is not in the Windows code system. Thus,specify NSPCOMP(ASP) for a COBOL program which has beenused with a host to operate under this system.

26 WINCOB,-WC,@

NUMBER

NONUMBER

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 623/783

Specify this option to determine the value used as the linenumber in line information. The line information identifies eachline of a source program within lists generated at compile time orrun-time. Specify NUMBER to use the value of the sequence

number area of the source program; specify NONUMBER to usethe value generated by the compiler.

NUMBER: If the sequence number area includes a nonnumericcharacter or if the sequence number is not in ascending order, theline number is changed to the previously correct sequencenumber + 1.

NONUMBER: Line numbers are assigned in ascending orderstarting from 1. The increment between successive line numbersis 1.

 Appendix A. Compiler Options 601

If NUMBER is specified, a sequence number including identicalvalues consecutively is not regarded as an error.

If NUMBER is specified, the error search function cannot beused.

27 WINCOB,-WC(D)

OBJECT[(directory-name)]

NOOBJECT

Specify OBJECT to generate an object program; otherwise,specify NOOBJECT. If an object program is outputted, the file isusually created in the directory of the source program. To createthe file in another directory, specify the directory name.

Refer to “Resources Necessary for Compilation” in Chapter 3.

28 WINCOB,-WC,@

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 624/783

OPTIMIZE

NOOPTIMIZE

Specify OPTIMIZE to generate a global-optimized objectprogram; otherwise, specify NOOPTIMIZE.

If this option is specified with TEST, OPTIMIZE is displayed asthe options established. The program, however, is compiled onthe assumption that NOOPTIMIZE is specified. (No globaloptimization)

See Appendix C, “Global Optimization.”

602 Appendix A. Compiler Options

29 WINCOB

PRINT[(directory-name)]

Specify this option to generate a compiler listing. If a compilerlisting is output, the file is usually created in the directory of thesource program. To create the file in another directory, specifythe directory name.

30 WINCOB,-WC,@

QUOTE

APOST

Specify QUOTE to use quotation marks as the values of the

QUOTE and QUOTES figurative constants; specify APOST to useapostrophes as the values.

Either quotation marks or apostrophes can be used as delimiter

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 625/783

q p pof nonnumeric literal in source programs regardless of thespecification of this option. The right and left side delimitersmust be identical.

31 WINCOB,-WC,@

 ALL V111 V112

RSV ( V122 ) V125

 VSR2 VSR3

Specify the type of a reserved word. The following are the namesof reserved-word sets:

 Appendix A. Compiler Options 603

• RSV(ALL): For COBOL85 V20 or later

• RSV(V111): For GS series COBOL85 V11L11

• RSV(V112): For GS series COBOL85 V11L20

• RSV(V122): For GS series COBOL85 V12L20

• RSV(V125): For COBOL85 V12L50

• RSV(VSR2): For VS COBOL II REL2.0

RSV(VSR3): For VS COBOL II REL3.0

32 WINCOB,-WC,@

SDS

NOSDS

Specify this option to determine how to move a signed internaldecimal item to another signed internal decimal item. SpecifySDS to move the sign of the sending item as is; specify NOSDS tomove a converted sign X'B' and X'D' are treated as minus signs

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 626/783

move a converted sign. X'B' and X'D' are treated as minus signs.

The other values are treated as plus signs. A plus sign of thesending item is converted to X'C'; a minus sign of the sendingitem is converted to X'D'.

33 WINCOB,-WC,@

SOURCE

NOSOURCE

Specify SOURCE to output a source program listing; otherwise,specify NOSOURCE. If SOURCE is specified, the source programlisting is output to the directory specified in the compiler optionPRINT or the -dp option.

604 Appendix A. Compiler Options

A source program listing is generated only if this option isspecified with the compiler option PRINT or the -dp option.

34 WINCOB,-WC

  FIX  FIX

SRF( FREE [, FREE ] )

  VAR VAR

 Specify the reference formats of a COBOL source program andlibrary. Specify FIX for the fixed-length format; specify FREE forthe free format, specify VAR for the variable-length format.

Specify the reference format of COBOL source program, thenspecify that of the library. If the two reference formats are the

same, there is no need to specify the library program format.

35 WINCOB,-WC,@

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 627/783

run-time environment information nameSSIN ( )

SYSIN

Specifies the data input destination of the ACCEPT statement forACCEPT/DISPLAY function.

• SSIN(run-time environment information name): A file isused as the data input destination. At run-time, specify thepath name of the run-time environment information name.

• SSIN(SYSIN): The console window is used as the data inputdestination.

The run-time environment information name can be specifiedwith up to eight uppercase letters and numeric charactersbeginning with an uppercase letter (A to Z).

 Appendix A. Compiler Options 605

The run-time environment information name must be unique.The name must be different from a run-time environmentinformation name (file-identifier) used with another file.

Refer to “ACCEPT/DISPLAY Function” in Chapter 11.

36 WINCOB,-WC,@

  run-time environment information nameSSOUT ( )

  SYSOUT

Specifies the data output destination of the DISPLAY statementfor ACCEPT/DISPLAY function.

• SSOUT(run-time environment information name): A file isused as the data output destination. At run-time, specify the

path name of the run-time environment information name.

• SSOUT(SYSOUT): The console window is used as the dataoutput destination.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 628/783

p

The run-time environment information name can be specifiedwith up to 8 uppercase letters and numeric characters beginningwith an uppercase letter (A to Z).

The run-time environment information name must be unique.The name must be different from a run-time environmentinformation name (file-identifier) used with another file.

Refer to “ACCEPT/DISPLAY Function” in Chapter 11.

606 Appendix A. Compiler Options

37 WINCOB,-WC,@

  ASCIISTD1 ( JIS1 )

  JIS2

To determine how to treat an alphanumeric code (standard codeof a 1 byte characters) specified for EBCDIC in the ALPHABETclause, specify this option.

Specify ASCII to treat the alphanumeric code as an ASCII code;specify JIS1 to treat it as a JIS 8-bit code; specify JIS2 to treat it asa JIS 7-bit Roman character code.

EBCDIC is specified in the ALPHABET clause, the character codesystem used depends on the specification of this option.

• STD1(ASCII): EBCDIC (ASCII)• STD1(JIS1) : EBCDIC (kana)

• STD1(JIS2) : EBCDIC (lowercase letters)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 629/783

STD1(JIS2) : EBCDIC (lowercase letters)

38 WINCOB,-WC

  8TAB ( )

  4

Specifies whether tabs are to be set in units of 4 columns (TAB(4))or 8 columns (TAB(8) ).

 Appendix A. Compiler Options 607

39 WINCOB,-WC(D),@(D)

TEST[(directory-name)]

NOTEST

To use a debugger, specify TEST; otherwise, specify NOTEST. IfTEST is specified, the debugging information file used with thedebugger is created in the directory of the source program. Tocreate the file in another directory, specify the directory name.

If this option is specified with OPTIMIZE, OPTIMIZE isdisplayed as the options established. The program, however, iscompiled on the assumption that NOOPTIMIZE is specified (noglobal optimization).

Refer to “Resources Necessary for Compilation” in Chapter 3,

and the “Fujitsu COBOL Debugging Guide”.

40 WINCOB,-WC,@

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 630/783

TRACE[(n)]

NOTRACE

To use the TRACE function, specify TRACE; otherwise, specifyNOTRACE.

n indicates the number of the trace information items to beoutput. Specify n with an integer 1 to 999,999. The default valueis 200.

If TRACE is specified, processing for displaying traceinformation is incorporated into the object program.Consequently, execution performance decreases. When the

608 Appendix A. Compiler Options

debugging function terminates, specify NOTRACE, thenrecompile the program.

Refer to “Using the TRACE Function” in the “Fujitsu COBOLDebugging Guide”.

41 WINCOB,-WC,@

TRUNC

NOTRUNC

Specify a method of truncating high-order digits when a numberis moved with a binary item as a receiving item.

• TRUNC: The high-order digits of the result value aretruncated according to the specification of the PICTUREclause of the receiving item. The result value after truncationis stored in the receiving item.

If this option is specified with the compiler optionOPTIMIZE, the high-order digits of a variable moved from an

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 631/783

OPTIMIZE, the high order digits of a variable moved from anexternal decimal item or internal decimal item throughoptimization are also truncated. Digits are truncated asexplained above only if the number of digits in the integer

part of the sending item is greater than that of the receivingitem.

• NOTRUNC: The execution speed of the object program is oftop priority. If the execution is faster without truncation thanwith truncation, digits are not truncated.

For example, specification in the PICTURE clause:

• Moving S999VP (3 digits in the integer part) to S99V99 (2digits in the integer part): Truncation

• Moving SPV999 (0 digit in the integer part) to S99V99 (2digits in the integer part): No truncation

 Appendix A. Compiler Options 609

If TRUNC is specified, the value to be set into the integer area ofthe sending item depends on the hardware.

If NOTRUNC is specified, the program must be designed so thata digit count exceeding the digit count specified in the PICTUREclause is not stored in the receiving item even when no digit istruncated.

If NOTRUNC is specified, whether to truncate digits depends onthe compiler. Thus, a program with no truncation is used byspecifying NOTRUNC may be incompatible with another

system.

42 WINCOB,-WC,@

ZWB

NOZWB

Specify this option to determine how to treat a sign part when asigned external decimal item is compared with an alphanumericfield.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 632/783

Specify ZWB for comparison ignoring the sign part of theexternal decimal item; specify NOZWB for comparison includingthe sign part.

Alphanumeric characters include alphanumeric data items,alphabetic data items, alphanumeric edited data items, numericedited items, nonnumeric literals, and figurative constants otherthan ZERO.

For example:

• 77 ED PIC S9(3) VALUE +123.

• 77 AN PIC X(3) VALUE "123".

610 Appendix A. Compiler Options

The conditional expression ED = AN is defined as shown belowin this example:

• With ZWB specified: True

• With NOZWB specified: False

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 633/783

Appendix B. I-O Status List

This appendix lists the meanings of the values (status values) setwhen input-output statements are executed. The values are set ina data name specified in the FILE STATUS clause of the filecontrol entry when input-output statements are executed.

Table 65. I-O Status List

Classification I-OStatusValue

DetailedInformation

Meaning 

Successful 00 -- Input-output statements were executedsuccessfully.

02 -- The status is one of the following:- The value of the reference key of the recordread by executing the READ statement is thesame as that of the next record.- The record having the same record key valueas the record written by executing the WRITEor REWRITE statement already exists in a file.This is not an error however because a record

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 634/783

This is not an error, however, because a recordkey value may be duplicated.

612 Appendix B. I-O Status List

Table 65. I-O Status List (cont.)

Classification I-O

StatusValue

Detailed

Information

Meaning 

  Successful 04 -- The length of an input record is greater than themaximum record.

 FORM RTS One of the following status occurred in thepresentation file.- An input error occurred in required full-fieldinput items or required input items.- The data error occurred. (A national language

data error, an ANK data error, a numeric itemconfiguration data error, a numeric item signerror, a numeric item decimal point error, aredundancy check error)- Data entered in the data item is invalid.

 ACM The input message is longer than the specifiedmaximum record.

05 -- One of the following status occurred in the filewhere the OPTIONAL clause is specified.- The OPEN statement in INPUT, I-O, orEXTEND mode was executed for a file, but thefile has yet to be created.

The OPEN statement in INPUT mode was

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 635/783

- The OPEN statement in INPUT mode wasexecuted for a nonexistent file. In this case, thefile is not created and at end condition occurs(input-output status value = 10) during

execution of the first READ statement.- The OPEN statement in I-O or EXTEND modewas executed for a nonexistent file. In this case,the file is created.

07 -- Input-output statements were successfullyexecuted, however, the file referenced by one ofthe following methods exists in a non-reel orunit medium.- OPEN statement or CLOSE statement with

  NO REWIND specified- CLOSE statement with REEL/UNIT specified

0A ACM There was no message to be input to thespecified logical destination.

 Appendix B. I-O Status List 613

Table 65. I-O Status List (cont.)

Classification I-O

StatusValue

Detailed

Information

Meaning 

Successful 0B ACM The number of output messages exceeds themaximum number of messages stored at thespecified logical destination.

AT ENDcondition

10 -- AT END condition occurred in a sequentiallyaccessed READ statement.- File end reached.- The first READ statement was executed for a

non-existent optional input file.- That is, a file with the OPTIONAL clausespecified was opened in INPUT mode but thefile was not created.

14 AT END condition occurred in a sequentiallyaccessed READ statement.- The valid digits of a read relative recordnumber are greater than the size of the relativekey item of the file.

Invalid keycondition

21 -- Record key order is invalid.One of the following status occurred. - During sequential access, the prime recordkey value was changed between the READ

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 636/783

key value was changed between the READstatement and subsequent REWRITE statement.- During random access or dynamic access of afile with DUPLICATES specified as the prime

key, the prime record key value was changedbetween the READ statement and subsequentREWRITE or DELETE statement.- During sequential access, prime record keyvalues are not in ascending order at WRITEstatement execution.

22 -- During WRITE or REWRITE statementexecution, the value of prime record key, oralternate record key to be written already exist

in a file. However, DUPLICATES is specified inthe prime record key or alternate record key.

614 Appendix B. I-O Status List

Table 65. I-O Status List (cont.)

Classification I-O

StatusValue

Detailed

Information

Meaning 

Invalid KeyCondition

23 -- The record was not found. - During START statement or random accessREAD, REWRITE, or DELETE statementexecution, the record having the specified keyvalue does not exist in the file.- Relative record number 0 was specified for arelative file.

24 -- One of the following status occurred.- Area shortage occurred during WRITEstatement execution.- During WRITE statement execution, thespecified key is out of the key range.- After overflow writing, an attempt was madeto execute the WRITE statement again.

Permanenterror condition

30 -- A physical error occurred.

ACM ACM detected error.34 -- Area shortage occurred during WRITE

statement execution.35 The OPEN statement in INPUT, I-O, or

EXTEND mode was executed for a file without

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 637/783

EXTEND mode was executed for a file withoutthe OPTIONAL clause specification. The file hasyet to be created, however.

37 -- The specified function is not supported.

38 The OPEN statement was executed for a file forwhich CLOSE LOCK was executed before.

Logical errorcondition

39 -- During OPEN statement execution, a file whoseattribute conflicts with the one specified in theprogram was assigned.

41 -- The OPEN statement was executed for anopened file.

42 -- The CLOSE statement was executed for anunopened file.

 Appendix B. I-O Status List 615

Table 65. I-O Status List (cont.)

Classification I-O

StatusValue

Detailed

Information

Meaning 

Logical ErrorCondition

43 -- During sequential access or DELETE orREWRITE statement execution for a file withDUPLICATES specified as the prime key, thepreceding input-output statement was not asuccessful READ statement.

44 -- One of the following status occurred.- The record length during WRITE or

REWRITE statement execution is greater thanthe maximum record length specified in theprogram. Or, an invalid numeric wasspecified as the record length.- During REWRITE statement execution, therecord length is not equal to that of the recordto be rewritten.

46 -- During sequential call READ statementexecution, the file position indicator isundefined due to one of the following reasons.- The preceding START statement isunsuccessful.- The preceding READ statement isunsuccessful (including at end condition).

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 638/783

47 -- The READ or START statement was executedfor a file not opened in INPUT or I-O mode.

48 -- The WRITE statement was executed for a file

not opened in OUTPUT, EXTEND (sequential,relative, or indexed), or I-O (relative orindexed) mode.

49 -- The REWRITE or DELETE statement wasexecuted for a file not opened in I-O mode.

616 Appendix B. I-O Status List

Table 65. I-O Status List (cont.)

Classification I-O

StatusValue

Detailed

Information

Meaning 

Other errors 90 -- These errors are other than those previouslyclassified. The following conditions areassumed.1) File information is incomplete or invalid.2) During OPEN or CLOSE statementexecution, an error occurred in a OPEN orCLOSE function.

3) An attempt was made to execute an input-output statement for a file where the CLOSEstatement was unsuccessful due to input-output status value 90.4) Resources such as main storage areunavailable.5) An attempt was made to execute the OPENstatement for a file not closed correctly.6) An attempt was made to write records after

an error occurred due to overflow writing.7) An attempt was made to write records after ano-space condition occurred.8) An invalid character is contained in a text filerecord.9) S h t t b i t t d f

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 639/783

9) Some characters cannot be interpreted from anative code to the code set.10) The lock table is full.11) An error other than the above occurred.This is the only information about input-outputoperations where the error occurred.12) A system error occurred.

 FORM RTS FORM RTS detected an error. ACM ACM detected an error.

91 -- - No file is assigned.- At OPEN statement execution, a fileidentification does not correspond to a physical

file name.92 -- An exclusive error occurred. (RDM file)93 -- An exclusive error occurred. (File lock)

 Appendix B. I-O Status List 617

Table 65. I-O Status List (cont.)

Classification I-O

StatusValue

Detailed

Information

Meaning 

Other Errors 99 -- An exclusive error occurred. (Record lock)ACM A system error occurred.

9B ACM A destination error occurred.9E FORM RTS The execution waiting by the READ statement

was compulsorily released.9F ACM - A monitoring time error occurred.

- A destination error stopped processing.

9G ACM The number of messages at the logicaldestination exceeds the specified maximum.

9H ACM A file area or storage became insufficient at thelogical destination.

'FORM RTS' in the Detail code column means a FORM RTS errorcode. For details, refer to the FORM RTS online help.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 640/783

618 Appendix B. I-O Status List

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 641/783

Appendix C. Global

OptimizationThis appendix explains the global optimization performed by theCOBOL85 compiler.

Optimization

Global optimization divides the procedure division into sets ofstatements (called basic blocks), each consisting of one entry, oneexit, and statements executable in physical sequence between theentry and the exit. Control flow and data use status are then

analyzed, mainly in connection with loops (program parts toexecute repeatedly).

Specifically, the following operations occur during globaloptimization:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 642/783

• Removing common expressions

• Shifting an invariant

• Optimizing induction variables

• Optimizing PERFORM statements

• Integrating adjacent moves

• Eliminating unnecessary substitutions

620 Appendix C. Global Optimization

Removing a Common Expression

For arithmetic or conversion processing, if possible, the previousresults are reserved and used without additional execution ofarithmetic or conversion processing.

Example 1:

77 I PIC S99 BINARY.77 J PIC S99 BINARY.

77 K PIC S99 BINARY.01 REC-102 A0 OCCURS 25 TIMES.

03 A PIC XX OCCURS 10 TIMES.02 B0 OCCURS 35 TIMES.

03 B PIC XX OCCURS 10 TIMES.:

MOVE SPACE TO A (I,J). ... (1)

:MOVE SPACE TO B (I,K). ... (2)

If I does not change in value between (1) and (2) in Example 1,the address calculation formula for A(I,J) "A - 22 + I * 20 + J * 2"and the address calculation formula for B(I,K) "B - 22 + I * 20 + K* 2" will have "I * 20" in common.

Th f COBOL ti i th l tt t th lt f th

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 643/783

Therefore, COBOL optimizes the latter to use the result of theformer. A is assumed to indicate the address A(1,1) here.

 Appendix C. Global Optimization 621

Example 2:

77 Z1 PIC S9(9) DISPLAY.77 Z2 PIC S9(9) DISPLAY.

77 B1 PIC S9(4) BINARY.77 B2 PIC S9(4) BINARY.  :  COMPUTE Z1 = B1 * B2. ... (1)

  :  COMPUTE Z2 = B1 * B2. ... (2)

In Example 2, B1 and B2 remain unchanged between (1) and (2),B1 * B2 becomes common and (2) is optimized so it uses results

of (1).

Shifting an Invariant

For arithmetic or conversion processing done within a loop, theprocessing can be performed outside the loop if the same results

would be obtained regardless of whether the processing is donewithin or outside the loop.

Example 1:

77 I PIC S9(4) BINARY.77 ZD PIC S9(7) DISPLAY.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 644/783

01 REC-1.  02 B1 PIC S9(7) BINARY OCCURS 20 TIMES.  :

  MOVE 1 TO I.LOOP-1 }  IF B1(I) = ZD GO TO EXIT-1. }  : } Loop  ADD 1 TO I. }  IF I IS <= 20 GO TO LOOP-1. }

If ZD never changes throughout the loop in Example 1, thecompiler shifts ZD-to-Binary conversion processing by the IFstatement to the outside of the loop.

622 Appendix C. Global Optimization

Optimizing an Induction Variable

If the compiler finds a loop containing a partial expression thatuses an item (induction item) defined recursively only by aconstant (as in ADD 1 TO I., for example) or by an item with anunchanging value, it introduces a new induction variable andchanges the multiplication of the subscript calculation formula toan addition.

Example 1:

77 I PIC S9(4) BINARY.01 REC-1.  02 A PIC X(10) OCCURS 20 TIMES.  :LOOP-1. }  IF A(I) = ... ...(1) }  : } Loop  ADD 1 TO I. ...(2) }  IF I IS <= 20 GO TO LOOP-1. ...(3) }

Because I is defined recursively by a constant within the loop inExample 1, the compiler introduces a new induction variable toreplace the multiplication "I * 10" in the address calculationformula for A(I) "A - 10 + I * 10" with “t”, and generates "ADD 10

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 645/783

( ) gTO t" after (2).

Furthermore, if I is not used anywhere else in the loop and,concurrently, the value of I calculated inside the loop is not usedafter control exits from the loop, the compiler replaces (3) with"IF t IS <= 20 GO TO LOOP-1" and deletes (2).

Optimizing a PERFORM Statement

The compiler expands the PERFORM statement into someinstructions for saving, setting and restoring the return addressfor the return mechanism. The exit of the PERFORM statementtransfers control to the other statement, generally. Otherwise,

 Appendix C. Global Optimization 623

some of the machine instructions for the return mechanism turnout to be redundant.

The compiler then removes these redundant machineinstructions.

Integrating Adjacent Moves

If different alphanumeric move statements transfer data fromcontiguous items to identically contiguous items, the compiler

integrates these move statements into one.

Example 1:

02 A1 PIC X(32).02 A2 PIC X(16).

  :02 B1 PIC X(32).02 B2 PIC X(16).  :

MOVE A1 TO B1. ...(1)  :MOVE A2 TO B2. ...(2)

If A2 and B2 do not change between (1) and (2) and,concurrently, B2 is not referenced in Example 1, the compilerdeletes MOVE statement (2) Then MOVE statement (1) sets A1

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 646/783

deletes MOVE statement (2). Then MOVE statement (1) sets A1and A2, and B1 and B2, as one area, respectively, to perform a

move.

Eliminating Unnecessary Substitutions

Substitutions are eliminated for data items that are not going tobe either implicitly or explicitly referenced.

624 Appendix C. Global Optimization

Notes

If the compiler option OPTIMIZE is specified, the compilergenerates a globally optimized object program. For details, referto Appendix A, “Compiler Options.”

Notes on Global Optimization

The following explains notes on global optimization:

• Use of the linkage function

Some parameters for a called program share all or part of astorage area (for example, CALL "SUBPROG" USING A, A.or CALL "SUBPROG" USING A, B. where A and B share part

of the area).If the content of the area is overwritten by the calledprogram, the optimization of the called program may notlead to the expected result. So, do not specify the compileroption OPTIMIZE for such a program.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 647/783

• No execution of the global optimization

The compiler does not perform global optimization on thefollowing programs:

− Programs that do not define the items and index nameshaving the attributes to target by global optimization

− Programs using the segmentation function (segmentationmodule)

− Programs specifying a compiler option TEST

• Less effective global optimization

 Appendix C. Global Optimization 625

Global optimization is less effective on the followingprograms:

− Programs mainly performing I/O operations, andprograms that usually do not use the CPU

− Program using no numeric items but only alphanumericitems

− Programs referencing nondeclaratives from declaratives

− Programs referencing declaratives from nondeclaratives

− Programs specifying the compiler option TRUNC. Fordetails, refer to Appendix A, “Compiler Options.”

Notes on Debugging

Since global optimization causes the deletion, shifting and

modification of one or more statements, a program interruption(for example, data exception) can occur a different number oftimes or at a different location.

If the program is interrupted while data items are begin writtenin, those data items may not actually be set.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 648/783

With compiler option NOTRUNC, the program may not operateproperly if the internal or external decimal item is to berecursively defined. For details, refer to Appendix A, “CompilerOptions.”

626 Appendix C. Global Optimization

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 649/783

Appendix D. Intrinsic Function

ListThe following table lists the Intrinsic functions that can be usedwith COBOL85.

Table 66. COBOL85 Intrinsic Functions

Classification Function ExplanationLength LENGTH Obtains the length of a data item or

literal.Size MAX Obtains the maximum value.

MIN Obtains the minimum value.ORD-MAX Obtains the ordinal position of the

maximum value.ORD-MIN Obtains the ordinal position of the

minimum value.Conversion REVERSE Reverses the order of character

strings.LOWER-CASE Converts uppercase characters to

lowercase characters.UPPER-CASE Converts lowercase characters to

uppercase characters.NUMVAL C t i h t t

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 650/783

NUMVAL Converts numeric characters tonumeric values.

NUMVAL-C Converts numeric charactersincluding a comma and currencysign to numeric values.

628 Appendix D. Intrinsic Function List

Table 66. COBOL85 Intrinsic Functions (cont.)

Classification Function ExplanationCharacteroperation

CHAR Obtains a character at a specifiedposition in the collating sequence of aprogram.

ORD Obtains the ordinal position of aspecified character in the collatingsequence of a program.

Numeric valueoperation

INTEGER Obtains the maximum integerwithin a specified range.

INTEGER-PART Obtains integer parts.

RANDOM Obtains random numbers.Calculation ofinterest rate

ANNUITY Obtains the approximate value ofthe equal payment rate to 1 (theprincipal) according to the rate ofinterest and the period.

PRESENT-VALUE Obtains the current price accordingto the reduction rate.

Date operation CURRENT-DATE Obtains the current date and timeand the difference betweenGreenwich Mean Time.

DATE-OF-INTEGER Obtains the date corresponding tothe day of the year.

DAY-OF-INTEGER Obtains the year and daycorresponding to the day of theyear.

INTEGER-OF-DATE Obtains the day of the year

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 651/783

INTEGER-OF-DATE Obtains the day of the yearcorresponding to the date.

INTEGER-OF-DAY Obtains the day of the yearcorresponding to the year andday.

WHEN-COMPILED Obtains the date and time theprogram was compiled.

 Appendix D. Intrinsic Function List 629

Table 66. COBOL85 Intrinsic Functions (cont.)

Classification Function ExplanationArithmeticcalculation

SQRT Obtains the approximate value of asquare root.

FACTORIAL Obtains factorials.LOG Obtains natural logarithms.LOG10 Obtains common logarithms.MEAN Obtains average values.MEDIAN Obtains medians.MIDRANGE Obtains the average values of the

maximum and minimum.

RANGE Obtains the difference between themaximum and minimum.

STANDARD-DEVIATION Obtains standard deviations.MOD Obtains a specified value in

specified modulus.REM Obtains remainders.SUM Obtains sums.VARIANCE Obtains variances.

Trigonometricfunction SIN Obtains the approximate value of asine.COS Obtains the approximate value of a

cosine.TAN Obtains the approximate value of a

tangent.ASIN Obtains the approximate value of

i i

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 652/783

an inverse sine.ACOS Obtains the approximate value of

an inverse cosine.ATAN Obtains the approximate value of

an inverse tangent.

630 Appendix D. Intrinsic Function List

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 653/783

Appendix E. Special Registers

Used with Screen and FormFunctions

This appendix explains the values of special registers used withscreen and form functions. Some functions cannot be used

depending on the FORM RTS version and level. For details, referto the FORM RTS online help.

EDIT-MODE

Before execution of the WRITE statement, the output mode of a

data item can be specified for the EDIT-MODE special register.The following table explains the values that can be specified.

Table 67. Values that can be specified for EDIT-MODE

Value Explanation Value Explanation" "(Blank)

Applies output processing. "*" Expands and edits characters.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 654/783

( )"X" Does not apply output

processing.

"K" Does not output the initial

value."N" Outputs the data as national

data. (National data items only)"B" Outputs bit map data.

"A" Outputs the data asalphanumeric data. (Nationaldata items only)

"O" Outputs OLE objects.

632 Appendix E. Special Registers Used with Presentation File Function

EDIT-STATUS

Before execution of the READ statement, the input mode of adata item can be specified for the EDIT-STATUS special register.The input results are posted after execution of the READstatement. The following table explains the values that can bespecified.

Table 68. Values that can be specified for EDIT-STATUS

Value Explanation Value Explanation" "(Blank)

Applies input processing. "S" Enables selection status display.

"X" Does not apply input processing. "D" Does not apply input processingand enables selection statusdisplay.

"B" Disables the specification forinput highlighting.

The following table explains the return values.

Table 69. Values returned to EDIT-STATUS

Value Explanation Value Explanation"E" The input data contains an error. "S" The item has been selected.

(Only when an item is selectedfor input)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 655/783

for input)"Z" Input was omitted for an item. "I" The item was entered through

the ID card." "(Blank)

The data was inputted asnational data. (National dataitems only)

"U" The data was not changed.

"A" The data was inputted asalphanumeric data. (Nationaldata items only)

Appendix E. Special Registers Used with Presentation File Function 633

EDIT-COLOR

Before execution of the WRITE statement, the display color of adata item can be specified for the EDIT-COLOR special register.The following table explains the values that can be specified.

Table 70. Values that can be specified for EDIT-COLOR

Value Explanation Value Explanation" "

(Blank)

Does not change the previous

information.

"O" Outputs data in dark gray.

"M" Outputs data according to thecolor attribute of the screendescriptor.

"K" Outputs data in dark blue.

"N" Outputs data in non-displaymode.

"F" Outputs data in dark red.

"B" Outputs data in blue. "J" Outputs data in dark pink."R" Outputs data in red. "I" Outputs data in dark turquoise.

"P" Outputs data in pink. "C" Outputs data in dark yellow."G" Outputs data in green. "E" Outputs data in dark green."T" Outputs data in turquoise. "D" Outputs data in gray."Y" Outputs data in yellow. "W" Outputs data in white."A" Outputs data in black. "H" Outputs data with high

brightness. (*1)"L" Outputs data with low

brightness. (*1)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 656/783

g ( )*1 High brightness cannot be distinguished from low brightness under this system.

EDIT-OPTION

Before execution of the WRITE statement, attributes of a dataitem can be specified for the EDIT-OPTION special register. Thefollowing table explains the values that can be specified.

634 Appendix E. Special Registers Used with Presentation File Function

Table 71. Values that can be specified for EDIT-OPTION

Value Explanation Value Explanation" "

(Blank)

Does not change the previous

information.

"D" Outputs data without using

any underline, blink, or reverse."M" Outputs data according to the

item attribute of the screendescriptor.

"V" Outputs data using blink andreverse. (*1)

"U" Outputs data using underline. "A" Outputs data using underline,blink, and reverse. (*1)

"B" Outputs data using blink. (*1) "-"(Hyphen)

 Outputs deletion lines. Thisvalue is for a printed form

function. Do not specify thisvalue for a screen displayfunction.

"R" Outputs data using reverse."S" Outputs data using underline

and blink. (*1)"T" Outputs data using underline

and reverse.*1 Blink cannot be used under this system.

EDIT-CURSOR

Before execution of the READ statement, positioning of thecursor can be specified for the EDIT-CURSOR special register.The following table explains the values that can be specified

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 657/783

The following table explains the values that can be specified.

Table 72. Values that can be specified for EDIT-CURSOR

Value Explanation Value Explanation" "(Blank)

Does not position the cursor. "X" Suppresses the specification ofthe cursor position item.(Cursor position item only)

"C" Positions the cursor.

Appendix F. Message Lists

This appendix explains messages written by the WINCOB andcompile commands, the COBOL85 compiler, and the COBOL85run-time system.

Note: Messages listed in this chapter are 32-bit COBOLmessages. 32-bit COBOL messages are generally moredescriptive and apply to both 32 and 16-bit COBOL. While 16-bit

users may see a slightly different message, the message numberwill provide an easy mapping between the older 16-bit messagesand the more descriptive 32-bit messages.

Messages Output by WINCOB and Compile Commands

This section explains messages written by the WINCOB andcompile commands, system action, programmer response, andparameters. A variable character string is expressed as $s in themessages below.

'$s' is an invalid source file name.

Compilation terminated

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 658/783

Compilation terminated.

ResponseSpecify the correct file name, then re-execute.

An invalid suboption is specified for '$s'.

Compilation terminated.

Response

Specify the correct sub-option, then re-execute.'-P' option is missing. '$s' option is ignored.

Ignores the option ($s) and continues compilation.

636   Appendix F. Message Lists

 ResponseTo enable the option ($s), specify it with the -P option, then re-execute.

Source file name is missing.

Compilation terminated.

ResponseSpecify the name of the file to be compiled, then re-execute.

'$s' is not a COBOL85 Compiler option.

Compilation terminated.

ResponseSpecify the correct option, then re-execute.

Argument of '$s' is not specified.

Compilation terminated.

ResponseSpecify the argument for the option ($s) correctly, then re-execute.

'$s' was not found.

Compilation terminated.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 659/783

ResponseSpecify the correct file name, then re-execute. The file name iswritten for $s.

System error '$s1' occurred on '$s2'.

Terminates compilation abnormally.

ResponseCheck and eliminate the cause of the error. System error codeerrno=0xXXX XXX (expressed in hexadecimal) is written for $s1.The name of the processing in which the system error occurred iswritten for $s2.

 Appendix F. Message Lists  637

Number of users exceeded the specified maximum.

Compilation terminated.

ResponseStart processing when the number of users becomes smaller thanthe specified maximum.

Error occurred in LANPACK environment. '$s'.

Compilation terminated.

ResponseCheck and eliminate the cause of the error. The character stringindicating the error information is written for $s. (See Table 72.)

Table 72. Error information

Character String Error Information Programmer ResponseSETERR The environment variable for

LANPACK is not specified

correctly.

Check if LANPACK is installedcorrectly.

NOUSFILE The control file for LANPACK isnot found.

 ___________________ 

OTHERERR Other error. The error is probably caused byLANPACK. Collect the errorinformation and call your FujitsuSE.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 660/783

Messages Produced by the COBOL85 Compiler

This section explains messages written by the COBOL85compiler.

The following shows the message format:

message-number line-number message-text

• message-number

• message number is displayed as shown below.

638   Appendix F. Message Lists

JMNnnnnI-S

 JMN: Prefix indicates a COBOL compiler message.

nnnn: Message serial number.

I: Indicates that operator response is not required.

S: Indicates the severity code. (See Table 73.)

Table 74. Severity codes of messages output by the COBOL85 compiler 

Severity Code Level Meaning Return Code

I (INFORMATION) Transmitting message Information detected bythe compiler. 0

W (WARNING) Warning error The object program hasbeen generated. However,check whether thecompilation results are asexpected.

E (ERROR) Recoverable error The object program hasbeen generated. An error

(e.g., compiler optionerror) has occurred.

1

S (SERIOUS) Serious error The object program hasnot been generated.

2

U(UNRECOVERABLE)

Unrecoverable error Compilation has beenhalted.

3

• line-number

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 661/783

The line number of the line containing an error is displayed.Messages indicating the same error information are displayedcollectively. In this case, more than one line number isdisplayed.

• message-text

Explains the error conditions.

 Appendix F. Message Lists  639

Messages Produced by the COBOL85 Run-time System

This section explains messages written by the COBOL85 run-time system.

The following shows the message format:

message-number message-text

• message-number

The message number is displayed as shown below:

JMPnnnni-w

 JMP: Prefix indicates a run-time system message.

nnnn: Message serial number.

i: Characters to indicate severity and response required.

I: Operator response is unnecessary.A: Operator response is necessary.

w: Severity code. (See Table 74.)

Table 75. Meaning of severity codes in execution-time message and their effect onreturn codes

Severity Code Level Meaning Effect on Return

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 662/783

Severity Code Level Meaning Effect on ReturnCode

I (INFORMATION) Transmittingmessage

Information detected bythe run-time system. Theprogram can be executednormally.

Not affected

W (WARNING) Warning error The program can beexecuted normally.However, check whether

the execution results areas expected.

Not affected

640   Appendix F. Message Lists

E (ERROR) Recoverableerror

There is an error, but processing is continuedaccording to theappropriate assumption.

Affected(*1)

U(UNRECOVERABLE)

Unrecoverableerror

The system stopsprogram execution andperforms terminationprocessing.

Not affected (*2)

*1 If an E-level message output, a return code is set when the COBOL execution unitterminates. The E-level message return code is assumed to be 12. It is compared to the valuein special register PROGRAM-STATUS, and the larger value is set as the return code.*2 The program terminates abnormally.

Message-text explains the error conditions.The following explains an error address written for a parameterindicating variable information in the message text:

• error address

The place where the error was detected is displayed in thefollowing form.

− When either compile option TRACE or CHECK isspecified:PGM= External program name. LINE= Statement number.

Statement number: [COPY modification value -] line number.Verb number

− For cases except those mentioned above:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 663/783

o cases except t ose e t o ed abo e:PGM= External program name. ADR= nnnnnnnn.

nnnnnnnn : Application address where the error is detected.

The following explains messages written by the COBOL85 run-time system, system action, and programmer response in thefollowing format:

message-number

  message-text (*1)

System action or run-time system action

 Appendix F. Message Lists  641

ExplanationExplanation of the message text

Response

Action to be taken by the programmer

*1 $n in message text is a parameter indicating variableinformation. The parameter is replaced by the program nameor file name in the actual message.

The following explains an access name or file name written for aparameter indicating variable information in message text:

• Access name:

An access name is used for connecting a program and fileentity. The access name corresponds to the run-timeenvironment information name specified with the file entityname at run-time. The access name also corresponds to thefile identifier specified in the ASSIGN clause.

• File name:

A file name is a file entity name. The file name corresponds tothe file identifier literal or data name specified in the ASSIGNclause. "?" is displayed if the data name is not recognized.

If DISK or PRINTER is specified in the ASSIGN clause, thefile name corresponds to the file name specified in the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 664/783

file name corresponds to the file name specified in theSELECT clause.

The file name specified in the SELECT clause is enclosed inparentheses in the message text.

JMP0001I-UOPEN ERROR. FILE=$1.

Abnormally terminates the program. Response

• Check whether the access name ($1) corresponding to thefunction name SYSIN or SYSOUT is assigned correctly.

642   Appendix F. Message Lists

• Before activating Windows, start the SHARE command inMS-DOS command mode. (16)

JMP0002I-U

PROGRAM '$1' IS RECURSIVELY CALLED.

Abnormally terminates the program.

ExplanationThe program ($1) was called, and is re-called before it terminates(before execution of the STOP RUN or EXIT PROGRAMstatement).

ResponseCheck the CALL statement in the called program.

JMP0007I-WINVALID OPTION. $1.

Ignores the run-time option ($1), and continues processing.

If the specified run-time option is SWITCH, the SWITCH run-time option is enabled as follows:

• If the digit count of the number in the specified numeric partis smaller than eight, the number is written left-justified.

• If the digit count is greater than eight, the high-order eightdigits are valid.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 665/783

ResponseSpecify the correct run-time option, then re-execute.

JMP0009I-UINSUFFICIENT STORAGE AVAILABLE.

Abnormally terminates the program.

Response

Do the following, then re-execute:

• Stop all applications that are executing at the same time

• Confirm the size of real storage and increase it if necessary

 Appendix F. Message Lists  643

• Confirm the size of virtual storage and increase it if necessary

JMP0010I-ULIBRARY WORK AREA IS BROKEN.

Abnormally terminates the program.

ExplanationThe work area of the COBOL85 run-time system is broken.

ResponseCheck the program as follows:

• If an item including a subscript, index, referencemodification, or OCCURS DEPENDING ON clause isreferred to, confirm that the item is within the referencerange. This check can be made by specifying the CHECKoption.

• If a parameter was specified for transferring data via theCALL statement, confirm that the sender and receiver havethe same parameter attributes. Especially, check the lengthattribute.

• If a file is used, confirm that the record is referenced in thecorrect length. For example, if the maximum record length isused instead of the actual record length and the remainingportion is filled with spaces, the record is referenced

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 666/783

incorrectly.JMP0012I-UINTERNAL PROGRAM IS RECURSIVELY CALLED IN PROGRAM $1.

Abnormally terminates the program.

ExplanationThe internal program included in the outermost program ($1)

was called, and the internal program is re-called before itterminates (before execution of the STOP RUN or EXITPROGRAM statement).

644   Appendix F. Message Lists

ResponseCheck the CALL statement in the called program.

JMP0015I-U

CANNOT CALL PROGRAM '$1'. $2.

Abnormally terminates the program.

Response

• Eliminate the cause of the error according to the error codewritten for $2, then re-execute.

(16): Refer to “Error Codes of the Load Library function.”(32): Refer to Visual C++ on-line help information.

• If no error code is written for $2, check whether the entrypoint ($1) specified in the CALL statement exists in the DLL.(16)

JMP0016I-U

READ/WRITE ERROR. FILE='$1'.

Abnormally terminates the program.

ResponseCheck the file assigned to the access name ($1).

JMP0018I-UCLOSE ERROR. FILE='$1'.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 667/783

Abnormally terminates the program.

ResponseCheck the file assigned to the access name ($1).

JMP0019I-UEXTERNAL DATA ATTRIBUTE ERROR. DATA=$1. PGM=$2,$3.

Abnormally terminates the program.ResponseConfirm that the program ($2) in which the error was detectedand the program ($3) which defined the EXTERNAL data ($1)

 Appendix F. Message Lists  645

have the same $1 definition. A data name is usually written for$1. If no data name is defined (e.g., FILLER), the file definitionnumber that appeared in the source program is written.

JMP0020I-UINVALID ENTRY INFORMATION. PGM=$1.

Abnormally terminates the program.

Response

(16): Check whether the correspondence between the DLL name,program name, and secondary entry point name of the calledprogram ($1) is correctly defined in the initial file for execution.

(32): Check whether the entry information (DLL name, programname and the second entry point name of the called program ($))is correctly defined in the entry information file specified for@CBR_ENTRYFILE or in the initialization file for execution.

JMP0022I-U

EXTERNAL FILE ATTRIBUTE ERROR. FILE=$1. PGM=$2,$3. '$4'.

Abnormally terminates the program.

ResponseConfirm that the program ($2) in which the error was detectedand the program ($3) that is first defined the EXTERNAL file ($1)have the same $1 definition. A file name is usually written for $1.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 668/783

If the file name cannot be written, the file definition number thatappeared in the source program is written. One of the characterstrings shown in Table 75 is written for $4.

Table 76. Character strings written for JMP0022I-U $4

646   Appendix F. Message Lists

 Common file organizations

$4 Error Contents

ACCESS-MODE Access modeACCESS-NAME Access nameFILE-ORG File organizationLOCK-MODE LOCK MODE clause specificationMAXRL Maximum record lengthMINRL Minimum record lengthOPTIONAL Presence or absence of OPTIONAL clause specificationREC-MODE Record format

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 669/783

 Appendix F. Message Lists  647

Relative/Indexed file

$4 Error ContentsALT-KEY Number of alternate record keys

KEY-ATR Key item attributeKEY-DISP Displacement of the key item in a recordKEY-DUPL Presence or absence of DUPLICATES clause specificationKEY-LEN Key lengthREL-ATR Attribute of the relative key itemREL-COL Column count of the relative key itemREL-KEY Presence or absence of RELATIVE KEY clause

specificationREL-LEN Length of the relative key itemREL-NAME Name of the relative key item

Print file

 $4 Error ContentsADVANCING Presence or absence of the WRITE statement in which

ADVANCING is specifiedCHAR-TYPE Presence or absence of specification of how to write the

CHARACTER TYPE clause for format 3

CODE Presence or absence of specification of the CODE clauseCTLCHR Attribute of the control statement areaLINAGE Presence or absence of specification of the LINAGE

clauseLNG-ATR Attribute and column count of the LINAGE data itemLNG1-INTEG Integer of LINAGE data item 1LNG1-NAME Name of LINAGE data item 1LNG2-INTEG Integer of LINAGE data item 2

LNG2 NAME Name of LINAGE data item 2

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 670/783

LNG2-NAME Name of LINAGE data item 2LNG3-INTEG Integer of LINAGE data item 3LNG3-NAME Name of LINAGE data item 3LNG4-INTEG Integer of LINAGE data item 4LNG4-NAME Name of LINAGE data item 4REC-LEN Record length

648   Appendix F. Message Lists

JMP0026I-WNO 'ON EXCEPTION' STATEMENT EXISTS, WHEN EXCEPTION OCCURRED ON'$2 $1' STATEMENT.

Continues processing.

ResponseSpecify the ON EXCEPTION clause in the $2 statement (ACCEPTor DISPLAY statement) corresponding to the $1 function name(ARGUMENT-VALUE or ENVIRONMENT-VALUE).

JMP0092I-UCANNOT REGISTER WINDOWCLASS '$1'.

Abnormally terminates the program.

Response

Do the following, then re-execute:

• Confirm that the program name does not contend withanother process.

• Check whether the EXPORT statement is specified correctlyin the module definition file.

• Stop all applications that are executing at the same time

• Confirm the size of real storage and increase it if necessary

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 671/783

• Confirm the size of virtual storage and increase it if necessary

• Check whether the initial file format is correct. (16)

JMP0093I-UCANNOT CREATE WINDOW '$1'.

Abnormally terminates the program.

 Appendix F. Message Lists  649

Response

Do the following, then re-execute:

• Confirm that the program name does not contend withanother process.

• Check whether the stack size is large enough.

• Stop all applications that are executing at the same time

• Confirm the size of real storage and increase it if necessary

• Confirm the size of virtual storage and increase it if necessary• Check whether the initial file format is correct. (16)

JMP0096I-URUN-TIME INITIAL FILE'S PATH-NAME IS INVALID.

Abnormally terminates the program.

ResponseCheck whether the path name of the initial file for execution isspecified correctly.

JMP0097I-URUN-TIME SYSTEM IS NOT INSTALLED PROPERLY. FILE=$1.

Abnormally terminates the program.

Response

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 672/783

Response• Confirm the file($1) is correctly installed.

• Confirm the run-time system is correctly installed. Or,confirm the installation directory of the run-time system iscorrectly set in the environmental variable PATH.

JMP0099I-U

FORCED TERMINATION. CODE=$1.

Terminates the program.

650   Appendix F. Message Lists

ResponseEliminate the cause of the error according to the previous outputmessage. If no message was written, an internal error probably

occurred. Call your Fujitsu SE. The ABEND (abnormal end) codeis written for $1.

JMP0200I-EINSUFFICIENT DATA ACCEPTED FROM SYSIN.

Continues processing assuming that the remaining part of theinputted data area is blank.

Response• Prepare the number of data items that can be input by

executing the ACCEPT FROM SYSIN statement.

• Confirm that the ACCEPT statement is not executed anumber of times equal to or greater than the number of dataitems.

JMP0201A-IAWAITING A REPLY.

After receiving response, continues processing.

ExplanationThe system asks the operator to input data by using the ACCEPTstatement.

Response

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 673/783

ResponseInput any necessary data.

JMP0202A-I'$1'

After receiving response, continues processing.

ExplanationThe STOP literal statement is being executed.

 Appendix F. Message Lists  651

ResponseInput any character. The literal specified in the STOP literalstatement is written for $1.

JMP0204I-USTATEMENT SEQUENCE ERROR. STM=$1. PGM=$2. LINE=$3. RPT=$4.

Abnormally terminates the program.

ResponseCorrect the execution sequence of statements for the report ordetail phrase indicated in the message, then re-execute. The type

of statement (INITIATE, GENERATE, or TERMINATE) is writtenfor $1. The outermost program name is written for $2. Thestatement number ([copy-qualification-value-]line-number.verb-number.) is written for $3. The report name or data name (detailphrase name) is written for $4.

JMP0206I-WSCREEN ITEM SIZE IS LARGER THAN LOGICAL SCREEN.

The screen item is displayed partially.

ResponseSpecify a logical screen size large enough to display the entireitem.

JMP0207I-ULOGICAL SCREEN SIZE IS TOO LARGE.

Abnormally terminates the program

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 674/783

Abnormally terminates the program.

ResponseSpecify the logical screen size so that (column count + 1) * linecount is equal to no more than 16,250, then re-execute.

JMP0208I-EINVALID NUMERICAL VALUE ACCEPTED.

Writes zero to the receive data item, then continues processing.

652   Appendix F. Message Lists

ResponseSpecify a value for the numeric item of the ACCEPT statementcorrectly, then re-execute.

JMP0301I-E'$1'($2) OPENED BY '$3' IS NOT CLOSED.

Terminates the program without performing close processing forthe file.

ResponseCorrect the program ($3) so that the CLOSE statement is

executed for the file ($1) before termination of the program ($3).The open mode of the file ($1) is written for $2.

JMP0302I-UCLOSE ERROR DURING PROGRAM TERMINATION. PGM=$1. FILE=$2.

Abnormally terminates the program.

Response

Check and eliminate the cause of the error. If another message iswritten, refer to it to determine the cause. The program name iswritten for $1. The access name or file name is written for $2.

JMP0310I-I/U$1 ERROR. FILE=$2. '$3'. $4

Continues program processing if the severity code is I; aborts the

program if the severity code is U. The severity code isdetermined as follows:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 675/783

p g y ydetermined as follows:

I: The FILE STATUS clause is specified for file definition.

U: The FILE STATUS clause and error procedures are notspecified.

 Appendix F. Message Lists  653

ResponseEliminate the cause of the error according to the character string

written for $3, then re-execute. OPEN or CLOSE is written for $1.The access name or file name is written for $2. One of thecharacter strings shown in Tables 77 and 78 are written for $3.The error address is written for $4.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 676/783

654   Appendix F. Message Lists

Table 77. Character strings written for JMP0310I-I/U $3 (1)

$3 Error Contents Programmer Response

ACC-METHOD The specified file access methodis invalid. (*1)

Specify the file access methodcorrectly.

BLKED-FILE The file cannot be used becauseof a CLOSE statement error.

Check and eliminate the cause ofthe CLOSE statement error.

ERFLD=xxxx Error code from the systemxxxx: Expressed in hexadecimal

Check for and eliminate thecause of the error according tothe system error code. (*2)

ERRCD=xxxx A presentation file access erroroccurred.

Check for and eliminate thecause of the error according tothe manuals of the connectedproducts. (*3)

EXCL-ERROR An exclusive error occurred. Re-execute. If the exclusive erroroccurs repeatedly, confirm thatthe error does not affectoperation.

FCB The FCB control statement isinvalid

Check the FCB control statement.

FILE-LOCK The file is exclusively used byanother user, or the file cannotbe used exclusively because it isbeing used by another user.

FTNCD=xxxx Error code from the systemxxxx: Expressed in hexadecimal

Check for and eliminate thecause of the error according tothe system error code. (*2)

LOAD The subprogram could not beloaded.

Check the program run-timeenvironment.

LOCK-FULL The lock table is full. Re-execute. If the error occurst dl fi th t th

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 677/783

repeatedly, confirm that the errordoes not affect operation.

NON-FILE The file did not exist when theOPEN statement withoutOUTPUT specified wasexecuted.

Before executing the program,create the file.

NON-REEL The CLOSE statement with

REEL or UNIT specified wasexecuted.

Correct the program.

 Appendix F. Message Lists  655

Table 77. Character strings written for JMP0310I-I/U $3 (1) (cont.)

$3 Error Contents Programmer Response

NON-UNIQUE Allocated file has a duplicatekey.

Make the keys duplicate in theprogram specification.

OPEN-MODE The specified file open mode isinvalid.

Specify the correct open mode,then open the file.

READ-ONLY A read-only file is used, or thespecified file name is invalid.

Change the file attribute, orspecify the correct file name.

REC-MODE The specified record format isinvalid.

Specify the correct recordformat.

RMERR=xxxx Error code from the systemxxxx: Expressed in hexadecimal A system error probablyoccurred. Collect the errorinformation, then call yourFujitsu SE.

UNSUPPORT The file does not support thespecified function.

Check the file attribute, orconfirm that there is no physicalerror.

*1 An attempt was made to access a different file organization or to access an indexed filerequiring recovery.

*2 - If a message is generated showing error information ERFLD=101 when a print file(without the FORMAT clause specified) is executed, ensure the following:

Only the required number of printer drivers are installed.The FCB control statement is less than 2,048 bytes.All the specified forms overlay patterns are correct.All the registered forms overlay pattern names are correct.The spool area is large enough.(Confirm the disk capacity of the environment variable (TMP.)directory.

Stop all other applications that are executing at the same time.Confirm the size of real storage and increase it if necessary.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 678/783

Confirm the size of real storage and increase it if necessary.Confirm the size of virtual storage and increase it if necessary.If no problems are found in the above checks, a system error probablyoccurred. Collect the error information, then call your Fujitsu SE.

  - For Btrieve file error codes, refer to the “Btrieve Manual” issued by NOVELL Inc.  - See “System Error Codes” for details on character strings indicating errors in the file

message text other than that above.*3 If ERRCD=90xx is output while FORM RTS is used, refer to the FORM RTS online help forxx.

656   Appendix F. Message Lists

If any of the character strings shown in Table 77 are displayed,eliminate any conflicts between the file or record definition in theprogram and the attribute of the file to be processed.

Table 78. Character strings written for JMP0310I-I/U $3 (2)

$3 Error Contents Check Item in ProgramINV-BLKSZ The block length is invalid. Length specified in the BLOCK

CONTAINS clauseINV-CODEST The code set is invalid. Character code specified in the

CODE SET clauseINV-COLSEQ The collating sequence is invalid. Alphabet name specified in the

PROGRAM COLLATING

SEQUENCE clauseINV-DELMTR The record delimiter is invalid. Data specified in the

ORGANIZATION, RECORD,and RECORD DELIMITERclauses

INV-KEYDUP Determination of whether tospecify a key in duplicate(DUPLICATES) is incorrect.

Presence or absence ofspecification of the RECORDKEY, ALTERNATE RECORD

KEY, and DUPLICATES clausesINV-KEYLEN The key length of the allocatedfile conflicts with the definitionin the program.

Data name length specified in theRECORD KEY and ALTERNATERECORD KEY clauses

INV-KEYSTR The key structure is invalid. Data name length and data namecount specified in the RECORDKEY and ALTERNATE RECORDKEY clauses, or the relativeposition in the record of the data

name specified in the clauses.INV-LRECL The record length of the allocated Data specified in the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 679/783

file conflicts with the definitionin the program.

ORGANIZATION clause.Record length specified in theRECORD CONTAINS clause.

INV-RKP The relative key position of theassigned file conflicts with thedefinition in the program.

Relative position in the record ofthe data name specified in theRECORD KEY and ALTERNATERECORD KEY clauses

KEY-ATTR The key attribute of the allocatedfile conflicts with the definitionin the program.

Data name attribute specified inthe RECORD KEY andALTERNATE RECORD KEYclauses

 Appendix F. Message Lists  657

Table 78. Character strings written for JMP0310I-I/U $3 (2) (cont.)

$3 Error Contents Check Item in ProgramKEY-ESDS A sequential file was not

allocated when specified.

Data specified in the

ORGANIZATION clauseKEY-KSDS An indexed file was not allocated

when specified.KEY-RRDS A relative file was not allocated

when specified.KEY-TEXT A text file was not allocated as a

print file.

JMP0311I-I/UMISSING ALLOCATION. FILE=$1. $2.

Continues program processing if the severity code is I; aborts theprogram if the severity code is U. The severity code isdetermined as follows:

I: The FILE STATUS clause is specified for file definition.

U: The FILE STATUS clause and error procedures are notspecified.

ResponseAllocate the file ($1) if necessary, or specify the file correctly, thenre-execute. The error address is written for $2.

JMP0313I-I/U

INSUFFICIENT STORAGE AVAILABLE. STM=$1. FILE=$2. $3

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 680/783

Discontinues error file processing, then continues programprocessing if the severity code is I; aborts the program if theseverity code is U. The severity code is determined as follows:

I: The FILE STATUS clause is specified for file definition.

U: The FILE STATUS clause and error procedures are notspecified.

658   Appendix F. Message Lists

ResponseDo the following, then re-execute:

• Stop any other applications that are executing at the same

time

• Confirm the size of real storage and increase it if necessary

• Confirm the size of virtual storage and increase it if necessary

The COBOL statement (OPEN, CLOSE, START, READ, WRITE,REWRITE, or DELETE) that caused the virtual storage to become

insufficient is written for $1. The file name or access name of theprocessed file is written for $2. The error address is written for$3.

JMP0320I-I/UINPUT/OUTPUT ERROR. STM=$1. FILE=$2. '$3'. $4

Discontinues error file processing, then continues programprocessing if the severity code is I; aborts the program if theseverity code is U. The severity code is determined as follows:

I: The FILE STATUS clause is specified for file definition.U: The FILE STATUS clause and error procedures are notspecified.

ResponseEliminate the cause of the error according to the character string

written for $3. The COBOL statement (START, READ, WRITE,REWRITE, or DELETE) that caused the input-output error is

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 681/783

REWRITE, or DELETE) that caused the input output error iswritten for $1. The file name or access name of the processed fileis written for $2. One of the character strings shown in Table 79 iswritten for $3. The error address is written for $4.

 Appendix F. Message Lists  659

Table 79. Character strings written for JMP0320I-I/U $3

$3 Error Contents Programmer Response

ALTD-LEN The record length specified inthe REWRITE statement isdifferent from the length of anexisting record.

Do not change the length of anexisting record when updatingthe record.

BLKED-FILE The file cannot be used becauseof a CLOSE statement error.

If message JMP0310I-I isdisplayed before JMP0320I-I,eliminate the cause of the erroraccording to message JMP0310I-I.

ERRCD=xxxx A presentation file access erroroccurred.

Check for and eliminate thecause of the error according tothe manuals of the linkedproducts. (*1)

EXCEED-LEN The length of the record to bewritten exceeds the maximumrecord length specified in theprogram.

Set the record length to withinthe specified maximum recordlength.

EXCL-ERROR An exclusive error occurred. Re-execute. If the exclusiveerror occurs repeatedly,confirm that the error does notaffect operation.

FCB The FCB contents are invalid. Check the FCB contents.FDBK=xxxx Error code from the system

xxxx: Expressed inhexadecimal

Check for and eliminate thecause of the error according tothe system error code. (*2)

FONT A font that did not exist in the

system was specified foroutput.

Install necessary fonts in the

system.

FOVL Th ifi d di Ch k h i i i l fil

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 682/783

FOVL The specified directorycontaining the forms overlaydefinition is invalid, or theforms overlay definition isinvalid.

Check the initial file todetermine if the directorycontaining the correct formsoverlay definition is specified.

FTNCD=xxxx Error code from the systemxxxx: Expressed inhexadecimal

Check for and eliminate thecause of the error according tothe system error code. (*2)

660   Appendix F. Message Lists

Table 79. Character strings written for JMP0320I-I/U $3 (cont.)

$3 Error Contents Programmer Response

INV-CHAR A line sequential file record orprint file record contains aninvalid character.

Check the data contents.

INV-LEN The record length specified inthe WRITE or REWRITEstatement is invalid.

Specify the correct length of therecord to be written.

KEY-CHANGE The key value at request forupdating the record wasdifferent from the key value atreading of the record.

Correct the program so that thekey value is not changed atupdating of the record.

LOAD The subprogram could not beloaded.

Check the program run-timeenvironment.

NO-TRANS Some characters in native modecannot be converted into a codeset.

Check the data contents.

PHYSIC-ERR A physical error occurred. Check the file contents(physical structure).

READ-ONLY A read-only file is used. Change the file attribute.REC-LOCK The record is exclusively used

by another user, or the recordcannot be used exclusivelybecause it is being used byanother user.

Re-execute. If the exclusiveerror occurs repeatedly,confirm that the error does notaffect operation.

R.KEY-ERR The relative key contentsconflict with the definitionspecified in the PICTURE

clause during random ordynamic access.

Specify a data item size in thePICTURE clause large enoughto store the maximum value of

the relative key.

Th l ti k it l i 0 S if l f th

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 683/783

The relative key item value is 0. Specify a non-zero value for therelative key item.

 Appendix F. Message Lists  661

Table 79. Character strings written for JMP0320I-I/U $3 (cont.)

$3 Error Contents Programmer Response

RMERR=xxxx Error code from the systemxxxx: Expressed inhexadecimal

A system error probablyoccurred. Collect the errorinformation, then call yourFujitsu SE.

RRN>R.KEY When the READ or WRITEstatement is executed forsequential processing, therelative record number exceedsthe maximum value of the

relative key item.

Specify a size of the relative keyitem large enough to store themaximum relative recordnumber of the file

*1 If ERRCD=90xx is output while Form RTS is used, refer to the Form RTS HELP for xx.*2 •  If a message is output showing error information FDBK=101 when a print file (without the

FORMAT clause specified) is executed, ensure the following:

Only the required number of printer drivers are installed.

The FCB control statement is less than 2,048 bytes.

All the specified forms overlay patterns are correct.The spool area is large enough.

(Confirm the disk capacity of the environment variable (TMP.)directory.Stop all other applications that are executing at the same time.Confirm the size of real storage and increase it if necessary.Confirm the size of virtual storage and increase it if necessary.All the registered forms overlay pattern names are correct.

If no problems are found in the above checks, a system error probably occurred.

Collect the error information, then call your Fujitsu SE.

  •  For Btrieve file error codes, refer to the “Btrieve Manual” issued by NOVELL Inc.

  •  See “System Error Codes” for details on character strings indicating errors in the file messagetext other than the above.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 684/783

JMP0321I-UAT END CONDITION. STM=READ. FILE=$1. $2

Abnormally terminates the program.

Response

• Specify AT END phrase in the READ statement to performfile end processing.

662   Appendix F. Message Lists

• Check whether the number of input data items is correct.

The file name or access name of the file with which a file endcondition was produced is written for $1. The error address is

written for $2.JMP0322I-UKEY SEQUENCE ERROR. STM=$1. FILE=$2. $3

Abnormally terminates the program.

Response

If $1 is the WRITE statement, correct the program so that thekey values are written in ascending order.

• If $1 is the REWRITE or DELETE statement, correct theprogram so that the key value of the record read by theprevious READ statement is not changed.

The file name or access name of the file with which an invalidkey condition was produced is written for $2. The error addressis written for $3.

JMP0323I-UDUPLICATE KEY ERROR. STM=$1. FILE=$2. $3

Abnormally terminates the program.

Response

Correct the program so that a key is not duplicated. The errorCOBOL statement (WRITE, REWRITE or CLOSE) is written for$1 The file name or access name of the error file is written for $2

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 685/783

$1. The file name or access name of the error file is written for $2.The error address is written for $3.

JMP0324I-URECORD NOT FOUND. STM=$1. FILE=$2. $3

Abnormally terminates the program.

 Appendix F. Message Lists  663

Response

• Correct the program so that attempts to access a non-existentrecord are inhibited.

• Correct the program by using the FILE STATUS or INVALIDKEY clause so that the program checks an attempt to access anon-existent record.

The error COBOL statement (READ, REWRITE, START, orDELETE) is written for $1. The file name or access name of theerror file is written for $2. The error address is written for $3.

JMP0325I-I/UBOUNDARY VIOLATION ERROR. STM=$1. FILE=$2. $3

Continues program processing if the severity code is I; aborts theprogram if the severity code is U. The severity code isdetermined as follows:

I: The FILE STATUS clause is specified for file definition.

U: The FILE STATUS clause and error procedures are notspecified.

ResponseIncrease the size of the file space, then re-execute. The errorCOBOL statement (WRITE, REWRITE, READ, START, orCLOSE) is written for $1. The file name or access name of the

error file is written for $2. The error address is written for $3.

JMP0326I-U

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 686/783

NO-SPACE CONDITION. STM=$1. FILE=$2. $3

Abnormally terminates the program.

ResponseIncrease the size of the file space, then re-execute. The error

COBOL statement (WRITE, REWRITE, READ, START, orCLOSE) is written for $1. The file name or access name of theerror file is written for $2. The error address is written for $3.

664   Appendix F. Message Lists

JMP0327I-UINVALID KEY CONDITION. STM=$1. FILE=$2. '$3'. $4

Abnormally terminates the program.

ResponseIf $3 is RRN>R.KEY, correct the program so that the relativerecord number does not exceed the maximum value permittedfor the relative key item when records are written in sequentialprocessing. Alternatively, correct the program by using theINVALID KEY clause so that processing for an invalid keycondition is performed. The error COBOL statement (WRITE) is

written for $1. The file name or access name of the error file iswritten for $2. The error address is written for $4.

JMP0328I-I/UDEPENDING ON OBJECT VALUE IS OUT OF RANGE. STM=WRITE. FILE=$1.$2

Continues program processing if the severity code is I; aborts the

program if the severity code is U. The severity code isdetermined as follows:

I: The FILE STATUS clause is specified for file definition.

U: The FILE STATUS clause and error procedures are notspecified.

Response

Correct the program so that the DEPENDING ON value isdefined in the specified range. The file name or access name ofthe error file is written for $1 The error address is written for $2

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 687/783

the error file is written for $1. The error address is written for $2.

JMP0330I-I/USTATEMENT SEQUENCE ERROR. STM=$1. FILE=$2. '$3'. $4

Continues program processing if the severity code is I; aborts the

program if the severity code is U. The severity code isdetermined as follows:

I: The FILE STATUS clause is specified for file definition.

 Appendix F. Message Lists  665

U: The FILE STATUS clause and error procedures are notspecified.

Response

Eliminate the cause of the error according to the character stringwritten for $3, then re-execute. The COBOL statement (OPEN,CLOSE, READ, WRITE, REWRITE, START, or DELETE) withwhich an input-output error occurred is written for $1. The filename or access name of the processed file is written for $2. Oneof the character strings shown in Table 80 is written for $3. Theerror address is written for $4.

Table 80. Character strings written for JMP0330I-I/U $3

$3 Error InformationAT-END After a file at end condition was produced, the READ statement was

re-executed.DUPL-OPEN The OPEN statement was executed for an open file.LOCKED After the CLOSE statement with LOCK phrase specified was executed

an attempt was made to open the file.

NO-READ The previous statement is not a successful READ statement.NOSPACE After a no-space condition was produced, the WRITE statementwas re-executed.

NOT-OPENED An input-output statement was executed for a closed file.OPEN-MODE The OPEN mode is invalid.POS-ERROR The file position indicator is undefined.

JMP0340I-U

CONTROL RECORD FORMAT ERROR. STM=WRITE. FILE=$1. '$2'. $3

Abnormally terminates the program.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 688/783

y p g

ResponseEliminate the cause of the error according to the character stringwritten for $2, then re-execute. The file name or access name ofthe processed file is written for $1. One of the character strings

shown in Table 81 is written for $2 and shows the relationshipbetween the character strings and control record contents. Theerror address is written for $3.

666   Appendix F. Message Lists

Table 81. Character strings written for JMP0340I-U $2

$2 Field Contents $2 Field Contents

 BIND Binding direction OSTK Offset stack CMOD Copy modification module

name PFRM Printing format

 C-NO Number of copies POST Printing surface positioning FCB FCB name PRTA Unprintable area FID Format definition deck

name RSV Reserved area (not blank)

 FORM Forms code R-NO Forms overlay printingcount

 FOVL Forms overlay modulename

 SIDE Printing surfacespecification

 F-NO Number of forms overlayfields

 SIZE Forms size

 HOP Hopper STK Stacker ID Control record ID S-NO Copy correction start

number LEN Control record length T-NO Number of character array

table for copy correction LOAD Dynamic loading WDTH Binding width MODE Control mode XTB Name of character array

table for copy correction OFST Print origin position

JMP0350I-U

 USE PROCEDURE IS RECURSIVELY CALLED.

Abnormally terminates the program.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 689/783

ResponseIf execution of an input-output statement during an errorprocedure causes re-execution of the error procedure, do not letcontrol reach the last statement of the first-executed error

procedure.

 Appendix F. Message Lists  667

JMP0360I-UPS FILE ACCESS ERROR. CODE=$1.

Abnormally terminates the program.

ResponseCheck the contents of the destination specified in the SYMBOLICDESTINATION clause. If the contents are correct, a system errorprobably occurred. Collect the error information, then call yourFujitsu SE. The internal code indicating detailed errorinformation is written for $1.

JMP0363I-USYMBOLIC DESTINATION ERROR. FILE=$1.

Abnormally terminates the program.

ResponseSpecify the destination name in the SYMBOLIC DESTINATIONclause correctly, then re-execute. The file name or access name iswritten for $1.

JMP0364I-UCLAUSE '$1' ERROR. FILE=$2.

Abnormally terminates the program.

ResponseSpecify the correct data item in the $1 clause, then re-execute. The

file name or access name is written for $2.JMP0365I-UDUPLICATE FONT NAMES WERE FOUND. '$1'.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 690/783

Abnormally terminates the program.

ResponseMultiple fonts indicated by $1 were installed. Use the control

panel font application to delete unnecessary fonts, then re-execute: Ensure that:

668   Appendix F. Message Lists

 Windows 95

“Print True Type as Graphic” is checked in the printer Propertiesdialog box.

 Windows 3.1

• The same font type is not specified for the WIN.INI [fonts]section and WIFEMAN.INI [FontPackages] section.

• Mincho, Gothic, or Courier is generally used as the devicefont of the printer. None of the above three fonts is specifiedfor the WIN.INI [fonts] section and WIFEMAN.INI[FontPackages] section.

JMP0370I-UINSUFFICIENT STORAGE AVAILABLE TO PERFORM SQL.

Abnormally terminates the program.

Response

Do the following, then re-execute.• Stop all applications that are executing at the same time

• Confirm the size of real storage and increase it if necessary

• Confirm the size of virtual storage and increase it if necessary

JMP0371I-UENVIRONMENT INFORMATION FILE ERROR TO PERFORM SQL. '$1'.

Abnormally terminates the program.

Response

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 691/783

ResponseSpecify data in the environment information file correctly, thenre-execute. The character string indicating the error informationis written for $1. (See Table 81.)

 Appendix F. Message Lists  669

Table 82. Character strings written for JMP0371I-U $1

 (With SequeLink)

$1 Error Information

@SQL_CLI No client interface type was specified, or the specifiedcharacter is not supported.

@SequeLink_Inf No SequeLink information file was specified, or the specifiedSequeLink information file does not exist.

@SQL_HOSTNM No host name was specified.@SQL_SERVER No server name was specified.@SQL_USERID No user ID was specified.@SQL_PASSWORD No password was specified.

@SQL_DBKIND No database type was specified, or the specified database typeis not supported.

@SQL_SERVICE No service name was specified.@SQL_LOGPRM1 Logon parameter 1 was specified.@SQL_LOGPRM2 Logon parameter 2 was specified.

 (With ODBC)

$1 Error Information@ODBC_Inf No ODBC information file was specified, or the specified

ODBC information file does not exist.@SQL_DATASRC No data source name was specified.@SQL_SERVER No server name was specified.@SQL_USERID No user ID was specified.@SQL_PASSWORD No password was specified.

JMP0372I-U

START ENVIRONMENT ERROR TO PERFORM SQL. '$1'. $2

Abnormally terminates the program.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 692/783

ResponseEliminate the cause of the error according to the character stringwritten for $1, then re-execute. (See Table 82.)

670   Appendix F. Message Lists

Table 83. Character string written for JMP0372I-U $1

$1 Error Contents Programmer ResponseLOAD The run-time library could not

be loaded.Eliminate the cause of the error according tothe detail code (Load Library function errorcode) written for $2.

FREE The run-time library could notbe loaded.

Eliminate the cause of the error according tothe detail code (Load Library function errorcode) written for $2.

JMP0373I-I$1 ERROR. STM=$2. SERVER=$3. '$4'.

Continues program processing.

ResponseEliminate the cause of the error according to the error codewritten for $4, then re-execute. The type of the client interface iswritten for $1. The error SQL statement is written for $2. Thename of the error server is written for $3.

For the error code, refer to the error code manual of the clientinterface.

JMP0374I-UUNRECOGNIZABLE SQL STATEMENT WAS FOUND.

Abnormally terminates the program.

ResponseDelete the SQL statement that cannot be used, then re-execute.For SQL statements that cannot be used, see the requirements for

h d t b i t d t th i t

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 693/783

each database environment and notes on the environment.

 Appendix F. Message Lists  671

JMP0392I-UTHE NETWORK DATABASE FUNCTION CANNOT BE USED.

Abnormally terminates the program.

Response

• Change the program so that it does not use functions specificto GS-series hosts.

• To use distributed development support functions, re-executeunder the debugger. (16)

JMP0400I-UACCESS ENVIRONMENT ERROR OCCURRED. SYS=$1,FILE=$2,BLK=$3,$4=$5

Abnormally terminates the program.

ResponseA system error probably occurred. Collect the error information,then call your Fujitsu SE. The following information is written for$1 to $5:

$1: Error information from the system, or the character stringNONE if the system sends no error information

$2: System information

$3: Control block address at which the error was detected

$4: ERR or REQ

$5: The following is set as the internal error information:

If $4 is ERR: Error-detected location

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 694/783

If $4 is REQ: Processing code

672   Appendix F. Message Lists

JMP0410I-USTOP RUN STATEMENT MUST NOT BE EXECUTED USING JMPCINT2.

Abnormally terminates the program.

ResponseReplace the STOP RUN statement in the application programwith the EXIT PROGRAM statement.

JMP0420I-ICANNOT OBTAIN WINDOW HANDLE. '$1'. $2

Returns -1.

ResponseEliminate the cause of the error, then re-execute. The characterstring indicating the error information is written for $1. (SeeTable 84.)

Table 84. Character strings written for JMP0420I-I $1

$1 Error Contents Programmer Response

ACC-ERROR A window handle allocation erroroccurred.

Check for and eliminate the causeof the error according to theFORM RTS code written for $2.(*1)

INV-ENV An operating environment erroroccurred.

Check the COBOL operatingenvironment.

INV-KIND The file type corresponding to thespecified file-identifier is invalid.

Specify the presentation file-identifier.

NON-FILE The file corresponding to thespecified file-identifier does notexist.

Specify the file-identifier correctly,or check if the file was openednormally.

*1 Refer to the FORM RTS online help.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 695/783

 Appendix F. Message Lists  673

JMP0600I-I/UINSUFFICIENT STORAGE AVAILABLE TO PERFORM SORT OR MERGESTATEMENT.

Continues program processing if the severity code is I; aborts theprogram if the severity code is U. The severity code isdetermined as follows:

I: SORT-STATUS is referred to for file definition.

U: SORT-STATUS is not referred to.

Response

Do the following, then re-execute.• Stop all applications that are executing at the same time

• Confirm the size of real storage and increase it if necessary

• Confirm the size of virtual storage and increase it if necessary

JMP0601I-I/USORT OR MERGE STATEMENT ERROR. $1. $2

Continues program processing if the severity code is I; aborts theprogram if the severity code is U. The severity code isdetermined as follows:

I: SORT-STATUS is referred to for file definition.

U: SORT-STATUS is not referred to.

ResponseEliminate the cause of the error according to the value written for$1, then re-execute. The file information (file name or access

) d l d f f $ h dd

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 696/783

name) or detailed information is written for $1. The error addressis written for $2. Table 85 explains the values written for $1.

674   Appendix F. Message Lists

Table 85. Values written for JMP0601I-I/U $1

$1 Error Contents Programmer Response

51 An error occurred during inputprocessing for the record to be sorted. If the same error occurs when theprogram is re-executed, a system errorprobably occurred. Collect the errorinformation, then call your Fujitsu SE.

52 Memory is insufficient. Modify the environment to allocateenough memory.

535456

5962101

An error occurred during inputprocessing for the record to be sorted.

If the same error occurs when theprogram is re-executed, a system errorprobably occurred. Collect the error

information, then call your Fujitsu SE.

102 An error occurred during outputprocessing for the record to be sorted.

103 An error occurred during inputprocessing for the record to be merged.

110 The address of the record to be sortedcould not be obtained.

111 The record length is invalid. Check whether the record lengthcomplies with the COBOL85specification.

112113

An error occurred during inputprocessing for the record to be sorted.

If the same error occurs when theprogram is re-executed, a system errorprobably occurred. Collect the errorinformation, then call your Fujitsu SE.

114 An error occurred during input

processing for the record to be merged.208 An error occurred when a temporary

file (for sorting and merging) wasopened.

Modify the environment (e.g., harddisk) to allocate a large enoughtemporary file. If the same error occurswhen the program is re executed a

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 697/783

when the program is re-executed, asystem error probably occurred. Collectthe error information, then call yourFujitsu SE.

212 The size of the temporary file (for

sorting and merging) is insufficient.

Modify the environment (e.g., hard

disk) to allocate a large enoughtemporary file.

 Appendix F. Message Lists  675

Table 85. Values written for JMP0601I-I/U $1 (cont.)

$1 Error Contents Programmer Response

214 A temporary file (for sorting andmerging) cannot be created. Modify the environment (e.g., harddisk) to allocate a large enoughtemporary file.

224 An error occurred during write to atemporary file (for sorting andmerging).

If the same error occurs when theprogram is re-executed, a system errorprobably occurred. Collect the errorinformation, then call your Fujitsu SE.

250 A sort-merge program error occurred.Other A PowerSORT error occurred while

using PowerSORT.

Refer to the PowerSORT online help.

Do the following, then re-execute.

• Stop all applications that are executing at the same time

• Confirm the size of real storage and increase it if necessary

• Confirm the size of virtual storage and increase it if necessary

JMP0608I-I/URELEASE STATEMENT CAN NOT BE EXECUTED IN OUTPUT PROCEDURE. $1

Continues program processing if the severity code is I; aborts theprogram if the severity code is U. The severity code isdetermined as follows:

I: SORT-STATUS is referred to for file definition.

U: SORT-STATUS is not referred to.ResponseCorrect the program. The error address is written for $1.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 698/783

JMP0609I-I/URETURN STATEMENT CAN NOT BE EXECUTED IN INPUT PROCEDURE. $1

Continues program processing if the severity code is I; aborts the

program if the severity code is U. The severity code isdetermined as follows:

676   Appendix F. Message Lists

I: SORT-STATUS is referred to for file definition.U: SORT-STATUS is not referred to.

Response

Correct the program. The error address is written for $1.JMP0612I-I/URETURN STATEMENT CAN NOT BE EXECUTED AFTER AT END. $1

Continues program processing if the severity code is I; aborts theprogram if the severity code is U. The severity code isdetermined as follows:

I: SORT-STATUS is referred to for file definition.U: SORT-STATUS is not referred to.

ResponseCorrect the program so that the RETURN statement is notexecuted after a file at end condition is produced. The erroraddress is written for $1.

JMP0613I-I/USORT/MERGE LIBRARY CANNOT BE LOADED. $1 $2

Continues program processing if the severity code is I; aborts theprogram if the severity code is U. The severity code isdetermined as follows:

I: SORT-STATUS is referred to for file definition.U: SORT-STATUS is not referred to.

ResponseRemove the cause of the error, then re-execute. The library filename is set in $1 and the error code is set in $2.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 699/783

Refer to the Visual C++ online help.

Note: If $1 and $2 are not output, confirm whether or not

PowerSORT is correctly installed.

 Appendix F. Message Lists  677

JMP0701I-UGCB IS BROKEN.

Abnormally terminates the program.

ResponseThe program is broken. Correct the program as follows, then re-execute:

• If an item including a subscript, index, referencemodification, or OCCURS DEPENDING ON clause isreferred to, confirm that the item is within the allowable

reference range.• If there is a parameter for transferring data through the CALL

statement, confirm that the sender and receiver have thesame parameter attributes. (Be sure to check the lengthattribute.)

• If a file is used, confirm that the correct record length is

referenced. (For example, if SPACE clear processing isperformed with the maximum record length instead of theactual record length when a variable-length input file is used,the record length referenced is incorrect.)

JMP0702I-ULIA IS BROKEN.

Abnormally terminates the program.

ResponseSee JMP0701I-U.

JMP0703I-U

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 700/783

JMP0703I URCB IS BROKEN.

Abnormally terminates the program.

ResponseSee JMP0701I-U.

678   Appendix F. Message Lists

JMP0704I-UDEBUG TABLE IS BROKEN.

Abnormally terminates the program.

ResponseSee JMP0701I-U.

JMP0705I-WINSUFFICIENT STORAGE AVAILABLE. FUNC=$1.

Cancels the '$1' function, then continues processing.

Response

Do the following, then re-execute.

• Stop all applications that are executing at the same time

• Confirm the size of real storage and increase it if necessary

• Confirm the size of virtual storage and increase it if necessary

The character string indicating the function is written for $1.

(TRACE: Trace function/COUNT: Count function (16))

JMP0724I-WFILE CAN NOT BE OPENED. FILE=$1. '$2' OPTION IGNORED.

Continues processing without outputting '$2' information.

ResponseCheck whether the file is allocated correctly. The access name iswritten for $1. The debug function name is written for $2.

JMP0725I-WFILE CAN NOT BE OPENED. '$1' OPTION IGNORED.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 701/783

Continues processing without outputting '$1' information.

ResponseCheck whether the area is large enough to create a file. Thedebug function name is written for $1.

 Appendix F. Message Lists  679

JMP0770I-WDEBUGGER CANNOT BE ACTIVE. TEST OPTION IGNORED. $1. '$2' $3.

Ignores the compiler option TEST and continues processing.

ResponseEliminate the cause of the error according to the character stringwritten for $2, then re-execute. The name of the error program iswritten for $1. The following explains the character stringswritten for $2:

'MEMORY SHORTAGE': The memory is insufficient.

'FILE NOT FOUND': The $1 file is not found.'PATH NOT FOUND': The search path is not found.

'PATH NOT SET': No search path was specified.

'LOADING ERROR': Loading failed.

The error code (Load Library function error code) was written for

$3.JMP0820I-E/USUBSCRIPT/INDEX IS OUT OF RANGE. PGM=$1. LINE=$2. OPD=$3 ($4)

E level: Uses the subscript or index value as is, then continuesprocessing.

U level: Aborts the program.

ResponseSpecify a correct value for the subscript or index indicated in themessage, then re-execute. The outermost program name iswritten for $1. The statement number (line-information[copy-

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 702/783

written for $1. The statement number (line information[copyqualification-value-]line-number.verb-number) is written for $2.The operand name is written for $3. The number of dimensions iswritten for $4.

680   Appendix F. Message Lists

JMP0821I-E/UREFERENCE MODIFIER IS OUT OF RANGE. PGM=$1. LINE=$2. OPD=$3.

E level: Performs reference modification with an incorrect value,

then continues processing.U level: Aborts the program.

ResponseCorrect the program so that reference modification of the dataitem indicated in the message is performed within the specifiedrange. The outermost program name is written for $1. Thestatement number (line-information[copy-qualification-value-]line-number.verb-number) is written for $2. The operand nameis written for $3.

JMP0822I-E/UODO OBJECT VALUE IS OUT OF RANGE. PGM=$1. LINE=$2. OPD=$3.ODO=$4.

E level: Uses the object value specified in the OCCURS

DEPENDING ON clause as is, then continues processing.U level: Aborts the program.

ExplanationThe object value specified in the OCCURS DEPENDING ONclause is not within the permitted range.

Response

Specify a correct value for the object (in the OCCURSDEPENDING ON clause) indicated in the message, then re-execute. The outermost program name is written for $1. Thestatement number (line-information[copy-qualification-value-

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 703/783

]line-number.verb-number) is written for $2. The name of theoperand that refers to the data including the OCCURSDEPENDING outermost-program-name ON clause is written for

$3. The object name specified in the OCCURS DEPENDING ONclause is written for $4.

 Appendix F. Message Lists  681

JMP0899I-ULOGICAL ERROR.

Abnormally terminates the programs.

ResponseThe program or dynamic area may be damaged because of aprogram error. Check for the cause of the error in the samemanner as when JMP0701I-U is written.

JMP0901I-EFUNCTION $1 ERROR, ARGUMENT ABSOLUTE VALUE IS MORE THAN 3.53E+15.

Returns 0, then continues processing.ResponseSpecify the absolute value of the argument within the calculationenabled range, then re-execute. The name of the error function(SIN or COS) is written for $1.

JMP0902I-EFUNCTION $1 ERROR, ARGUMENT ABSOLUTE VALUE IS MORE THAN 1.0.

Returns 0, then continues processing.

ResponseSpecify the absolute value of the argument that can be stored inthe definition area, then re-execute. The name of the errorfunction (ASIN or ACOS) is written for $1.

JMP0903I-EFUNCTION $1 ERROR, ARGUMENT VALUE IS OUT OF RANGE.

Returns 0, then continues processing.

Response

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 704/783

pSpecify the value of the argument that can be stored in thedefinition area, then re-execute. The name of the error function(LOG, LOG10, ANNUITY, FACTORIAL, RANDOM, SQRT, orTAN) is written for $1.

682   Appendix F. Message Lists

JMP0904I-EFUNCTION $1 ERROR, ARGUMENT VALUE IS INVALID.

Returns 0, then continues processing.

ResponseSpecify the value of the argument that satisfies the condition ofeach function, then re-execute. The name of the error function iswritten for $1.

JMP0905I-EFUNCTION ANNUITY ERROR, ARITHMETIC EXCEPTION.

Returns 0, then continues processing.ResponseSpecify the value of the argument that does not cause zerodivision, then re-execute.

System Error Codes

This section explains system error codes.

The meanings of the error codes are different between Windows3.1 and Windows 95/Windows NT. See the error code table foreach system.

• With Windows 3.1: See Table 86.

• With Windows 95/Windows NT: See Table 87.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 705/783

 Appendix F. Message Lists  683

Error Codes (16)

Table 86. System error codes (16)

CODE Explanation Programmer Response1 (0x01) Invalid function code Before activating Windows, confirm

that the SHARE command is activein MS-DOS command mode.

4 (0x04) The number of files to be opened istoo large.

Specify the correct value for theSHARE command option.

5 (0x05) Access cannot be made. Check if the file is allocated correctly,or specify the correct value for the

SHARE command option.15 (0x0F) Invalid drive name. Allocate the file to a drive that can be

used.20 (0x14) A disk unit is defective. Confirm that the disk unit is not

damaged.36 (0x24) The shared buffer is full. Specify a larger value for the /L

operand of the SHARE command.

Refer to Chapter 5 for more information about the SHARE

command.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 706/783

684   Appendix F. Message Lists

Error Codes (32)

Table 87. System error codes (32)

CODE Explanation Programmer Response2 (0x02) The specified file cannot be found. Check to see if the product is

correctly installed.4 ( 0x04) The file cannot be accessed. Check the run-time environment.5 (0x05) Access cannot be made. Check whether the file is allocated

correctly.8 (0x08) Command cannot be processed

because the applicable storage area

is insufficient.

Do the following, then re-execute:n Stop all applications that are

executing at the same timen Confirm the size of real storage

and increase it if necessaryn Confirm the size of virtual

storage and increase it ifnecessary

15 (0x0F) Invalid drive name. Check whether the drive name iscorrect.

19 (0x13) Write-protected disk. Check the disk.20 (0x14) A disk unit is defective. Confirm that the disk unit is notdamaged.

21 (0x15) The drive cannot get ready. Check the drive.34 (0x22) The incorrect disk is in the drive. Check the disk.53 (0x35) The network path is not found. Check the specified network path

name.59 (0x3B) An unexpected network error

occurred.Check whether the networkenvironment is set up correctly.

127 (0x7F) The specified procedure cannot befound.

Check to see if the product iscorrectly installed.

206 (0xCE) The file name is too long. Check the file name.1785 (0x6F9) The disk may be not formatted. Check whether the disk is formatted.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 707/783

Appendix G. Writing SpecialLiterals

This appendix explains how to write literals for specifying names(for example, program and file names) defined in the system.

Program Name Literal

Any characters can be used for a literal specifying a programname in the PROGRAM-ID paragraph, CALL statement, orCANCEL statement. There are no configuration rules. You mustdetermine if the literal complies with the linker rules.

Text Name Literal

For the text name literal to be written in the COPY statement,specify the name of the file containing library text in thefollowing format:

"[drive-name: ] [path-name] file-name [extension]"

[drive-name]Specify the drive-name by a single character from A to Z. Whenthe drive-name is omitted, the current drive will be used.

[path-name]

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 708/783

Specify the directory storing the file in the following format:

[\][directory-name [\ directory-name] ...]\

When the path-name is omitted, the file will be placed in thedirectory specified by compile option LIB. When compiling from

686 Appendix G. Writing Special Literals

the WINCOB window, the source file to be compiled is stored inthe current directory. When the relativity path-name is specified,the current directory is added to the front.

[File-name]

Specify the file-name.

[extension]

Specify the file extension if possible. Note: "CBL" and "COB" maynot be used. For example:

• "C:\COPY\A.CBL"

• "A.CPY"

• "C:\COPY\A"

File-Identifier Literal

For the file-identifier literal to be written in the ASSIGN clause ofthe file control entry, specify the file to be processed in thefollowing manner:

[drive-name]

Specify a drive name with an alphabetic character from A to Z. A

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 709/783

name not specified with an alphabetic character from A to Z isregarded as a port name. When the drive name is omitted, the

current drive will be used.

Appendix G. Writing Special Literals 687

[port-name]

A port name can be specified for sequential files only. If a portname is specified, specification of a path name and file-reference-

name is invalid.To specify a printer with a port name, use port name LPT1,LPT2, or LPT3.

[path-name]

Specify the directory storing the file in the following format:

 [\][directory-name[\directory-name] ...]\

If a path name is omitted the current directory is used.

[file-name]

Specify a file name.

[extension]

Specify any character string for identifying the type of the file.For example:

• "A:\COBOL\A.DAT"

• "LPT1:"

• "B.TXT"

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 710/783

688 Appendix G. Writing Special Literals

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 711/783

Appendix H. High-Speed FileProcessing

Record sequential files and line sequential files can be accessedfaster by specifying an available range. This appendix explainsmethods of specification for high-speed file processing and noteson high-speed file processing.

Specification Methods

This section explains methods of specification for high-speed fileprocessing. The specification methods apply to both recordsequential files and line sequential files.

When defining a file-identifier as a file-reference-identifier in the

program, specify ",BSAM" following the file-name to be allocatedupon setting of environment variable information. Refer to“Environment Variables” in Chapter 5 for details on settingenvironment variables information.

file-identifier=[path-name]file-name,BSAM

When defining a data name as a file-reference-identifier in the

program, specify ",BSAM" following the file-name to be allocatedat definition of the data-name in the program.

MOVE "[path-name]file-name,BSAM" TO data-name.

When defining a file-identifier literal as a file-reference-identifier

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 712/783

gin the program, specify ",BSAM" following the file-name to beallocated at definition of the file-identifier literal in the program.

ASSIGN TO "[path-name]file-name,BSAM"

690   Appendix H. High-Speed File Processing

Notes

Records cannot be updated (REWRITE statement cannot beexecuted). If a record is updated, an error occurs duringexecution (Record sequential files only).

If files are shared and you want to permit file sharing amongdifferent processes, all files must be in shared mode and openedwith INPUT specified. Operation is not guaranteed if a file isopened without specifying INPUT. File sharing is not permittedin the same process. Operation is not guaranteed if a file is

shared with in the same process.High-speed file processing cannot be used if DISK is specified asthe file-reference-identifier.

If a record read from a line sequential file includes a tab, the tabcode is not replaced by a blank.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 713/783

Appendix I. GS-series FunctionComparison

Table 88 compares functions between the GS-series (M-series)and COBOL85 for Windows. Refer to Chapter 16, “DistributedDevelopment Support Functions” for a definition of GS-seriesterms.

The following symbols are used in the "Comparison" column of

Table 88:

A: Can be used in the same manner as the GS-series.

B: Can be used under given conditions in the same manneras the GS-series.

C: Cannot be used with the GS-series. (The function is

specific to this system or incompatible with the GS-series.)D: Compilation can be done, but the function is disabledduring execution.

E: Can be used, but the function works differently than whenit works with the GS-series.

F: Cannot be used with this system.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 714/783

692 Appendix I. Function Comparison

Table 88. Function comparison between the GS-series and this system

Function Classification Comparison Remarks

Classification Function outline

Character set All types ofcharacters that canbe used in theprogram

A

COBOL words User-definedword

All types of user-defined words

 A Use of theunderscore (_)character has aspecific

function in thissystem.Figurativeconstant

All figurativeconstants that canbe used in theprogram

 A

Special register SHIFT-IN,SHIFT-OUT, SORT-CORE-SIZE, SORT-

MESSAGE

 D

PROGRAM-STATUS, RETURN-CODE

 B The attributesare different.GS-series:S9(4)BINARYThis system:S9(9)COMP-5

Other than theabove

 A

Function name SYSPUNCH,STACKER-01 to 12,CSP,S01,S02SYSPCH,BUSHU,SOKAKU, ON-YOMI, KUN-YOMI

 D

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 715/783

SWITCH-8 CCHANNEL02 to12

 C02 to C12

 B The FCB

controlstatement mustbe specified.

Appendix I. Function Comparison 693

Table 88. Function comparison between the GS-series and this system (cont.)

Function Classification Comparison Remarks

Classification Function outline

COBOL words Function name Other than theabove

A

Literal National item literalNationalalphanumeric literalNationalassociation literalNational language

literal

 D

Hexadecimal literal Nationalhexadecimal literalNational codeliteral

 E Notedifferencesamong codes.

Other than theabove

 A

Others Specification of

quotation mark as aconstant

C GS-Series:

CompileoptionAPOST/QUOTE

is followedThis system:Automaticallydetermined.

Method ofwriting

program

Referenceformat

Sequence number A

Fixed format,variable format

 A

Data definition Datadescription

All clauses that canbe described in thedata descriptionentry

 A

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 716/783

entryData type COMP-5 C

Other than theabove  A

694 Appendix I. Function Comparison

Table 88. Function comparison between the GS-series and this system (cont.)

Function Classification Comparison Remarks

Classification Function outline

Expression Arithmeticexpression

Binary arithmeticoperator, unaryarithmetic operator

 A

Conditionalexpression

All relationaloperators that canbe used

 A

Linkageexpression

Use of linkageexpression

 C

Classcondition All class conditions that can be used  A

Otherconditions

Condition-namecondition, signcondition, switch-status condition

 A

Nucleus Environmentdefinition

SUBSCHEMA-NAME paragraph

B (16) Operation canbe checkedwith the

debugger.D (32)

Other than theabove

 A

Basicinstruction

All nucleus modulestatements

 A

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 717/783

Appendix I. Function Comparison 695

Table 88. Function comparison between the GS-series and this system (cont.)

Function Classification Comparison Remarks

Classification Function outline

Sequential file Environmentdefinition

APPLY WRITE-ONLY clauseMULTIPLE FILETAPE clauseRERUN clausePASSWORD clauseRESERVE AREAclause

 D

Data namespecified in the ASSIGNclauseDISK specified inthe ASSIGN clausePRINTER specifiedin the ASSIGNclause

LOCK MODEclause

 C

Other than theabove

 A

File definition CODE-SET clause D

BLOCKCONTAINS clause

 B No functionalmeaning forthis system.

The programthat wasoperating withthe GS-seriesoperates asbefore.

Other than the A

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 718/783

Other than theabove

 A

696 Appendix I. Function Comparison

Table 88. Function comparison between the GS-series and this system (cont.)

Function Classification Comparison Remarks

Classification Function outline

Sequential file Input-outputstatement

WITH LOCKspecified in aninput-outputstatementUNLOCKstatement

 C

Other than theabove

 A

Line sequential file All C

Relative file Environmentdefinition

PASSWORD clause RERUN clause

 D

Data namespecified in the ASSIGNclauseDISK specified in

the ASSIGN clauseLOCK MODEclause

 C

Other than theabove

 A

File definition CODE-SET clause D

BLOCKCONTAINS clause

 B No functionalmeaning forthis system.The programthat was

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 719/783

that wasoperating with

the GS-seriesoperates asbefore.

Appendix I. Function Comparison 697

Table 88. Function comparison between the GS-series and this system (cont.)

Function Classification Comparison Remarks

Classification Function outline

Relative file File definition Other than theabove

 A

Input-outputstatement

WITH LOCKspecified in aninput-outputstatementUNLOCKstatement

 C

Other than theabove  A

Indexed file Environmentdefinition

PASSWORD clauseRERUN clause

 D

Data namespecifiedin the ASSIGNclauseDISK specified in

the ASSIGN clauseLOCK MODEclause

 C

Permission to forma single key withmultiple data items

 B Can be usedwith thissystem undergiven

conditions.Other than theabove

 A

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 720/783

698 Appendix I. Function Comparison

Table 88. Function comparison between the GS-series and this system (cont.)

Function Classification Comparison Remarks

Classification Function outline

Indexed file File definition CODE-SET clause DBLOCKCONTAINS clause

 B No functionalmeaning forthis system.The programthat wasoperating withthe GS-seriesoperates asbefore.

Other than theabove

 A

Input-outputstatement

WITH LOCKspecified in aninput-outputstatementUNLOCK

statement

 C

POSITIONINGPOINTER specifiedin the STARTstatement

 F

Other than theabove

 A

Sort-merge Mnemonicname

BUSHU,SOKAKU,ON-YOMI,KUN-YOMI

 D

Special register SORT-CORE-SIZE,SORT-MESSAGE

 D

Other than theabove

 A

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 721/783

Others All A

Appendix I. Function Comparison 699

Table 88. Function comparison between the GS-series and this system (cont.)

Function Classification Comparison Remarks

Classification Function outline

Inter-programcommunication

PROCEDUREDIVISION

WITH specification C

CALLstatement

BY VALUEspecification

 C

WITH specification COther than theabove

 A

Others All A

Source textmanipulation COPYstatement OF/IN SYSDBDCTspecification  F

OF/IN XMDLIBand XFDLIBspecification

 C

Library text nameliteral

 C

 JOININGspecification only

 C

Report writerfeature

File definition BLOCKCONTAINS clauseCODE clause

 D

Other than theabove

 A

Others All A

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 722/783

700 Appendix I. Function Comparison

Table 88. Function comparison between the GS-series and this system (cont.)

Function Classification Comparison Remarks

Classification Function outline

Presentationfile

Environmentdefinition

APL, CMD, TRM,or WST specified inthe SYMBOLICDESTINATIONclause

 B (16) Operation canbe checkedwith thedebugger.

 D (32)APPLYMULTICONVERSA

TION-MODEclause

 D

PROCESSINGTIME clause

 C

DESTINATIONCONTROL clause

 D

MESSAGESEQUENCE clause

 D

MESSAGE CODEclause (not 4bytes)

 D

Other than theabove

 A

File definition All AInput-outputstatement

All A

Special register All ADebugging functions All D Compilation

only if usedwith the GS-series

Segmentation All D Compilationonly if usedwith the GS-

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 723/783

series

Appendix I. Function Comparison 701

Table 88. Function comparison between the GS-series and this system (cont.)

Function Classification Comparison Remarks

Classification Function outline

Communication All DExtension System control All D

Networkdatabase

All B (16) Operation canbe checkedwith thedebugger.

 D (32)

AIM/RDB All FSD function All ABuilt-in function All CScreen handling All CCommand line argumenthandling and environmentvariable handling

All C

Checking Program Operation

Programs created in common function scope can be checkedunder this system. Some functions may cause program executionmethods and execution results to differ between systems.

When operating a program using the inter-program

communication function, if the program is activated through asystem, the method of specifying the parameters to be passed tothe program is different.

To pass parameters in the global server system format under thissystem, use the initialization file (COBOL85.CBR) or Run-timeEnvironment Setup window to specify the parameters. Refer to“ f ” h f

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 724/783

“Setting Run-time Environment Information” in Chapter 5 for

the method of specifying the global server system formatparameters in the initialization file (COBOL85.CBR) and the Run-time Environment Setup window.

702 Appendix I. Function Comparison

For example, a COBOL program description is as follows:

If a program uses a function specific to the GS-series, specialprocessing is required for operating the program under thissystem.

To substitute another resource and operate a program using thecommunication function, execute input-output statements for the

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 725/783

p psequential file. Check the contents of the sequential file todetermine whether the program operates as expected.

Appendix I. Function Comparison 703

If skipping a non-executable statement by using an interactivedebugger, and the file to be processed or the subprogram doesnot exist, use the interactive debugger to skip input-output andCALL statements. For details on how to use the interactive

debugger, see the “Fujitsu COBOL Debugging Guide.”

Notes

If a hexadecimal non-numeric literal and national hexadecimalnonnumeric literal are used in the program, take the code intoconsideration.

If the presentation file function is used, the expansion format of apresentation file record fetched from a screen and formdescriptors (this system) or format descriptor (GS-series) isdifferent when the COBOL source program is compiled.

If a function name (CHANNEL02 to CHANNEL12, or C02 toC12) is used, the FCB control statement is required. The FCBcontrol statement format used with the global server ADJUST isalso used under this system.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 726/783

704 Appendix I. Function Comparison

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 727/783

Appendix J. Command Formats

This appendix explains compiler commands and linkercommands.

The command formats differ between Windows 95/WindowsNT and Windows 3.1.

Compiler Commands

Use the compiler commands to compile a COBOL sourceprogram and to generate an object program.

For details on generated files and files required for compilercommand execution, refer to “Resources Necessary forCompilation” in Chapter 3. For compiler command specifiedlocation and basic usage, refer to “Using Commands to Compile”

also in Chapter 3.

The following are compiler commands:

• (16): COBOL command

• (32): COBOL command, or COBOL32 command

Input FormatCommand OperandCOBOLCOBOL32 (32)

[option-list] file-name …[option-list] file-name …

Operands

At least one space is needed between the command name andeach operand Items enclosed in "[" and "]" can be omitted An

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 728/783

each operand. Items enclosed in [ and ] can be omitted. An

absolute or relative path name can be specified for a directoryname and file name in the explanation below.

706 Appendix J. Command Formats

[option-list]

Specify the information to be posted to the COBOL85 compiler.See Table 88 for the specification.

The following shows the priority determined by the optionspecification methods:

1. Using the compiler directing statement in the source file(Refer to “Compiler Directing Statement” in Chapter 2)

2. Using the -WC option (See Table 88)

3. Using an option other than the -WC option (See Table 88)

4. Using the option file (See Table 88)

5. Using the environment variable (32) (Refer to “Setting UpEnvironment Variables” in Chapter 1)

[file-name]

Specify the name of the source file to be compiled. One or more

file names can be specified.

Table 89. Compiler command options

Specification Specification Format

Directory of library files [-I directory-name]

Directory of screen and form descriptor files [-m directory-name]

Directory of file descriptor files [-f directory-name]

Whether to output a compiler listing file, and the outputdestination file name

 [-P file-name]

Directory of a compiler listing file [-dp directory-name]

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 729/783

Use of the TRACE function [-Dr]Use of the CHECK function [-Dk]

 Appendix J. Command Formats 707

Table 89. Compiler command options (cont.)

Specification Specification Format

Use of an interactive debugger [-Dt]

Directory of a debugging information file [-dd directory-name]Directory of an object file [-do directory-name]Compilation of main program [-M]Global optimization [-O]Option file [-i file-name]Directory of a SUBSCHEMA definition file (16) [-A directory-name]Compiler option [-WC,"compiler-option"]

No space is needed before file-name or directory-name in the

specification format.

 [-I directory-name]

If the library function (COPY statement) is used, specify thedirectory of libraries. If libraries exist in more than one directory,specify the -I option more than once. The directories are searchedfor in the order they were specified.

A COPY statement with IN/OF specified is ignored.

Note: The -I option functions the same as compiler option LIB.For further information, refer to Appendix A, “CompilerOptions.”

[-m directory-name]

If the COPY statement with IN/OF XMDLIB specified is used forfetching a record definition from screen and form descriptors,specify the directory of the screen and form descriptor file. Ifscreen and form descriptor file exists in more than one directory,specify the -m option more than once. The directories aresearched for in the order specified.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 730/783

708 Appendix J. Command Formats

Note: The -m option functions the same as compiler optionFORMLIB. For further information, refer to Appendix A,“Compiler Options.”

[-f directory-name]

If the COPY statement with IN/OF XFDLIB specified is used forfetching a record definition from file descriptor, specify thedirectory of the file descriptor file. If file descriptor file exists inmore than one directory, specify the -f option more than once.The directories are searched for in the order specified.

Note: The -f option functions the same as the compiler option

FILELIB. For further information, refer to Appendix A,“Compiler Options.”

[-P file-name]

Determine whether to output a compiler listing file, and specifythe file name. If the file name is not specified, the file is output tothe directory of the source file.

If the -P option is specified with the -dp option, the file linkedwith the directory specified in the -dp option is the finalcompilation list file. Do not specify an absolute path name forfile-name.

[-dp directory-name]

A compiler listing file is usually under the directory of the sourcefile. Specify the -dp option to define a new directory for thecompilation list file.

Note: The -dp option functions the same as compiler optionPRINT. For further information, refer to Appendix A, “CompilerOptions.”

[-Dr]

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 731/783

[ ]

Specify the -Dr option to use the TRACE function.

 Appendix J. Command Formats 709

For details on using the TRACE function, refer to the “FujitsuCOBOL Debugging Guide.”

If the -Dr option is specified, processing for displaying traceinformation is incorporated into the object program.

Consequently, execution performance lowers. When the debugfunction terminates, recompile the program without the -Droption specified.

Note: The -Dr option functions the same as compiler optionTRACE. For further information, refer to Appendix A, “CompilerOptions.”

[-Dk]To use the CHECK function, specify the -Dk option.

For details on using the CHECK function, refer to the “FujitsuCOBOL Debugging Guide.”

If the -Dk option is specified, processing for checking subscripts,indexes, and reference modification is incorporated into the

object program. Consequently, execution performance isdegraded. When the debug function terminates, recompile theprogram without the -Dk option specified.

Note: The -Dk option functions the same as compiler optionCHECK. For further information, refer to Appendix A,“Compiler Options.”

[-Dt]

Specify the -Dt option to use an interactive debugger.

Note: The -Dt option functions the same as the compiler optionTEST. For further information, refer to Appendix A, “CompilerOptions” and the “Fujitsu COBOL Debugging Guide.”

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 732/783

710 Appendix J. Command Formats

[-dd directory-name]

Specify a directory of a debug information file. If the -dd optionis not specified, the debug information file is created in thedirectory of the source file.

The -dd option is effective only when it is specified with the -Dtoption or the TEST compiler option.

[-do directory-name]

Specify a directory for storing an object file. If the -do option isnot specified, the object file is created in the directory of the

source file.[-M]

Specify the -M option to compile a COBOL program serving asthe main program for execution.

Note: The -M option functions the same as compiler optionMAIN. For further information, refer to Appendix A, “Compiler

Options.”[-O]

Specify the -O option to create a globally optimized objectprogram.

Note: The -O option functions the same as compiler optionOPTIMIZE. For further information, refer to Appendix A,

“Compiler Options” and Appendix C, “Global Optimization.”

[-i file-name]

If a compiler option is specified in an option file (storingcharacter strings as compiler options), specify the name of theoption file. An option file can be created by selecting items fromthe list box using the WINCOB command.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 733/783

The following example shows the WINCOB commandspecification format for creating an option file:

 Appendix J. Command Formats 711

WINCOB -i path-name-of-option-file

[-A directory-name] (16)

Specify the directory of the SUBSCHEMA definition file which is

specified in the SUBSCHEMA-NAME paragraph. If aSUBSCHEMA definition file exists in more than one directory,specify the -A option more than once. The directories aresearched for in the order they were specified.

Note: The -A option functions the same as compiler optionAIMLIB. For further information, refer to Appendix A,“Compiler Options.”

[-WC,"compiler-option"]

Specify a compiler option for the COBOL85 compiler. Forcompiler options and their specification formats, refer toAppendix A, “Compiler Options.”

More than one compiler option can be specified. The specified

compiler options must be separated by a comma. If the samecompiler option is specified more than once, the compiler optionspecified last is effective.

The priority level of compiler instructions is as follows:

• Compiler option specified by compiler instruction statementin source program.

• Compiler option specified by the -WC option of theCOBOL32 command.

• Option specified for the COBOL32 command.

• Compiler option in the option file specified by -I option ofCOBOL32 command.

Do not specify the following options in the -WC option:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 734/783

p y g p p

AIMLIB, FILEEXT, FILELIB, FORMEXT, FORMLIB, LIB, OBJECT, PRINT, TEST

712 Appendix J. Command Formats

Linker Commands

Use the linker commands to link a program and generate anexecutable program.

For details on generated files and required files for linkcommand execution, refer to “Resources Required for Linking”in Chapter 4. For linker command specified location and basicusage, refer to “Using Commands to Link” in Chapter 4.

The following are linker commands:

• (16): LINK command, LIB command, IMPLIB command

• (32): LINK command, LIB command

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 735/783

 Appendix J. Command Formats 713

LINK Command (16)

This section explains the LINK command for Windows 3.1.

Input FormatCommand OperandLINK (16) [option-list] file-name-list

Operands

At least one space is needed between the command name andeach operand. Items enclosed in "[" and "]" can be omitted. Anabsolute or relative path name can be specified for a directoryname and file name in the explanation below.

[option-list]

Specify LINK command options. See Table 89 for thespecification.

[file-name-list]File names can be specified following the option list. Thefollowing shows the specification format:

object-file-name,[output-file-name],[map-file-name],[library-name],module-definition-file

[object-file-name]

Specify one or more object files to be linked. The specified objectfile names must be separated by a space or plus sign (+). Thedefault file name extension is OBJ.

[output-file-name]

Specify an executable file or DLL. If an executable file is specified,the default file name extent is EXE. If DLL is specified, the

d f l f l

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 736/783

default file name extension is DLL.

714 Appendix J. Command Formats

[map-file-name]

Specify a map file. The default file name extension is MAP.

[library-name]

Specify a standard (object code) library or import library. If astandard object library is specified, only the object modulerequired for external reference is linked.

[module-definition-file-name]

Specify a module definition file. The default file name extensionis DEF.

Table 90. LINK command options (16)

Specification Specification FormatPrepares for debugger option [/CO]Restricts the linker to use only standard libraries [/NOD]Disables the library extended dictionary. [/NOE]Outputs a list of public symbols to the map file. [/M]

For details on the above options, refer to “Setting LinkerOptions” in Chapter 4.

LIB Command (16)

This section explains the LIB command for Windows 3.1.

The LIB command does the following:

• Creates library files

• Deletes, adds, and replaces library modules

• Copies and moves one module from the library to another file

• Outputs library modules to the public symbol list

F d t il t d fil d fil f LIB d

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 737/783

For details on generated files and files for LIB commandexecution, refer to “Resources Required for Linking” in Chapter4.

 Appendix J. Command Formats 715

Input FormatCommand OperandLIB (16) library-name [option-list][command][,[list-output-

destination] [, [new-library-name]]][;]

Operands

At least one space is needed between the command name andeach operand. Items enclosed in "[" and "]" can be omitted. Anabsolute or relative path name can be specified for a directoryname and file name in the explanation below.

[library-name]

Specify the library to be processed. The default file nameextension is LIB.

[option-list]

Specify the information to be posted to the LIB command. For thespecification, see Table 90.

[command]

Specify the file to be processed following the command symbol.By specifying the file name, the contents of the library specifiedfor library-name can be changed, a new library can be created,and one module can be copied or moved from the library toanother file. For the command symbols and the files to be

specified, see Table 91.[list-output-destination]

The following information is output to the file specified for list-output-destination:

• Public symbol lists in the library (in alphabetical order)

• Module lists in the library

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 738/783

716 Appendix J. Command Formats

[new-library-name]

Specify new-library-name to save a library as another librarywhen the library contents are changed. If a new library is notspecified, the contents of the current library are updated. The

original contents are saved in a file with which the current libraryname extension is changed to BAK.

Table 91. LIB command options (16)

Specification SpecificationFormat

Changing or setting a library page size [/PAGESIZE:n]Whether to distinguish uppercase letters fromlowercase letters

  [/N | /I]

[/PAGESIZE:n]

For n, specify a value (16 to 32, or 768) raised to the power of 2.The default page size of a new library is 16 bytes.

[/N | /I]

Specify /N to distinguish uppercase letters from lowercaseletters. Otherwise, specify /I. The default is /I.

If a library is created with /N specified, a mark is given to thelibrary indicating creation with /N specified. If any of thelibraries to be linked was created with /N specified, the outputlibrary is treated as a library created with /N specified.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 739/783

 Appendix J. Command Formats 717

Table 92. Command symbols

Symbol Explanation File Specified+ Addition of

module Specify name of the object file to be added. The object filename extension OBJ can be omitted.

 Linkage of library Specify the library file to be linked. The library file nameextension LIB must be specified.- Deletion of

module Specify name of the object module to be deleted. A path orextension cannot be assigned to the object module name.

-+ Replacement ofmodule

 Specify name of the object module to be replaced. A pathor extension cannot be assigned to the object module name.To replace a module, the object file name extension must beOBJ and the file must be in the current directory.

* Module copy to

another file

 Specify name of the object module to be copied. The copy

destination file is created in the current directory. Thename of the copy destination file is the object module namewith extension OBJ added.

-*  Module move toanother file

 Specify name of the object module to be moved. The movedestination file is created in the current directory. Thename of the move destination file is the object modulename with extension OBJ added.

Press the CTRL and C keys together to cancel LIB command

processing.

IMPLIB Command (16)

This section explains the IMPLIB command of Windows 3.1.

Use the IMPLIB command to create import libraries.

For import libraries, refer to “Resources Required for Linking” inChapter 4.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 740/783

718 Appendix J. Command Formats

Input FormatCommand OperandIMPLIB (16) import-library-name module-definition-file-name | dll-name

OperandsAt least one space is required between the command name andthe operand.

import-library-name

Specify name of the import library to be created.

module-definition-file-name or dll-name

Specify a module definition file for a DLL or the DLL name. Animport library is created according to the contents of the moduledefinition file for a DLL specified here.

LINK Command (32)

This section explains the LINK command for the Windows 95and Windows NT version.

Input FormatCommand OperandLINK (32) file-name-list [option-list]

OperandsAt least one space is needed between the command name andeach operand. Items enclosed in "[" and "]" can be omitted. Anabsolute or relative path name can be specified for a directoryname and file name in the explanation below.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 741/783

 Appendix J. Command Formats 719

[file-name-list]

The following shows the specification format:

object-file-name library-name

[object-file-name]

Specify one or more object files to be linked. The specified objectfile names must be separated by a blank or tab.

[library-name]

Specify a standard (object code) library, import library, or exportfile. If a standard object library is specified, only the objectmodule required for external reference is linked.

The following files must be specified:

• COBOL import library

• LIBC.LIB,KERNEL32.LIB,USER32.LIB

[option-list]

Specify LINK command options. For the specification, see Table93.

Table 93. LINK command options (32)

Specification Specification FormatDefault base address of the executable file or DLL /BASE:addressPreparing for use of the COBOL85 interactive debugger /DEBUG

/DEBUGTYPE:COFF(For linkage with C language using Visual C++) /DEBUGTYPE:BOTHCreating a dynamic link library (DLL) /DLLProgram execution entry point /ENTRY:symbolName of the output main file /OUT:filename

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 742/783

720 Appendix J. Command Formats

LIB Command (32)

This section explains the LIB command for Windows 95 andWindows NT.

Use the LIB command to create a standard library or importlibrary.

For details on generated files and files for LIB commandexecution, refer to “Resources Required for Linking” in Chapter4.

Input Format When Creating a Library FileCommand OperandLIB (32) file-name-list [option-list]

Operands

At least one space is needed between the command name andeach operand. Items enclosed in "[" and "]" can be omitted. An

absolute or relative path name can be specified for a directoryname and file name in the explanation below.

[file-name-list]

Specify one or more object files. Existing libraries can also bespecified.

[option-list]Specify the information to be posted to the LIB command. For thespecification, see Table 93.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 743/783

 Appendix J. Command Formats 721

Input Format When Creating an Import LibraryCommand OperandLIB (32) /DEF:module-definition-file-name

/MACHINE:IX86/OUT:import-library-name[option-list] object-file-name-list

Operands

At least one space is needed between the command name andeach operand. Items enclosed in "[" and "]" can be omitted. Anabsolute or relative path name can be specified for a directoryname and file name in the explanation below.

[/DEF:]

The /DEF option specifies a module definition file for creating animport library. Specify the module definition file following thecolon (:).

[/MACHINE:]

The /MACHINE option specifies the type of the CPU thatexecutes the program.

[/OUT:]

The /OUT option specifies the import library to be created.

[option-list]

Specify the information to be posted to the LIB command. For thespecification, see Table 93.

[object-file-name-list]

Specify the object file for creating an import library.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 744/783

722 Appendix J. Command Formats

Table 94. LIB command options (32)

Specification Specification FormatCopying a specified object member from a specified library

 /EXTRACT:object-member-name

Deleting a specified object member from a specified library

 /REMOVE:object-member-name

Press the CTRL and C keys together to cancel LIB commandprocessing.

When an import library is created, an export file is created underthe import library name with the extension LIB changed to EXP.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 745/783

Appendix K. FCB ControlStatement

The following shows the specification format of the FCB controlstatement:

• LPI information

LPI information can be sequentially specified in format of(line-spacing, line-count) from the top of the page. Specify 6,8, or 12 (lpi) for line spacing.

• CH information

Specify a line number for CHANNEL-01 to CHANNEL-12.Channel number 1 identifies the first line that can be printed.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 746/783

724 Appendix K. FCB Control Statement

• SIZE information

Specify the length of paper in units of 1/10 inch. The defaultis 110 (11 inches).

FORM informationSpecify paper in fixed size. If a fixed size is specified, thelength of the paper is uniquely determined for PORT(portrait) or LAND (landscape).

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 747/783

Appendix L. Indexed FileRecovery

This appendix explains the indexed file recovery function andindexed file simple recovery function.

Indexed File Recovery Function

Function

The indexed file recovery function refreshes normal sectionsfrom the beginning of the file, and outputs abnormal sections toanother file. This allows you to recover an unusable indexed file(unusable because it was not closed normally).

The indexed file recovery function works the same as theRecovery command of the COBOL85 FILE UTILITY.

If an indexed file in the unusable state is opened, 90 is returnedas the I-O status.

Coding Format

#include "f1bcfutc.h" /* function-declaration (16) */#include "f3bifutc.h" /* function-declaration (32) */signed long int CFURCOV( char far*ixdfilename,

 char far *blkdatname,  char far *message);

• [ixdfilename]

Name of the file to be recovered

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 748/783

726 Appendix L. Indexed File Recovery

• [blkdatname]

Name of the file containing data which could not berecovered

• [message]

Area storing the execution result (message) of the indexed filerecovery function

CFURCOV Function

The following are explanations of the parameters of this function.

[ixdfilename]Specify the address of the area storing the name (character string)of the indexed file to be recovered. The character string must endwith a NULL (0x00) or blank (0x20).

[blkdatname]

Specify the address of the area storing the name (character string)

of the file where unrecoverable records are written. The characterstring must end with a NULL (0x00) or blank (0x20). Specify 0 ifa file for writing unrecoverable records is unnecessary.

[message]

Specify the address of the area storing a message that indicatesthe execution result of the indexed file recovery function.

Allocate the storage area to the calling source (512 bytesrequired). Specify 0 if a message is unnecessary.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 749/783

 Appendix L. Indexed File Recovery 727

Return Value

The code corresponding to the message is returned as theexecution result of the indexed file recovery function. See Table94 for codes and messages.

The following is an example how to use the indexed file recoveryfunction (with Windows 95 and Windows NT) (32):

#include "f3bifutc.h"void callcobfrcov(void){

char ixdfilename[512] = "c:\\ixdfile\0";char blkdatname[512] = "c:\\blkdat\0";

  char message[512];CFURCOV(ixdfilename,blkdatname,message);  return;}

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 750/783

728 Appendix L. Indexed File Recovery

Indexed File Simple Recovery Function

Function

Resets flags in an indexed file in unusable state so that the file isenabled. Unlike the indexed file recovery function, the indexedfile simple recovery function does not recover abnormal sectionsin the indexed file. Consequently, access to the indexed file afterflag reset can result in an error because of conflicting data.

If an indexed file in the unusable state is opened, 90 is returnedas the I-O status.

Coding Format

#include "f1bcfutc.h" /* function-declaration (16) */#include "f3bifutc.h" /* function-declaration (32) */

signed long int CFURCOVS( char far*ixdfilename, char far *message);

• ixdfilename

Name of the file to be recovered

• message

Area storing the execution result (message) of the indexed filesimple recovery function

CFURCOVS Function

The following are explanations of the parameters of this function.

ixdfilename

Specify the address of the area storing the name (character string)of the indexed file to be recovered. The character string must end

ith NULL (0 00) bl k (0 20)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 751/783

with a NULL (0x00) or blank (0x20).

 Appendix L. Indexed File Recovery 729

message

Specify the address of the area storing a message that indicatesthe execution result of the indexed file simple recovery function.Allocate the storage area to the calling source (512 bytes

required). Specify 0 if a message is unnecessary.

Return Value

The code corresponding to the message is returned as theexecution result of the indexed file simple recovery function. Forcodes and messages, see Table 94.

The following is an example of how to use the indexed filesimple recovery function (with Windows NT) (32):

#include "f3bifutc.h"void callcobfrcovs(void){

char ixdfilename[512] = "c:\\ixdfile\0";char message[512];CFURCOVS(ixdfilename,message);return;

}

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 752/783

730 Appendix L. Indexed File Recovery

Notes

At creation, include the following files for calling from a C

program:• (16): f1bcfutc.h

• (32): f3bifutc.h

At compilation, for calling from a C program, refer to“Compiling Programs” in Chapter 10.

At linkage, use the LINK command to link the following files:• (16): f1bcfutc.lib

• (32): f3bifutc.lib

For calling from a C program, refer to “Linking Programs” inChapter 10.

At execution, set up the following environment:• Before starting Windows, execute the SHARE command. (16)

• Specify the directory storing the following files for the PATHenvironment variable:

− (16): f1bcfutc.dll, f1bcfute.dll, f1bcfrm.dll

(32): f3bifutc.dll, f3bifute.dll, f3bifrm.dll

Examples of Calling from COBOL

This section shows examples of programs that perform recoveryprocessing according to the open status.

The following example calls the indexed file recovery functionwhen a file for storing unrecoverable data and a message areunnecessary:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 753/783

unnecessary:

 Appendix L. Indexed File Recovery 731

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 754/783

732 Appendix L. Indexed File Recovery

The following example calls the indexed file recovery functionwhen a file for storing unrecoverable data and a message arenecessary:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 755/783

 Appendix L. Indexed File Recovery 733

Codes and Messages

Table 95. Codes and messages returned by the indexed file recovery function (and

simple recovery function)Code(Decimal) Message0 n Records were restored. (*1)1 There was n records which were not able to be restored. (*2)10 Recovery file not found.11 Recovery file not the indexed file.12 Could not access recovery file.13 Sequential file exists. (*2)

14 Other process accessing the file.15 Other process recovering the file.16 Insufficient disk space. (*2)128 Insufficient memory space.129 Not DOS 3.1 or later.130 Not share mode.(DOS SHARE command unload.)131 Record in recovery file not found. (*2)132 Contradiction in the file information.

*1 The simple recovery function does not return the message.*2 The simple recovery function does not return the code and message.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 756/783

734 Appendix L. Indexed File Recovery

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 757/783

Appendix M. Using Other FileSystems

This appendix explains how to use COBOL85 with the followingfile systems:

• Btrieve

• RDM

Btrieve File

A Btrieve file can also be used just like a file system as asequential file or indexed file supported by COBOL85.

The Btrieve file access function is supported within the scope offunctions supported by the COBOL file system. Btrieve-specificfunctions, however, are not supported.

This section explains how to use the Btrieve file with COBOL85.

For details on how to use the Btrieve file, refer to Btrievemanuals.

Specifying File Environment

Specify a file-reference-identifier in the ASSIGN clause of the filecontrol entry to determine whether to use the COBOL file systemor Btrieve Record Manager.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 758/783

736 Appendix M. Using Other File Systems

If a file-identifier literal is specified as the file-reference-identifier,specify the file-identifier literal in the following format:

FILE-NAME

Specify the file name or path name of the input-output target file.

NO-SPECIFICATION

The COBOL file system is used.BTRV

The Btrieve Record Manager is used.

If a data name is specified as the file-reference-identifier, use thefile-identifier literal format to specify the file where the dataname is specified.

If the character string DISK is specified as the file-reference-identifier, the Btrieve Record Manager cannot be used. TheCOBOL file system is used.

If a file-identifier is specified as the file-reference-identifier,specify the same data as specified in the file-identifier literalformat for the environment variable that defines the file-identifier

as the environment variable name.The environment variable specification format is:

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 759/783

 Appendix M. Using Other File Systems 737

Function Outline

For sequential files, indexed files, COBOL syntax, and basicusage, refer to the “COBOL85 Reference Manual.”

If the function is more enhanced than the COBOL file system, thekey item attributes in index files can be Alphanumeric characters,National characters, External decimal numbers, Internal decimalnumbers and Binary numbers.

Unlike the COBOL file system, the following restrictions areplaced on use of the Btrieve Record Manager:

• A relative file cannot be specified

• A data item which is part of a record key cannot be specifiedin the START statement

• DISK cannot be specified as the file-reference-identifier

• FILE STATUS = 02 cannot be returned

The following table shows the differences between limitations forthe COBOL file system (COBOL) and the Btrieve record manager(Btrieve).

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 760/783

738 Appendix M. Using Other File Systems

Table 96. COBOL File System and Btrieve Limits

Description COBOL BtrieveMaximum record length 32,760 4,090 (fixed length)

32,760 (variable length)Maximum number of data items specified in

the RECORD KEY clause

254 24 (16bits)

119 (32bits)Maximum length of all data items specified inthe RECORD KEY clause

254 255

Maximum number of data items specifiedin the ALTERNATE RECORD KEY clause

254 23 (16bits)118(32bits) *1

Maximum length of all data items specified inthe ALTERNATE RECORD KEY clause

254 255

*1 The total of the number of data items specified in the RECORD KEY clause and that

specified in the ALTERNATE RECORD KEY clause can be up to N (24 for 16bits and 119 for32bits). This value decreases as the number of data items specified in the RECORD KEYclause increases.

NOTES

A record key must be within an area of 1,024 bytes from thebeginning of the record (16).

A record key must be within an area of 4,088 bytes from thebeginning of the record (32).

The length of a fixed length record and the minimum length of avariable length record must be in the range 4 to 4,088 bytes. If avariable length record is used, the Btrieve Record Managerrequires 4 bytes for the overhead.

If a duplicated key (per item) is used, the Btrieve RecordManager requires 8 bytes for the overhead. The length of a fixedlength record and the minimum length of a variable lengthrecord are decreased by 4 or 8 bytes.

If a record with a file position indicator defined is deleted by theDELETE statement with random access, the file positionindicator is undefined.

Do not use the extension PRE for a file name to be accessed in anapplication. In order to use the pre-image function, do not access

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 761/783

 Appendix M. Using Other File Systems 739

multiple Btrieve files having identical names with extensions thatare unique within an application. The pre-image function fails todefine the pre-image file for files when multiple Btrieve files areaccessed.(16)

Up to 18 files for 16bit or 20 files for 32bit can be opened in theapplication at the same time.

To use NetWare Btrieve and client-format Btrieve (supported bythis product) together, rename client-format BtrieveWBTRCALL.DLL to WBTRLOCL.DLL. For details, refer to theBtrieve manuals.(16)

A Btrieve file created under NetWare 4.1J cannot be accessed.

To enable access to Btrieve files, specify "yes" to "Create BtrieveFiles in Pre v6.x Format" in the Btrieve setup utility. For details,refer to the Btrieve manuals.(16)

This product contains Btrieve Workstation Engine for WindowsNT/Windows 95 v6.15 (32) and Btrieve Workstation Engine forWindows NT/Windows 95 v6.10 (16).

For ERFLD=xx and FDBK=xx status codes (xx: hexadecimal),refer to the “BTRIEVE Programmer’s Manual” and the “Btrievefor Windows NT/Windows 95 Installation and Operation” byBtrieve Technologies, Inc..

External Decimal Data Form Conversion (32)

The internal form of this NUMERIC differs from COBOL85 andis called 88consortium. It is equivalent to the data type of anexternal decimal with the sign which is not SEPARATE inCOBOL from the NUMERIC type of Btrieve file (Refer to the“BTRIEVE Programmer’s Manual” for an internal form of theNUMERIC data type for Btrieve).

Therefore, a Btrieve file should be used and the data convertedinto each form as either an input or output data item before

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 762/783

740 Appendix M. Using Other File Systems

writing and after reading when an external decimal item with thenot SEPARATE sign is used.

This conversion can be done easily in COBOL85 by using aCALL statement.

Description Form (32)

Conversion from 88consortium to COBOL85 is as follows:

Call "#DEC88TOFJ" USING [BY REFERENCE] name

Conversion from COBOL85 to 88consortium is as follows:

Call "#DECFJTO88" USING [BY REFERENCE] name

Function Outline (32)

At "#DEC88TOFJ", the program name which is called by theCALL statement, will convert an internal form of an external

decimal item with the without all SEPARATE specificationincluded in the name or the name from 88consortium into aninternal form of COBOL85.

At "#DECFJTO88", the program name which is called by theCALL statement, will convert an internal form of an externaldecimal item with the without all SEPARATE specificationincluded in the name or the name from COBOL85 into an

internal form of 88consortium.

If the item is not an external decimal item, using the withoutSEPARATE specification will not perform a conversion.

When the name is a group item and the following items areincluded in the subordinate items, the item will not be converted:

Items other than external decimal items with the sign usingthe without SEPARATE specification.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 763/783

 Appendix M. Using Other File Systems 741

• Items subordinate to items which specify the REDEFINESclause as well as the item itself.

• Items which specify the RENAMES clause.

In the following cases, the execution results are not guaranteed.

• The program name called by a CALL statement is specifiedby the name and "#DEC88TOFJ" or "DECFJTO88" is specifiedby the name.

• "#DEC88TOFJ" or "DECFJTO88" is called by a form differentfrom the above-mentioned description form (Two or morenames are specified for USING phrase, BY CONTENT phrase

is specified.).

• The name is a group item and the item uses the OCCURSclause with DEPENDING specification in the subordinateitem.

• When data items are defined in the constant paragraph.

• Data items that refer the part, applies by the name, and isdone.

Notes (32)

Immediately before passing a record to a Btrieve file orimmediately after having received one, do this function call. The

external decimal number of 88consortium form of conversion byimmediately after having input from Btrieve file and thisfunction cannot be treated by COBOL.

“It is not possible to be treated by COBOL” means that theresults of ‘operates’, ‘compares’ or ‘post as external decimal item’are not guaranteed. The value of the external decimal of the88consortium form is guaranteed only in records containing the

external decimal item of the 88consortium form when the groupitem is posted to other records.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 764/783

742 Appendix M. Using Other File Systems

The sorting and merging function cannot be used for Btrievefiles.

Incorrect function calls will be called if an external reference errorof "#DECFJTO88" or "#DEC88TOFJ" occurs when linking.

Example (32)

*1:External decimal data which becomes the written data before writing in Btrieve file with all signs in“workarea” which are not SEPARATE is converted from COBOL85 form into 88consortium form.

*2 : External decimal data which before reading after reading of the record from Btrieve filewith all signs in “workarea” which are not SEPARATE is converted from 88consortiumform into COBOL85 form.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 765/783

 Appendix M. Using Other File Systems 743

RDM File

An RDM file can be used just like a file system as a sequentialfile, relative file, or indexed file supported by COBOL85. This

section explains how to use the RDM file with COBOL85.

Specifying File Environment

A file-reference-identifier specified in the ASSIGN clause of thefile control entry determines whether to use the COBOL filesystem or RDM file system.

If a file-identifier literal is specified as the file-reference-identifier,specify the file-identifier literal in the following format:

FILE-NAME

Specify the file name or path name of the input-output target file.

NO-SPECIFICATION

The COBOL file system is used.

RDM

The RDM file system is used.

If a data name is specified as the file-reference-identifier, use thefile-identifier literal format to specify the file with the data namespecified.

If the character string DISK is specified as the file-reference-identifier, the RDM file system cannot be used. The COBOL filesystem is used.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 766/783

744 Appendix M. Using Other File Systems

If a file-identifier is specified as the file-reference-identifier,specify the same data as specified in the file-identifier literalformat for the environment variable that defines the file-identifieras the environment variable name.

The environment variable specification format is:

To use the extended function of the RDM file, specify thefollowing environment variable in addition to the above

specification:

CRDB_XLIB_OVR = file-name,RDM,character-stringindicating-extended-function [:...]

Function Outline

If the function is more enhanced than COBOL file systemfunctions, check the key item attributes of indexed files(alphanumeric data item, national item, external decimal item,internal decimal item, binary item).

Unlike the COBOL file system, the following restrictions areplaced on use of then RDM file system:

• DISK cannot be specified as the file-reference-identifier• File sharing and exclusive use of records cannot be specified

in the program

• Variable length records cannot be used

• An optional file can be used in only input open mode. (Nofile creation)

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 767/783

 Appendix M. Using Other File Systems 745

The following table shows the differences between quantitativerestrictions for the COBOL file system (COBOL) and RDM filesystem (RDM).

Table 97. COBOL File System and RDM File System Limits

Description COBOL RDM Maximum number of data items specified in the RECORD KEYclause

254 128

 Maximum length of all data items specified in the RECORD KEYclause

254 255

 Maximum number of data items specified in the ALTERNATERECORD KEY clause

254 (*1) 128

 Maximum length of all data items specified in the ALTERNATERECORD KEY clause

254 255

*1 The total of the number of data items specified in the RECORD KEY clause and thatspecified in the ALTERNATE RECORD KEY clause can be up to 255. This value decreases asthe number of data items specified in the RECORD KEY clause increases.

If MANUAL is specified in the LOCK MODE clause, recordscannot be locked.

Execute "Relative File Creation" to use a relative file with aCOBOL program. Execute the OPEN statement with OUTPUTspecified to execute "Relative File Creation."

An error message is written or I-O status occurs indicating thatthe record does not exist (run-time error JMP0324I-I/U or FS=23)if the OPEN statement with I-O or EXTEND specified is used toopen a relative file without "Relative File Creation." The WRITEstatement is then executed.

If the disk size is insufficient, the following error message isoutput when the CLOSE statement is executed:

 JMP0310I-I/U CLOSE ERROR. FILE='file-name or access-name'.'ERFLD=1C'

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 768/783

746 Appendix M. Using Other File Systems

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 769/783

Appendix N. A COBOL-Supported Subroutine

This appendix explains a COBOL-supported subroutine.

Subroutine for Receiving the Window Handle

This subroutine receives the FORM RTS window handle when

linked with the presentation file edit function operating underWindows.

Specification Method

Data definition with Windows 3.1 (16):

01 data-name-1 PIC X(8).

01 data-name-2 PIC S9(4) COMP-5.

With Windows 95 and Windows NT (32):

 01 data-name-1 PIC X(8). 01 data-name-2 PIC S9(9) COMP-5.

Specification of the CALL statement:

CALL"JMPBGWDH" WITH C LINKAGE USING data-name-1  data-name-2

Interface

For data-name-1, specify the file-identifier of the presentation filefor receiving the window handle.

For data-name-2, specify the area for storing the window handlereceived by the subroutine.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 770/783

748 Appendix N. COBOL-Supported Subroutine

The presentation file specified for data-name-1 must be specifiedfor DSP in the SYMBOLIC DESTINATION clause and be opened.

Message

A message is written if:

• The file is not the presentation file

• The file does not exist

Return Codes

Special register PROGRAM-STATUS is used to receive returncodes from the subroutine.

• Return code 0: The window handle was received normally.

• Return code -1: The window handle could not be received.

Notes

This subroutine cannot be used under AP/EFW, or with thepresentation file module test function. (16)

The file-identifier specified for data-name-1 must correspond to asingle file in the run unit. If the file-identifier is associated with

multiple files, the execution result is not guaranteed.When the DLOAD option is specified at compilation of theCOBOL program that calls this subroutine, the following entryinformation must be specified as shown below.

 (16) (32)

  : :

 [program-name.ENTRY] [program-name.ENTRY]  JMPBGWDH=F1BCILNG.DLL JMPBGWDH=F3BIILNG.DLL  : :

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 771/783

 Appendix N. COBOL-Supported Subroutine 749

Refer to “Entry Information” in Chapter 5 for details onspecifying entry information.

Using the Subroutine from an Application

Figure 145. A sample application using the window handle subroutine

*1: The window handle acquired according to the window handle acquisitionsubroutine is notified of application B (Delivery of the data between processes).

*2: READ statement of the display file is executed and enters the state of thewaiting for input from the screen.

*3: The window handle notified from application A is specified for the functionof FORM RTS and the input interruption of the screen is ordered.

*4: The input completion is notified to interrupt the input waiting for the screenand to have been done to application A compulsorily. The input interruption isnotified of application B.

9E is notified of the I/O state value of READ sentence of thedisplay file and 9E5A is notified of detailed information.

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 772/783

750 Appendix N. COBOL-Supported Subroutine

Subroutine for Receiving the Instance Handle

The instance handle of the windows COBOL application can bereceived.

Specification Method

Data definition:

01 data-name02 data-name-1 PIC S9(9) COMP-5.02 FILLER PIC X(12).

Specification of the CALL statement:

CALL "JMPBWINS" WITH C LINKAGE USING data-name.

Interface

For data-name, specify the area for storing the instance handle

received by the subroutine. The instance handle is stored in data-name.

Notes

When the DLOAD option is specified for a compilation of theCOBOL program by which this subroutine is called, thefollowing entry information will be needed. Refer to Chapter 5,“Entry Information” for the method of specifying entryinformation.

[program-name.ENTRY] JMPBWINS=F3BIPRCT.DLL

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 773/783

Index

@

@AllFileExclusive, 134

@CBR_CIINF, 136

@CBR_ENTRYFILE, 136

@CBR_PSFILE_xxx, 136

@CnslBufLine, 133

@CnslFont, 134

@CnslWinSize, 132

@EnvSetWindow, 133

@GOPT, 131@IconDLL, 131

@IconName, 132

@MessOutFile, 132

@MGPRM, 131

@NoMessage, 137

@ODBC_Inf, 135

@PrinterFontName, 134

@ScrnFont, 134

@ScrnSize, 132

@WinCloseMsg, 133

A

ACCEPT statement

inputting data from a console window, 388

inputting data from a file, 394

ACCEPT statements, 384ACCEPT/DISPLAY function, 384, 386

using, 392

ACCESS MODE clause, 213

ADDR function, 422

using, 426

alternate keys, 195

alternate record keys, 223

area A, 17

area address, 365area B, 17

argument value

referring to, 399, 401

ARGUMENT-NUMBER, 399

argumentsobtaining number of, 399, 401

ARGUMENT-VALUE, 399

ASSIGN clause, 199, 200, 237

specifying a data name, 238

specifying a file identifier, 237

when writing character string, 239

when writing file-identifier literal, 239

AT END, 232

defined, 232

B

BASED ON clause, 425

BASED-STORAGE section, 424

 building, 170

BY CONTENT, 359

C

C programs

calling from COBOL programs, 364

call programs

referring to command line arguments, 399

CALL statement, 82, 149, 356

CALL statement., 371

called programs, 356calling programs

from COBOL programs, 356

 passing return code values, 360

calling relations, 354

CHARACTER TYPE, 309

CHARACTER TYPE clause, 271

chart record, 308

client, 450

client operation, 453client operation window, 473

client/server 

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 774/783

connecting, 505

disconnecting, 507

COBCI_CLOSE, 480, 484

COBCI_OPEN, 480, 482

COBCI_READ, 485

COBCI_READ/COBCI_WRITE, 480

COBCI_WRITE, 488

COBOL

 program descriptions for,, 387

reference format, 16

COBOL file

creating, 252

COBOL files

adding records to, 253

COBOL functions, 2

COBOL programscalling from C programs, 368

COBOL source program.

creating, 571

COBOL85

compiler, 3

development environment, 7

FILE UTILITY, 6

interactive debugger, 4

 programs, 3supported products, 10

utilities, 3

COBOL85 compiler, 560

functions, 3

COBOL85 debugger, 560

COBOL85 FILE UTILITY, 246, 247

execute commands, 247

functions, 251

using, 246COBOL85 FILE UTILITY.

environment set-up, 246

COBOL85 run-time system, 560

COBOL85 run-time system information file

(16), 303

COBPRTST command program file, 560

COBPRTST dialog box, 574

activating, 574

using, 577COBPRTST-Update dialog box

using with presentation file module test

function, 577

common program, 362

communication

input-output statements, 439, 448

record definition, 448

Communication System Environment Setup

dialog box, 454

communication, ACM, 441

compiler 

functions, 4

compiler directing statement, 20

description format, 20

CONNECT statement, 505

connecting

multiple servers, 507CONSOLE, 389

console window

generating, 386

console windows

changing attributes of, 386

reading/writing data using, 386

COPY statement, 18

Create Logical Destination dialog box, 456

creating a COBOL source program, 16CRT STATUS clause, 346

cursor 

operating with more than one connection,

533

D

data

correspondence between ODBC-handleddata and COBOL585-handled data, 548

deleting, 523

input/output destinations, 385

inserting, 523

updating, 522

data correspondence, 548

DATA DIVISION, 310

in print files, 281

data items

defining to deliver values, 400

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 775/783

defining, to store input data, 393

defining, to store output data, 393

data manipulation, 511

data sharing, 359

data types, 552

data, input-output

using ACCEPT/DISPLAY function, 384

database

compiling the program, 535

connection confirmation, 544

retrieving data, 514

retrieving data by relating different tables,

519

retrieving data from a single row, 518

retrieving data from a table where rows are

related, 521retrieving data from all rows, 514

sample, 512

database access

with an ODBC driver, 502

Database manipulation language (DML), 559

date and time

setting, 398

using ACCEPT statement, 398

default connection information, 541DELETE statement, 523

Dependent Files dialog box, 182

DISCONNECT statement., 507

disconnecting from a server, 507

DISPLAY statement, 392

outputting data to a console window, 388

outputting data to a file, 395

DISPLAY statements, 384

distributed development support functions,559

creating environment file, 572

required files for using presentation file

module test function, 569

required operation software and resources,

560

DS registers, 372

Dynamic access, 196, 213, 218, 219, 222

dynamic link libraries (DLL), 76dynamic link library (DLL)

creating, 85

dynamic link structure, 82

dynamic linkage, 81

dynamic parameters

specifying, 529

dynamic program structure, 82

dynamic SQL, 524

E

editor, 16

embedded SQL

operations, 504

embedded SQL DECLARE section, 515

embedded SQL keyword list, 545

embedded SQL statement

execution limits, 554embedded SQL statements, 552

notes on executing, 553

entry information, 147

entry information (32)

setting, 160

entry point, 357

 primary, 357

secondary, 357

ENTRY statement, 357environment variable

referring to value of, 404, 405

updating value of, 404, 405

environment variable information (32)

changing, 160

deleting, 160

environment variables

referring to and updating, 399

referring to and updating values of, 403setting, 8

setting from Command Prompt (32), 123

setting from Control Panel (32), 123

Windows 3.1, 8

Windows NT, 8

environment variables (32)

adding, 158

Environment Variables (Keywords) dialog

 box, 159environment variables handling function, 404

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 776/783

Environment Variables List dialog box (32),

158

ENVIRONMENT-NAME, 404

ENVIRONMENT-VALUE, 404

epilogue codes, 372

EQUALS, 413

Error procedures, 232

defined, 234

error, input-output, 232

detection methods, 232

execution results, 235

EXCLUSIVE, 240

exclusive mode, 240, 242

executable files, 75

executable program

creating, dynamic link structure, 86

creating, dynamic program structure, 88

creating, simple structure, 85

linking single object, 84

executable programs

executing with WINEXEC, 117

EXECUTE statement, 526

executing a subprogram, 357

executing application programs, 188

EXIT PROGRAM statement, 357EXPORTS, 186

EXTERNAL clause, 359

external program, 361

F

F option, 118

FCBxxxx, 146

FCOM, 566file access mode, 196

file control entry

contents to be written, 334

contents to be written in, 320

file control entry.

defining print file in, 294

File creation, 244, 252

file descriptor 

specifying storage location, 10File extension, 244, 253

File manipulation, 260

file organization

types and characteristics, 190

File organization conversion, 262

File print, 262

file processing, 196

results, 244

FILE STATUS, 232, 244

FILE STATUS clause, 233

File-identifier, 138, 139, 141, 142, 143, 144

file-reference-identifier, 199

file-reference-identifier., 310

files, assigning, 237

files, exclusive control of, 240

fixed format, 19

fixed length record, 195

FORM, 10, 277, 329

form control buffer (FCB), 276

form descriptors, 277

generating, used by presentation file

module, 318

FORM overlay option, 11

form overlay pattern, 275

 programs using, 302

form overlay patterns printer orders, 303

FORM RTS, 11

formatting source programs, 16

FORMLIB, 340

FOVLDIR, 147

FOVLTYPE, 147

free format, 20

FROM specification, 398

function keydefining, 350

using, when executing a program, 345

function-names

associating with mnemonic names, 400

G

GIVING output-file-name, 413, 418

GLOBAL clause, 363GS-series format run-time parameter, 126

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 777/783

H

HOPPER, 298

host program

executing, 562

linking, 562

host-specific functions

language construct, used as supportfunctions, 559

I

I control records, 295

import library, 76

 building under Windows NT, 94

creating, 89

INDEXED, 222

indexed file, 194

creating, 228

extending, 229

 processing, 226

record key, 195

Indexed file manipulation, 263

indexed files

required file definitions, 222using, 221

indicator area, 17

INITIAL clause, 362

initial program, 362

initial state, 362

initialization file, 123

creating, 536

modifying contents of, 125

section types, 124initialization file (32), 161

Input file, 412, 417

INPUT PROCEDURE, 412

Input-output processing

executing, 338

input-output statements, 215, 337

execution orders, 218

INSERT statement, 523

internal program, 361calling, 362

inter-program communication, 353

INVALID KEY, 232

defined, 233

item control field

input-output options, 319

options, 333

keys, record, 195

L

L option, 118

LENG function, 422

using, 426LIB, 184

library

 building, 100

creating, by linking, 89

entering object files, 100

Library Name edit box, 100

library text

creating, 18

line feed character, 17LINE SEQUENTIAL, 207

line sequential file, 192

 processing, 208

line sequential files, 206

LINK command, 102, 373

linkage rules

and supporting compilers, 356

differences of,, 355

linker messages, 105under Windows 3.1 (16), 107

Linker Options

under Windows NT (32), 95

linking

examples of, C programs that call COBOL

 programs, 377

host program, 562

object programs using commands, 101

required files, 71

starting, 97

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 778/783

through window operation, 84

under Windows 3.1 (16), 103

using WINLINK command, 84

linking C programs, 373

LOCK MODE clause, 240

Logging Operation dialog box, 463

logical destination

changing mode, 459creating, 456

deleting, 457

logical destination definition file creation

utility, 474

logs

collecting, 463

Mmaking, 170

memory, 478

merge, 408, 415

types, 417

MERGE statement, 418

message

sending, 392

message boxes, 390message communication, 432

message file, 6

message transfer, 449

messages

outputting to message boxes, 390

M-host, 125, 573

mnemonic-name, 271

module definition file, 185

applications, 80DLL, 80

formats, 79

required statements, 77

under Windows 3.1 (16), 78

under Windows NT (32), 76

module definition file (16)

creating, 186

module definition file (32)

creating, 185module definition statements, 78

under Windows NT (32), 77

multiple object programs, 81

 N

 NOALPHAL, 371

 NULL, 127

numeric data item, 427

O

object program, 3

ODBC (Open DataBase Connectivity),, 501

ODBC driver, 502, 552

ODBC environment

setup, 543ODBC information file

creating, 537

specifications, 543

ODBC Information Setup Tool, 536, 537

using, 542

operating environment

using the presentation file module with the

servers, 435

option file, 170ORGANIZATION, 200

Output file, 412, 418

OUTPUT PROCEDURE, 413

OUTPUT PROCEDURE output-procedure-

name, 418

OVD_SUFFIX, 147

overlay patterns, 11

P

 passing parameters, 358

from C programs to COBOL programs, 369

from COBOL programs to C programs, 365

PERFORM statement, 423, 428

PERFORM statement without an AT END

condition, 428

 pointer, 422

required data items, 423

using, 423

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 779/783

 pointer data item, 427

 pointer qualification, 424

 pointer qualifier, 424

Power FORM, 10

 presentation file, 436

features and uses, 328

in ENVIRONMENT DIVISION, 333

module test function, 6Presentation file function, 328

requirements, 331

 presentation file module, 432, 435, 443

data transfer, 435

environment setup, 440

requirements, 329

requirements to print forms, 317

using, 434

using connected products to enable

communication functions using, 435

using for screen input-output, 329

using screen descriptors, 329

using, for each COBOL division, 333

 presentation file module test function

using, 573

 presentation file module test function.

opreating environment, 568 prime keys, 195, 223

 print characters, 271

fonts of, 273

forms of, 273

size of, 272

spaces, 273

 print file, 192

defining, 279

defining in a file control entry, 309defining in file control entry, 281

ENVIRONMENT DIVISION, 280

executing a program that uses form

descriptors, 314

form descriptors used with, 314

 program descriptions, 280

required environments to execute a

 program, 314

using with FCB, 305 print files, 268

using, with form descriptors, 307

writing programs using form descriptors in,

308

 print format, 297

 print lines

control of, 283

 print side, 298

 printer 

assigning, 283input-output statement, 311

 printer information file

assigning, 310

assigning to file identifier specified in the

ASSIGN clause, 315

specified with a relative path name, 314

specifying a file-reference identifier, 310

 printer modes (orders), 304

 printer modes (orders):, 304

 printer programs, 287

PRINTERSEQUENCE, 303

 printing, 267

conrol records, 295

defining ENVIRONMENT DIVISION, 294

forms using form overlay patters, 293

 procedures, 299

using a presentation file, 271using a print file without a FORMAT

clause, 270

using form overlay pattern with a print file,

292

using print file with a FORMAT clause,

270

 printing data

in line mode, 278

 printing forms, 308required environments with presentation

file module, 324

using a presentation file, 315

using input-output statements, 322

using presentation file module, 316

with presentation file module, 323

 printing methods, 268

Program

executing using form overlay pattern andFCB, 302

executing with WINEXEC, 110

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 780/783

setting run-time environment information,

117

under Windows 3.1 (16), 117

 program development, 11

operating with GS, 556

PROGRAMMING-STAFF (P-STAFF), 5

Programs

executing from WINEXEC, 118writing, using screen handling function,

346

writing, when printing forms with

 presentation file modules, 319

PROGRAM-STATUS, 360, 369, 484

 project

 building or rebuilding, 187

 project file, 170

creating, 176

 project management

 procedures, 173

 project management function., 170

Project window, 175, 187

P-STAFF, 5

R, 296

Random access, 196, 213, 218, 219, 222

rebuilding, 170

Record browse, 256

RECORD clause, 201

Record edit, 258

Record reference, 244

record sequential file, 191

record sequential files, 198defining, 199

fixed length, 201

 processing, 202

variable length, 201

Record sort, 260

Record updating, deletion, and insertion, 244

records

deleting, 220, 231

inserting, 220, 231locking, 241

referring to, 219, 229

sorting, 411

updating, 219, 230

reference format

types, 19

registering files, 177

registering library files, 180

registering other required files, 182registering source files, 178

registering target files, 177

RELATIVE, 213

relative file, 193, 213

creating, 218

extending, 218

 processing, 215

relative files, 211

RELATIVE KEY clause, 214

relative record number, 214, 218

relative record numbers, 193

return codes, 366

ROLLBACK statement, 515

run-time environment information, 125

entry information, 119

environment variable information, 119

format, 129setting, 122

setting from command line, 125

under Windows NT and 95, 121

Run-time environment information (32)

setting, 158

Run-time Environment Setup window, 125

Run-time Environment Setup window (16),

162

Run-time Environment Setup window (32),155

run-time options, 128

format, 166

run-time system, 4

S

S control records, 295

screen descriptors

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 781/783

generating, used by presentation file

module, 332

information requirements, 332

Screen handling function, 328, 344

explanation, 343

screen handling functions

features and uses, 328

screen input-output, 328functions, 328

screen window, 344

work procedure of, with presentation file

module, 332

screen input-output processing

required environments, using presentation

file module, 341

screen input-output status, 346

values, 346

screen layout, 344

SCREEN section, 347

screen transition, 570

search conditions

specifying at execution, 524

SELECT clause, 200

SELECTED FUNCTION clause, 339

sequence number area, 17SEQUENTIAL, 200

Sequential access, 196, 213, 218, 219, 222

server 

quitting, 467

server information

defining, 538

server operation, 451

server windows

operating, 454SET CONNECTION statement, 507

setting compiler options, 183

setting the main program, 180

SHARE, 117

share mode, 242

SIA COBOL syntax, 555

simple structure, 81

simplified inter-application communication

error codes, 493simplified inter-application communication, 6,

449

client/server procedures, 451

functions, 480

using, 449

simplified inter-application communication

function, 432

Simplified Inter-application Communication

Server window, 456

displaying information, 461sort, 408

types, 411

sort processing, 414

SORT statement, 412

Sort-merge file, 412, 414, 417, 419

SORT-STATUS, 418

source program

creating, 16

reference format, 19

special registers

input-output, 339

SQL statements, 508

determining, dynamically, 526

SQLCODE, 550

SQLMSG, 550

SQLSTATE, 515, 550

SS registers, 372SSIN, 396

SSOUT, 396

stack checks, 372

static linkage, 81

STOP RUN statement, 357

subprograms

returning control from, 357

subschema name paragraph, 566

SYSERR, 391, 392SYSIN-access-name, 145

SYSOUT-access-name, 145

system program description (SD) functions,

421, 422

T

TAB character, 17

TERMINATOR, 146, 345TRANSACTION management statement, 559

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 782/783

Types of Input-Output Using Screens, 328

U

UPDATE statement, 522

UPON clause, 392

USE FOR DB-EXCEPTION statement, 560

USE FOR DEAD-LOCK statement, 560USE procedure, 567

USING clause, 365

USING input-file-name, 412

Using the Screen Handling Function, 343

UWA, 566

V

variable format, 19

variable length character string, 530

variable length character string data, 530

variable length record, 195

W

WINCOB, 6

window attributes

changing for screen handling, 345

window information file

generating, to perform input-output

 processing, 340WINEXEC, 6, 152

WINLINK, 6, 71, 90

files used by, 71

using, 68, 70

WINLINK [Building COBOL Libraries]

window, 98

WINLINK [Linking Files] window, 91

WINLINK window

activating, 90

WINMSG (16), 6

WITH LOCK, 240

8/21/2019 Fujitsu COBOL - Users Guide

http://slidepdf.com/reader/full/fujitsu-cobol-users-guide 783/783