The Life and Times of Jim |
Hi, there. I'm Jim. Welcome to my phlog!![]() ![]() |
|
04/13/2011 07:21:00 jim Cobol Ref | Wed |||||||||||||||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <TITLE>COBOL: Language Reference</TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <style type="text/css"> a {text-decoration:none;color:green;background-color:white;} a:hover {text-decoration:none;color:white;background-color:green;} a.mainhdg {display:block;width:100%;color:#000;background-color:#00f;background-image:url(images/bluein.gif); text-align:center;float:none;} b.mainhdg {display:block;width:100%;background-color:#00f; margin-left:0px;font:bold 12px Verdana;text-align:center;float:none; color:#fff;background-image:url(images/menu2db.png);cursor:hand;} b.menuhdg {display:block;width:100%;color:#fff; margin-left:0px;font:bold 12px times;height:16px;text-align:center;float:none; color:#fff;background-image:url(images/menudb.png);cursor:hand;} b.menubg {display:block;width:100%;color:#000;background-color:#00f; margin-left:0px;font:bold 12px times;height:16px;text-align:center;float:none; color:black;background-image:url(images/menu.png);cursor:hand;} a.mnuTitle {background-image:url(images/250-normal.jpg);font:normal 12px Helvetica;color:#000; text-decoration:none;background-color:#eeeeff; padding-left:5px;padding-right:05px;border-bottom:solid 0px;width:95%;display:block;border:none;} a.olink {font:bold 12px Helvetica;color:#0066ff;background-color:transparent;text-decoration:none;} a.olink:hover {background-color:#ff0;color:#000} a.rLink {font:bold 12px Helvetica;color:#0a0;background-color:transparent;text-decoration:none;} a.rLink:hover {background-color:#ff0;color:#000} a.dLink {font:normal 12px Helvetica;color:#000;background-color:transparent;text-decoration:none;} a.dLink:hover {background-color:#ff0;color:#000} a.aLog {font:normal 12px Helvetica;color:#000;background-color:#ddf;display:block;} a.aLog:hover {background-color:#afa;} a.aLog2 {font:normal 12px Helvetica;color:#000;background-color:#fff;display:block;} a.aLog2:hover {background-color:#afa;} b.logHdg {font:bold 10px 'Verdana','Lucida Handwriting','Times';} div.text {display:hidden;} div.column {float:left;} img {border:0;margin:0;padding:0;} a {font:normal 10pt Times} a.mnuTitle:hover {background-image:url(images/bluein.jpg);} table.main {background-color:transparent;} div.mainborder {border:ridge 0px;background-color:#eef;} div.text {visibility:hidden;display:none;width:100%;border:1px solid;padding-left:5px;} b.keyword {display:block;width:200px;color:#000;background-color:#fff; margin-left:0px;font:bold 12px Verdana;text-align:left;float:none;font:normal 10pt Times; cursor:hand;} a.index01 {background-image:url(images/250-normal.jpg);font:normal 12px Helvetica;color:#000; text-decoration:none;background-color:#eeeeff; padding-left:5px;padding-right:05px;border-bottom:solid 0px;width:100px;display:block;border:none;float:left;} a.index02 {background-image:url(images/250-normal.jpg);font:normal 12px Helvetica;color:#000; text-decoration:none;background-color:#eeeeff; padding-left:5px;padding-right:05px;border-bottom:solid 0px;display:block;border:none;float:left;} a.index0 {font:normal 12px Helvetica;color:#000; text-decoration:none;background-color:#eeeeff;text-align:center; padding-left:5px;padding-right:05px;border:double 5px;width:100%;display:block;} a.index2 {font:normal 14px Helvetica;color:#000; text-decoration:none;background-color:#eeeeff;text-align:center; padding-left:5px;padding-right:05px;border:double 5px;width:100%;display:block;} a.index2:hover {background-color:white;color:black;} a.index3 {font:normal 14px Helvetica;color:#000; text-decoration:none;background-color:#eeeeff;text-align:left; padding-left:5px;padding-right:05px;border:solid 2px;} a.index3:hover {background-color:white;color:black;} a.co {ont:normal 12px Helvetica;color:blue; text-decoration:none;border-bottom:solid 0px;border:none;} a.ws- {font:normal 12px Helvetica;color:red;background-color:transparent; text-decoration:none;border-bottom:solid 0px;border:none;} a.na {font:inherit;color:gray;background-color:transparent; text-decoration:none;border-bottom:solid 0px;border:none;} b.co {font:normal 12px Helvetica;color:blue;} b.ws- {font:normal 12px Helvetica;color:red;} b.if {font:normal 12px Helvetica;color:green;} b.ad {font:normal 12px Helvetica;color:magenta;} pre.example {background-color:#eeeeee;display:inline-block; } </style> </HEAD> <BODY> <a href="http://h20000.www2.hp.com/bizsupport/TechSupport/DocumentIndex.jsp?lang=en&cc=us&taskId=101&prodClassId=-1&contentType=SupportManual&docIndexId=64255&prodTypeId=15351&prodSeriesId=4201303">Tandem Manuals</a> <a href="http://bizsupport1.austin.hp.com/bc/docs/support/SupportManual/c02132101/c02132101.pdf">SQL/MP Manual</a> <a href="http://bizsupport1.austin.hp.com/bc/docs/support/SupportManual/c02129236/c02129236.pdf">SQL/Screen Cobol Manual</a> <a href="http://bizsupport1.austin.hp.com/bc/docs/support/SupportManual/c02734252/c02734252.pdf">Guardian Calls Manual</a> <a href="http://bizsupport1.austin.hp.com/bc/docs/support/SupportManual/c02121195/c02121195.pdf">COBOL85 Manual</a> <DIV> <b> <A class="index0" NAME="TOC">Concepts:</b></A> <A CLASS="index01" HREF="#DIVISIONS">Divisions</A> <A CLASS="index01" HREF="#conditions">Conditions</A> <A CLASS="index01" HREF="#88-Levels">Condition Names</A> <A CLASS="index01" HREF="#contin">Continuation</A> <A CLASS="index01" HREF="#ctrlbrk">Control Breaks</A> <A CLASS="index01" HREF="#datatype">Data Types</A> <A CLASS="index01" HREF="#dates">Dates</A> <A CLASS="index01" HREF="#declars">Declaratives</A> <A CLASS="index01" HREF="#delim">Delimiters</A> <A CLASS="index01" HREF="#fields">Fields</A> <A CLASS="index01" HREF="#functions">FUNCTIONS</A> <A CLASS="index01" HREF="#hlval">High/Low Values</A> <A CLASS="index01" HREF="#subindx">index01</A> <A CLASS="index01" HREF="#julian">Julian Dates</A> <A CLASS="index01" HREF="#lvlnbr">Level Numbers</A> <A CLASS="index01" HREF="#literal">Literals</A> <A CLASS="index01" HREF="#para">Paragraphs</A> <A CLASS="index01" HREF="#pic">PIC Clauses</A> <A CLASS="index01" HREF="#qual">Qualified Fields</A> <A CLASS="index01" HREF="#refmod">Ref. Modification</A> <A CLASS="index01" HREF="#rpts">Reports</A> <A CLASS="index01" HREF="#section">Sections</A> <A CLASS="index01" HREF="#subindx">Subscripts</A> <A CLASS="index01" HREF="#table">Tables</A> <A CLASS="index01" HREF="#trunc">Truncation</A> </DIV> <BR> <div> <a class="index0" name="Statements">Statements</a > <A CLASS="index01" HREF="#77-Levels">77-LEVELS</A> <A CLASS="index01" HREF="#88-Levels" >88-LEVELS</A> <A CLASS="index01" HREF="#accept" >ACCEPT</A> <A CLASS="index01" HREF="#add" >ADD</A> <A CLASS="index01" HREF="#blank" >BLANK</A> <A CLASS="index01" HREF="#call" >CALL</A> <A CLASS="index01" HREF="#close" >CLOSE</A> <A CLASS="index01" HREF="#compute" >COMPUTE</A> <A CLASS="index01" HREF="#copy" >COPY</A> <A CLASS="index01" HREF="#corr" >CORR</A> <A CLASS="index01" HREF="intrinsic.html#date">Date Functions</A> <A CLASS="index01" HREF="#delete" >DELETE</A> <A CLASS="index01" HREF="#display" >DISPLAY</A> <A CLASS="index01" HREF="#divide" >DIVIDE</A> <A CLASS="index01" HREF="#evaluate">EVALUATE</A> <A CLASS="index01" HREF="#exit" >EXIT</A> <A CLASS="index01" HREF="#exec" >EXEC</A> <A CLASS="index01" HREF="#goto" >GO TO</A> <A CLASS="index01" HREF="#goback" >GOBACK</A> <A CLASS="index01" HREF="#if" >IF</A> <A CLASS="index01" HREF="#init" >INITIALIZE</A> <A CLASS="index01" HREF="#inspect" >INSPECT</A> <A CLASS="index01" HREF="#invkey" >INVALID KEY</A> <A CLASS="index01" HREF="#merge" >MERGE</A> <A CLASS="index01" HREF="#move" >MOVE</A> <A CLASS="index01" HREF="#multiply">MULTIPLY</A> <A CLASS="index01" HREF="intrinsic.html#numeric">Numeric Fcns</A> <A CLASS="index01" HREF="#occurs" >OCCURS</A> <A CLASS="index01" HREF="#onsize" >ON SIZE</A> <A CLASS="index01" HREF="#open" >OPEN</A> <A CLASS="index01" HREF="#pathsend">PATHSEND</A> <A CLASS="index01" HREF="#perform" >PERFORM</A> <A CLASS="index01" HREF="#read" >READ</A> <A CLASS="index01" HREF="#readnext">READ NEXT</A> <A CLASS="index01" HREF="#redef" >REDEFINES</A> <A CLASS="index01" HREF="#release" >RELEASE</A> <A CLASS="index01" HREF="#return" >RETURN</A> <A CLASS="index01" HREF="#rewrite" >REWRITE</A> <A CLASS="index01" HREF="#round" >ROUNDED</A> <A CLASS="index01" HREF="#search" >SEARCH</A> <A CLASS="index01" HREF="#set" >SET</A> <A CLASS="index01" HREF="#sort" >SORT</A> <A CLASS="index01" HREF="#start" >START</A> <A CLASS="index01" HREF="#stoprun" >STOP RUN</A> <A CLASS="index01" HREF="#string" >STRING</A> <A CLASS="index01" HREF="#subtract">SUBTRACT</A> <A CLASS="index01" HREF="#unstring">UNSTRING</A> <A CLASS="index01" HREF="#usage" >USAGE</A> <A CLASS="index01" HREF="#using" >USING</A> <A CLASS="index01" HREF="#value" >VALUE</A> <A CLASS="index01" HREF="#write" >WRITE</A> </div> <BR><BR> <LI><A HREF="http://www.cse.ohio-state.edu/~sgomori/314/topics.html">Back to Main</A></LI> <!----------------------------------------------------------------> <pre> *----------------------------------------------------------------- * Listing Directives *----------------------------------------------------------------- ?SYNTAX * SYNTAX does not create an object file ?COLUMNS 132|80 * Listing width ?NOCODE|?CODE * Listing of octal image of compiled code ?NOCROSSREF|?CROSSREF * Listing of data (use the CROSSREF utility instead) ?NODIAGNOSE-74|?DIAGNOSE-74 * Listing of COBOL85 compiler to diffences from Cobol74 ?NODIAGNOSE-85|?DIAGNOSE-85 * Listing of Causes NMCompiler to check diffences from Cobol85 ?NODIAGNOSEALL|?DIAGNOSEALL * Listing of Issues warnings for undefined identifiers ?NOFIPS|?FIPS * Listing of edits for Federal Information Processing Standard ?HEADING "Print Heading" * Listing Heading ?NOICODE|?ICODE * Listing of Mnemonic image of code. ?LINES * Listing Lines ?NOLIST|?LIST * Listing on/off ?NOMAP|?MAP * Lising of Symbols ?FMAP ?SHOWCOPY|?NOSHOWCOPY ?SUBSET (HIGH|EXTENDED|DEB1|SEG1|SEG2|OBSOLETE) * Lists obsolete code ?NOSUPPRESS|?SUPPRESS ?WARN|?NOWARN ?ERRORS nnn * Tells Compiler the maximum errors before aborting ?ERRORFILE filename * Uses with FIXERRS filename macro. *----------------------------------------------------------------- * Object Code Directives *----------------------------------------------------------------- ?MAIN program-id ?ENDUNIT|END PROGRAM program-id. ?NOSQL|?SQL (RELEASE1|RELEASE2|PAGES n|SQLMAP|WHENEVERLISTED) ?SQLMEM EXT|USER * Places SQL in EXTENDED STORAGE or WORKING STORAGE ?ENV COMMON * Uses the CRE environment ?ENV LIBRARY * Uses the CRE environment. Allows program to be libraried. ?ENV OLD * Uses nonCRE environment ?RUNNAMED ?SAVE PARAM|STARTUP|ASSIGNS|ALL 100 ?CONSULT (objname,...) *FOR CALL/ENTER OBJECTS BOUND IN AT RUNTIME ?SEARCH (objname,...) * FOR OBJECTS BOUND IN AT COMPILE TIME * DEFINE _OBJECT_SEARCH can be used instead. ?LIBRARY objname * specifies a User Library ?BLANK|?NOBLANK * Start Program with spaces in Working and Extended Storage ?HIGHPIN * Allows program to run in high pin. Must have ENV COMMON * You could use bind: BIND CHANGE HIGHPIN ON IN cobobj ?HIGHREQUESTERS * Allows program to run as a server, and talk to highpin programs ?NONSTOP * Allows use of STARTBACKUP and CHECKPOINT ?HEAP size * Useful only if CRE program calls C program ?COMPACT|?NOCOMPACT * Attempts to compact Code Space ?FLOAT|?NOFLOAT * Allows compiler to use floating point arithmetic for complex computations ?LARGEDATA (item) * Without, data is in User Data(50k) or small data area(32k). With this, its in Extended storage. ?OPTIMIZE 0|1|2 * 0 is easy to debug, 2 is hard but code is efficient. ?PORT 1 * 1-Allows calls to non cobol programs. Automatically defines return-code ?PORT 2 * 2-Don't align binaries on word btye boundries ?PORT * Combination of Port 1, and Port 2 ?NOPORT * Uses standard alignment ?SUBTYPE * ? *----------------------------------------------------------------- * Debug Directives *----------------------------------------------------------------- ?INSPECT|?NOINSPECT * Always use this. ?NOSYMBOLS|?SYMBOLS * Always use this. *----------------------------------------------------------------- * NMCOBOL Code Directives *----------------------------------------------------------------- ?RUNNABLE ?CALL-SHARED * NMCOBOL-Generate NMCobol Code for shared PIC ?SHARED * NMCOBOL-Generate NMCobol code for shared PIC DLL ?NON-SHARED * NMCOBOL-Gernated NMCobol code for nonshared non-PIC ?CANCEL|?NOCANCEL * REINITIALIZE DATA IN CANCELLED PROGRAMS ?LD * Used with NMCOBOL ?NLD * Used with NMCOBOL. See NLD manual ?UL * Used with NMCOBOL *----------------------------------------------------------------- * Source Code Directives *----------------------------------------------------------------- ?TANDEM|ANSI * ANSI forces use of restrictive columns. ?SETTOG settog-nbr * Used with ?IF, ?IFNOT ?RESETTOG settog-nbr * Used with ?IF, ?IFNOT ?IF settog-nbr * Used with ?SETTOG ?IFNOT settog-nbr * Used with ?SETTOG ?ENDIF nn * Ends an IF or IFNOT ?SOURCE filename (section1,section2,...) COPY section1 OF filename ?SECTION section1 ?SECTION section2 </pre> <A CLASS="index2" HREF="#toc" NAME="#DIVISIONS">DIVISION</A> <A CLASS="index01" HREF="#IDENTIFICATION">IDENTIFICATION</A> <A CLASS="index01" HREF="#ENVIRONMENT">ENVIRONMENT</A> <A CLASS="index01" HREF="#DATA">DATA</A> <A CLASS="index01" HREF="#PROCEDURE">PROCEDURE</A> <br><br> <!----------------------------------------------------------------> <A CLASS="index3" href="#DIVISIONS" name="#IDENTIFICATION">IDENTIFICATION DIVISION</A> <PRE> PROGRAM-ID. ProgramId <i>IS INITIAL|COMMON PROGRAM</i>. <a class="na" name="ProgramAuthor">AUTHOR. comment.</a> <a class="na" name="ProgramInstall">INSTALLATION. comment.</a> <a class="na" name="ProgramWritten">DATE-WRITTEN. comment.</a> <a class="na" name="ProgramCompiled">DATE-COMPILED. comment.</a> <a class="na" name="ProgramSecurity">SECURITY. comment.</a> </PRE> <A CLASS="index3" href="#DIVISIONS" name="#ENVIRONMENT">ENVIRONMENT DIVISION</A> <PRE> CONFIGURATION SECTION. <i>SOURCE-COMPUTER. comment.</i> <i>OBJECT-COMPUTER. comment.</i> <I>PROGRAM COLLATING SEQUENCE STANDARD-1|STANDARD-2|NATIVE|EBCDIC|literal</I> <I>CHARACTER SET character-set-types</I> <a name="specialnames">SPECIAL-NAMES.</a> FILE "$SYSTEM.SYSTEM.COBOLLIB" IS <a NAME="sncobollib" class="index1" HREF="#pdenterCobollib">COBOLLIB</a> FILE $SYSTEM.SYSTEM.CLULIB IS <a NAME="snclulib" class="index1" HREF="#pdenterCluLib">CLULIB</a> FILE #TERM IS SYSTEM-CONSOLE * DISPLAY "MESSAGE" UPON SYSTEM-CONSOLE <I>SWITCH-4 IS SWITCH-4 ON STATUS IS TRACE-ON</I> (works with TACL PARAM SWITCH-4 ON) <I>File-Mneumonic-Clauses</I> <I>ALPHABET alphabet-clause</I> <I>SYMBOLIC CHARACTERS symbolic-clause</I> <I>CLASS class-clause</I> <I>CURRENCY currency-clause</I> <I>DECIMAL-POINT decimal-clause</I> *- alphabet-clause = ALPHABET alphabet-name IS STANDARD-1|STANDARD-2|NATIVE|EBCDIC|literal-phrase *- symbolic-clause = SYMBOLIC CHARACTERS QUOTE IS 34 *- class-clause = CLASS VOWEL IS "AEIOUaeiou" *- currency-clause = CURRENCY SIGN IS "$". *- decimal-clause = DECIMAL-POINT IS COMMA. INPUT-OUTPUT SECTION. FILE-CONTROL. <a NAME="seqselect" class="co" HREF="#seqfile">SELECT <I>OPTIONAL</I> Sequential-File</a> ASSIGN <I>TO</I> <a class="index1" HREF="#filename">FileName</a>|#DYNAMIC|#TEMP <a class="index1" href="#Reserve2Areas"><i>Reserve2Areas</i></a> ORGANIZATION IS SEQUENTIAL ACCESS <I>MODE</I> IS SEQUENTIAL <I>FILE STATUS IS ws-file-status</I> <a NAME="relselect" class="co" HREF="#relfile">SELECT <I>OPTIONAL</I> RelativeFile</a> ASSIGN <I>TO</I> <a class="index1" HREF="#filename">FileName</a>|#DYNAMIC|#TEMP <a class="index1" href="#Reserve2Areas"><i>Reserve2Areas</i></a> ORGANIZATION IS RELATIVE ACCESS <I>MODE</I> IS SEQUENTIAL|RANDOM RELATIVE KEY IS <a class="ws-" HREF="#relkey">ws-RelativeKey</a>|DYNAMIC ALTERNATE <I>RECORD</I> KEY<I> IS</I> alt-key <I>WITH DUPLICATES</I> <I>FILE STATUS IS ws-file-status</I> <a NAME="indselect" class="co" HREF="#indfile">SELECT <I>OPTIONAL</I> IndexedFile</a> ASSIGN <I>TO</I> <a class="index1" HREF="#filename">FileName</a>|#DYNAMIC|#TEMP <a class="index1" href="#Reserve2Areas"><i>Reserve2Areas</i></a> ORGANIZATION IS INDEXED ACCESS <I>MODE</I> IS SEQUENTIAL|RANDOM|DYNAMIC RECORD KEY IS <a class="index1" HREF="#indkey">IndexKey</a> ALTERNATE <I>RECORD</I> KEY<I> IS</I> <a class="index1" HREF="#altkey">AlternateKey</a> <I>WITH DUPLICATES</I> <I>FILE STATUS IS ws-file-status</I> <a NAME="sortselect" class="co" HREF="#sdSortFile>SELECT <I>OPTIONAL</I> SortFile</a> ASSIGN <I>TO</I> <a class="index1" HREF="#filename">FileName</a>|#TEMP. <a class="co" HREF="#recfile">SELECT <I>OPTIONAL</I> ReceiveFile</a> ASSIGN <I>TO</I> <a class="index1" HREF="#recname">$RECEIVE</a>. *- ws-file-status = PIC XX. Any value except for "00" is an invalid I-O I-O-CONTROL. SAME RECORD|SORT|MERGE AREA for file-1, file-2, ... RECEIVE-CONTROL. TABLE OCCURS pw-maxlinks <i>EXTENDED-STORAGE</i> TIMES SYNCDEPTH LIMIT IS syncdepth-limit REPLY CONTAINS phrase ERROR CODE phrase MESSAGE SOURCE phrase REPORT phrase *-- pw-maxlinks = 1 to 255. This should be greater than Pathway server maxlinks. *-- syncdepth-limit = 1 </PRE> <!----------------------------------------------------------------------------> <A CLASS="index3" href="#DIVISIONS" name="#DATA">DATA DIVISION</A> <PRE> FILE SECTION. FD <a class="index1" NAME="seqfile" HREF="#seqselect">SequentialFile</a> <I>IS EXTERNAL</I> <i>IS GLOBAL</i> <I>BLOCK CONTAINS 1 {TO 4096} RECORDS|CHARACTERS</I> <i>RECORD CONTAINS 4096 CHARACTERS</i> <i>RECORD {IS} VARYING {IN} {SIZE} FROM 1 CHARACTERS {TO 4096} CHARACTERS {DEPENDING {ON} length-var}</i> <i>CODE SET IS STANDARD-1|STANDARD-2|NATIVE|EBCDIC</I> . 01 SequentialRecord. 05 SequentialFileData PIC X(1000). FD <a class="index1" NAME="relfile" HREF="#relselect">RelativeFile</a>. 01 RelativeRecord. 05 RelativeFileData PIC X(1000). FD <a class="index1" name="indfile" href="#indselect">IndexedFile</a>. 01 Indexed-Record. 05 <a class="index1" name="indkey" href ="javascript:history.back()">IndexKey</a> PIC X(10). 05 Indexed-Data PIC X(1000). 05 <a class="index1" name="altkey" href ="javascript:history.back()">AlternateKey</a> PIC X(10). SD <a class="index1" NAME="sdSortFile" HREF="#sortselect">sdSortFile</a>. 01 SortRecord. 05 SortField1 PIC X(100). 05 SortField2 PIC X(100). 05 SortFileData PIC X(1000). 05 SortField3 PIC X(100). <a class="index3" name="WorkingStorage">WORKING-STORAGE SECTION.</a> 01 WS-RECORD-LEVEL. 49 WS-HIGHEST-LEVEL PIC X(100). 66 WS-RENAMES-LEVEL. 01 WS-RECORD. 05 01 <a class="ws-" name="relkey" HREF="#relselect">ws-RelativeKey</a> NATIVE-4. 88 ws-RelativeFirstRecord VALUE 1. 88 ws-RelativeWriteToEnd VALUE -1. 88 ws-RelativeWriteToEmpty VALUE -2. 01 <a class="ws-" href="#pdacceptyymmdd" name="ws-acceptyymmdd" >ws-YYMMDD</a>. 05 YY PIC 9(2). 05 MM PIC 9(2). 05 DD PIC 9(2). 01 <a class="ws-" href="#pdacceptyyyymmdd" name="ws-acceptyyyymmdd" >ws-YYYYMMDD</a>. 05 YYYY PIC 9(4). 05 MM PIC 9(2). 05 DD PIC 9(2). 01 <a class="ws-" href="#pdacceptyyddd" name="ws-acceptyyddd" >ws-YYDDD</a>. 05 YY PIC 9(2). 05 DDD PIC 9(3). 88 Feb1st VALUE 32. 01 <a class="ws-" href="#pdacceptyyyyddd" name="ws-acceptyyyyddd" >ws-YYYYDDD</a>. 05 YYYY PIC 9(4). 05 DDD PIC 9(3). 88 Feb1st VALUE 32. 01 <a class="ws-" href="#pdacceptwd" name="ws-acceptwd" >ws-WeekDay</a>. 05 WeekDay PIC 9(1). 88 Monday VALUE 1. 88 Sunday VALUE 7. 01 <a class="ws-" href="#pdaccepthhmmsscc" name="ws-accepthhmmsscc" >ws-Time</a>. 05 Hours PIC 99. 88 Midnight VALUE 0. 05 Minutes PIC 99. 05 Seconds PIC 99. 05 Hundreths PIC 99. 01 <a class="ws-" name="ws-Alterparamtext" href="#pdalterparamtext">ws-AlterParamText</a>. 05 ws-Param-I PIC X(100). 05 ws-Value-I PIC X(100). 05 ws-Size-I NATIVE-2. 05 ws-Result-O NATIVE-2. 01 <a class="ws-" name="ws-CheckLogicalName" href="#pdCheckLogicalName">ws-CheckLogicalName</a>. 05 ws-AssignName-I PIC X(100). 05 ws-Result-O NATIVE-2. 88 NoFileWasAssigned VALUE 0. 88 AssignmConflict VALUE -1 THRU -99. 01 <a class="ws-" name="ws-DeleteAssignText" href="#pdDeleteAssignText">ws-DeleteAssignText</a>. 05 ws-Param-I PIC X(100). 05 ws-Result-O NATIVE-2. 01 <a class="ws-" name="ws-DeleteParamText" href="#pdDeleteParamText">ws-DeleteParamText</a>. 05 ws-Param-I PIC X(100). 05 ws-Result-O NATIVE-2. 01 <a class="ws-" name="ws-DeleteStartUpText" href="#pdDeleteStartUpText">ws-DeleteStartUpText</a>. 05 ws-Param-I PIC X(5) VALUE "*ALL*". 05 ws-Result-O NATIVE-2. 01 <a class="ws-" name="ws-GetAssignText" href="#pdGetAssignText">ws-GetAssignText</a>. 05 ws-Assign-I PIC X(63). 05 ws-FileName-O PIC X(34). 05 ws-Length-O NATIVE-2. 88 AssignIsMissing VALUE -1. 01 <a class="ws-" name="ws-getparamtext" href="#pdgetparamtext">ws-GetParamText</a>. 05 ws-Param-I PIC X(100). 88 ParamIsMissing VALUE -1. 05 ws-Value-O PIC X(100). 05 ws-Length-O NATIVE-2. 88 ParamIsMissing VALUE -1. 01 <a class="ws-" name="ws-getStartUptext" href="#pdgetStartUptext">ws-GetStartUpText</a>. 05 ws-StartUp-I PIC X(6). 88 InFile VALUE "IN". 88 OutFile VALUE "OUT". 88 RunString VALUE "STRING". 88 RunVolume VALUE "VOLUME". 05 ws-Value-O PIC X(526). 05 ws-Length-O NATIVE-2. 88 PortionIsMissing VALUE -1. 01 <a class="ws-" name="ws-PutAssignText" href="#pdPutAssignText">ws-PutAssignText</a>. 05 ws-Assign-I PIC X(63). 05 ws-FileName-I PIC X(120). 05 ws-Result-O NATIVE-2. 88 LogicError VALUE -1. 88 CheckPointError VALUE -2. 88 StackOverflow VALUE -3. 01 <a class="ws-" name="ws-Putparamtext" href="#pdPutparamtext">ws-PutParamText</a>. 05 ws-Param-I PIC X(100). 05 ws-Value-I PIC X(120). 05 ws-Result-O NATIVE-2. 88 LogicError VALUE -1. 88 CheckPointError VALUE -2. 88 StackOverflow VALUE -3. 01 <a class="ws-" name="ws-PutStartUptext" href="#pdPutStartUptext">ws-PutStartUpText</a>. 05 ws-StartUp-I PIC X(6). 88 InFile VALUE "IN". 88 OutFile VALUE "OUT". 88 RunString VALUE "STRING". 88 RunVolume VALUE "VOLUME". 05 ws-Value-I PIC X(526). 05 ws-Result-O NATIVE-2. 88 LogicError VALUE -1. 88 CheckPointError VALUE -2. 88 StackOverflow VALUE -3. 01 <a class="ws-" name="ws-Add" href="#pdAdd">ws-Add</a>. 05 ws-Amt-1 PIC 9(8). 05 ws-Amt-2 PIC S9(8)V999. 05 ws-Amt-3 PIC V999. 05 ws-Result-1 PIC V999. 05 ws-Result-2 PIC V999. 01 <a class="ws-" name="ws-Corr" href="javascript:history.back()">ws-Corr</a>. 05 ws-Corr-1. 10 ws-Amt-1 PIC 9(8). 10 ws-Amt-2 PIC S9(8)V999. 10 ws-Amt-3 PIC V999. 05 ws-Corr-2. 10 ws-Amt-1 PIC 9(8). 10 ws-Amt-2 PIC S9(8)V999. 10 ws-Amt-3 PIC V999. 05 ws-Result PIC V999. 01 <a class="ws-" name="ws-CLUProcessCreate" href="#pdCLUProcessCreate">ws-CluProcessCreate.</a> 05 ws-ProgramFile PIC X(40) VALUE "$SYSTEM.SYSTEM.FUP". 05 ws-ErrorNbr NATIVE-2. 05 ws-ProcessNameOption NATIVE-2. 88 RunUnnamed VALUE 0. 88 Use5CharProcessName VALUE 1. 88 SystemGenerated VALUE 2. 88 UseThisProcessName VALUE 3. 88 Use6CharProcessName VALUE 4. 05 ws-ProcessName PIC X(06) VALUE "$PROC". 05 ws-NowaitTag PIC X( ). 05 ws-Result PIC S9(4) SIGN LEADING SEPARATE. 88 ws-Okay VALUE 0. 01 <a class="ws-" name="ws-EnterDelay" href="#pdEnterDely">ws-Delay</a>. 05 HundrethsOfASecond PIC PIC S9(8) COMP. 88 DelayOneSecond VALUE 1000. 88 DelayOneMinute VALUE 6000. 88 DelayOneHour VALUE 360000. 88 DelayOneDay VALUE 8640000. 01 <a class="ws-" name="ws-CobolAssign" href="#pdCobolAssign">ws-CobolAssign</a>. 05 ws-FileName PIC X(36) VALUE "$VOL.SUBVOL.FILE". 05 ws-FileCode PIC 999 COMP. 88 ws-EditFile VALUE 101. 88 ws-ObjectFile VALUE 100. 88 ws-AsciFile VALUE 180. 05 ws-FileType PIC 9999 COMP. 88 ws-Unstructured VALUE 0000. 88 ws-EntrySequenced VALUE 0002. 05 ws-Error PIC S9(4) COMP. 88 ws-Okay VALUE 0. 88 ws-FileNameIsBad VALUE 1. 88 ws-FileCantBeChgd VALUE 2. 88 ws-NotEnoughSpace VALUE 4. 88 ws-BadFileType VALUE 5. 01 <a class=ws- name="wsWaitSeconds">ws-WaitSeconds</a> PIC 9(7)v9(2) COMP. 01 <a class="ws-" href="#pdSearchVarying" name="ws-SearchVarying" >ws-SearchUnsorted</a> 05 ws-UnSortedRecord OCCURS 3 TIMES INDEXED BY ws-UnSortedKey. 10 FILLER VALUE PIC X(1) VALUE "B". 10 FILLER VALUE PIC X(1) VALUE "A". 10 FILLER VALUE PIC X(1) VALUE "C". 01 <a class="ws-" href="#pdSearchAll" name="ws-SearchAll" >ws-SearchSorted</a> 05 ws-SortedRecord OCCURS 3 TIMES ASCENDING KEY INDEXED BY ws-SortedKey KEY. 10 FILLER VALUE PIC X(1) VALUE "A". 10 FILLER VALUE PIC X(1) VALUE "B". 10 FILLER VALUE PIC X(1) VALUE "C". * Because COMP fields are aligned on even byte boundries * the compiler adds filler, which doesn't show up in the listing. * The following is 560 bytes (not 405 bytes) 01 WS-AREA-IS-560-BYTES. 02 TABLE-1 OCCURS 5 TIMES. 03 TABLE-2 OCCURS 5 TIMES. 04 TABLE-3 OCCURS 5 TIMES. 05 ITEM-A PIC 99 USAGE IS COMP. 05 ITEM-B PIC X. * 05 filler pic x. 04 ITEM-3 PIC X. * 04 filler pic x. 03 ITEM-2 PIC X. * 03 filler pic x. EXTENDED-STORAGE SECTION. LINKAGE SECTION. </PRE> <A CLASS="index3" href="#DIVISIONS" name="#PROCEDURE">PROCEDURE DIVISION</A> <PRE> <hr> <a class="co" name="pdaccept">ACCEPT</a> <b class=ws->keyboard-i</b> <a class="co" name="pdacceptdevice">ACCEPT</a> <b class=ws->variable</b> <i>FROM device</i> <a class="co" name="pdacceptyymmdd" href="#ws-acceptyymmdd">ACCEPT</a> <a class="ws-" href="#ws-acceptyymmdd">ws-YYMMDD</a> FROM DATE <a class="co" name="pdacceptyyyymmdd" href="#ws-acceptyyyymmdd">ACCEPT</a> <a class="ws-" href="#ws-acceptyyyymmdd">ws-YYYYMMDD</a> FROM DATE YYYYMMDD <a class="co" name="pdacceptyyddd" href="#ws-acceptyyddd">ACCEPT</a> <a class="ws-" href="#ws-acceptyyddd">ws-YYDDD</a> FROM DAY <a class="co" name="pdacceptyyyyddd" href="#ws-acceptyyyyddd">ACCEPT</a> <a class="ws-" href="#ws-acceptyyyyddd">ws-YYYYDDD</a> FROM DAY YYYYDDD <a class="co" name="pdacceptwd" href="#ws-acceptwd">ACCEPT</a> <a class="ws-" href="#ws-acceptwd">ws-WeekDay</a> FROM DAY-OF-WEEK <a class="co" name="pdaccepthhmmsscc" href="#ws-accepthhmmsscc">ACCEPT</a> <a class="ws-" href="#ws-accepthhmmsscc">ws-Time</a> FROM TIME <hr> <a class="co" name="pdadd">ADD</a> <a class="ws-" href="#ws-Add">ws-Amt-1 <i>ws-Amt-2 ws-Amt-3 </i></a> TO <a class="ws-" href="#ws-Add">ws-Result-1 <i>ws-Result-2</i></a> <i>ROUNDED</i> <i>ON SIZE ERROR statement </i> <i>NOT ON SIZE ERROR statement </i> <i>END-ADD </i> <a class="co" >ADD</a> <a class="ws-" href="#ws-Add">ws-Amt-1 <i>ws-Amt-2 ws-Amt-3 </i></a> GIVING <a class="ws-" href="#ws-Add">ws-Result-1 <i>ws-Result-2</i></a> <i>ROUNDED</i> <i>ON SIZE ERROR statement </i> <i>NOT ON SIZE ERROR statement </i> <i>END-ADD </i> <a class="co" >ADD</a> CORR <a class="ws-" href="#ws-Corr">ws-Corr-1</a> TO <a class="ws-" href="#ws-Corr">ws-Corr-2 </a> <i>ROUNDED</i> <i>ON SIZE ERROR statement </i> <i>NOT ON SIZE ERROR statement </i> <i>END-ADD </i> <hr> <a class="co" name="pdcall">CALL</a> <a class="ws-" name="pdcall" href="#ws-call">ws-CallCobolId</a> USING <a class="ws-" href="#ws-call">ws-CallerArea-1</a> <i><a class="ws-" href="#ws-call">ws-CallerArea-2</a></i> <i>BY REFERENCE</i> <b class=ws->variable...</b></i> <i>BY CONTENT<b class=ws-> variable...</b></i> <i>ON OVERFLOW statement </i> <i>END-CALL </i> <pre class="example"> 01 <a class="ws-" name="ws-call" href="#pdcall">ws-Call-Areas.</a> 05 ws-CallerCobolId VALUE "CALLED-PROGRAM". 05 ws-CallerArea-1 PIC X(10). 05 ws-CallerArea-2 PIC X(10). * Structure of Called PROGRAM PROGRAM-ID. CALLED-PROGRAM. LINKAGE SECTION. 01 <a class="ws-" name="ws-link" href="#pdlink">Link-Areas.</a> 05 ls-CalledArea-1 PIC X(10). 05 ls-CalledArea-2 PIC X(10). PROCEDURE DIVISION USING ls-CalledArea-1, ls-CalledArea-2. ... END-PROGRAM CALLED-PROGRAM. * The Calling program can use a ?SEARCH objname </pre> <hr> <a class=co name="pdclose">CLOSE</a> filename-1<i>, filename-2,...</i> <a class=co name="pdcompute">COMPUTE</b> <a class=ws- href="#ws-Add">ws-Result-1</a> <i>ROUNDED</i> = <a class=ws- href="ws-Add">ws-Amt-1</a> * <a class=ws- href="ws-Add">ws-Amt-2</a> / ( 5. + -1.2) <i>ON SIZE ERROR statement </i> <i>NOT ON SIZE ERROR statement </i> <i>END-COMPUTE</i> <a class=co name="pdCopy">COPY</a> filename <i>IN library </i> <i>REPLACING{==pText==|<b class=va>value</b> BY==pText==|<b class=va>value</b> }... </i> <a class="co" name="pddelete">DELETE</a> filehandle RECORD <i>INVALID KEY statement </i> <i>NOT INVALID KEY statement </i> <i>END-DELETE </i> <a class="co" name="pddisplay">DISPLAY</a> <b class=va>value<i> ...</i> </b>UPON device</I> <i>WITH NO ADVANCING</i> <a class="co" name="pddivid">DIVIDE</a> <b class=va>value</b> INTO|BY <b class=va>value</b> GIVING <b class=ws->variable</b> <i>ROUNDED</i> <i>REMAINDER <b class=ws->variable</b></i> <i>ON SIZE ERROR statement </i> <i>NOT ON SIZE ERROR statement </i> <i>END-DIVIDE </i> <a class="co" name="pddivid">DIVIDE</a> <b class=va>value</b> INTO <b class=ws->variable</b> <i>ROUNDED </i> <i>ON SIZE ERROR statement </i> <i>NOT ON SIZE ERROR statement </i> <i>END-DIVIDE </i> <a class="co" name="pdenter">ENTER</a> <i>C|TAL|FORTRAN</i> RoutineName <a href="#specialnames"><i>OF|IN SpecialNamesFile</i></a> <I>USING field-name|OMITTED</i> <i>GIVING field-name</i> <a name="pdentercobollib" href="#sncobollib">* Cobollib routines</a> <a class="co" name="pdalterparamtext" href="#ws-AlterParamText">* ENTER ALTERPARAMTEXT</a> MOVE "COLLECTOR-NAME" TO ws-Param-I OF ws-AlterParamText MOVE "$W" TO ws-Value-I OF ws-AlterParamText MOVE 2 TO ws-Size-I OF ws-AlterParamText <a href="#pdenter" class="index1">ENTER</a> ALTERPARAMTEXT OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-Param-I OF ws-AlterParamText ws-Value-I OF ws-AlterParamText OMITTED ws-Size-I OF ws-AlterParamText <i>GIVING ws-Result-O OF ws-AlterParamText</i> <a class="co" name="pdCheckLogicalName" href="#ws-CheckLogicalName">* ENTER CHECKLOGICALNAME</a> MOVE "COLLECTOR-NAME" TO ws-AssignName-I OF ws-CheckLogicalName <a href="#pdenter" class="index1">ENTER</a> CHECKLOGICALNAME OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-AssignName-I OF ws-CheckLogicalName GIVING ws-Result-O OF ws-CheckLogicalName <a class="co" name="pdDeleteAssignText" href="#ws-DeleteAssignText">* ENTER DELETEASSIGNTEXT</a> MOVE "COLLECTOR-NAME" TO ws-Param-I OF ws-DeleteAssignText <a href="#pdenter" class="index1">ENTER</a> DELETEASSIGNTEXT OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-Param-I OF ws-DeleteAssignText <i>GIVING ws-Result-O OF ws-DeleteAssignText</i> <a class="co" name="pdDeleteParamText" href="#ws-DeleteParamText">* ENTER DELETEPARAMTEXT</a> MOVE "COLLECTOR-NAME" TO ws-Param-I OF ws-DeleteParamText <a href="#pdenter" class="index1">ENTER</a> DELETEPARAMTEXT OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-Param-I OF ws-DeleteParamText <i>GIVING ws-Result-O OF ws-DeleteParamText</i> <a class="co" name="pdDeleteStartUpText" href="#ws-DeleteStartUpText">* ENTER DELETESTARTUPTEXT</a> MOVE "*ALL*" TO ws-Param-I OF ws-DeleteStartUpText <a href="#pdenter" class="index1">ENTER</a> DELETESTARTUPTEXT OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-Param-I OF ws-DeleteStartUpText <i>GIVING ws-Result-O OF ws-DeleteStartUpText</i> <A class="co" NAME="pdGetAssignText" href="#ws-GetAssignText">* ENTER GETASSIGNTEXT</a> * Retrieves TACL portions of: ASSIGN COLLECTOR-NAME "$S" * Requires: ?SAVE ALL ASSIGN MOVE "TRAN-FILE" TO ws-Assign OF ws-GetAssignText <a href="#pdenter" class="index1">ENTER</a> GETASSIGNTEXT OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-Assign-I OF ws-GetAssignText ws-FileName-O OF ws-GetAssignText <i>GIVING ws-Length-O OF ws-GetAssignText</i> <A class="co" NAME="pdgetparamtext" href="#ws-getparamtext">* ENTER GETPARAMTEXT</a> * Retrieves TACL portions of: PARAM COLLECTOR-NAME "$S" * Requires: ?SAVE ALL PARAM MOVE "COLLECTOR-NAME" TO ws-Param OF ws-GetParamText <a href="#pdenter" class="index1">ENTER</a> GETPARAMTEXT OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-Param-I OF ws-GetParamText ws-Value-O OF ws-GetParamText <i>GIVING ws-Length-O OF ws-GetParamText</i> <A class="co" NAME="pdgetStartUptext" href="#ws-getStartUptext">* ENTER GETSTARTUPTEXT</a> * Retrieves TACL portions of: RUN PROGRAM /IN infile, OUT outfile/ string * Requires: ?SAVE STARTUP MOVE "IN" TO ws-StartUp OF ws-GetStartUpText <a href="#pdenter" class="index1">ENTER</a> GETSTARTUPTEXT OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-StartUp-I OF ws-GetStartUpText ws-Value-O OF ws-GetStartUpText <i>GIVING ws-Length-O OF ws-GetStartUpText</i> <A class="co" NAME="pdPutAssignText" href="#ws-PutAssignText">* ENTER PUTASSIGNTEXT</a> * Creates a TACL Assign: ASSIGN COLLECTOR-NAME "$S" * Requires: ?SAVE ALL ASSIGN MOVE "TRAN-FILE" TO ws-Assign-I OF ws-PutAssignText MOVE "$VOL.SUBVOL.FIL TO ws-FileName-I OF ws-PutAssignText <a href="#pdenter" class="index1">ENTER</a> PUTASSIGNTEXT OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-Assign-I OF ws-PutAssignText ws-FileName-I OF ws-PutAssignText <i>GIVING ws-Result-O OF ws-PutAssignText</i> <A class="co" NAME="pdPutparamtext" href="#ws-Putparamtext">* ENTER PUTPARAMTEXT</a> * Retrieves TACL portions of: PARAM COLLECTOR-NAME "$S" * Requires: ?SAVE ALL PARAM MOVE "COLLECTOR-NAME" TO ws-Param OF ws-PutParamText MOVE "$W" TO ws-Value OF ws-PutParamText <a href="#pdenter" class="index1">ENTER</a> PUTPARAMTEXT OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-Param-I OF ws-PutParamText ws-Value-I OF ws-PutParamText <i>GIVING ws-Result-O OF ws-PutParamText</i> <A class="co" NAME="pdPutStartUptext" href="#ws-PutStartUptext">* ENTER PUTSTARTUPTEXT</a> * Retrieves TACL portions of: RUN PROGRAM /IN infile, OUT outfile/ string * Requires: ?SAVE STARTUP MOVE "IN" TO ws-StartUp-I OF ws-PutStartUpText MOVE "$VOL.SUBVOL.OBEYFILE" TO ws-VALUE-I OF ws-PutStartUpText <a href="#pdenter" class="index1">ENTER</a> PUTSTARTUPTEXT OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING ws-StartUp-I OF ws-PutStartUpText ws-Value-I OF ws-PutStartUpText <i>GIVING ws-Result-O OF ws-PutStartUpText</i> <hr> <a name="pdenterclulib" href="#snclulib">* CLULib routines</a> <A class="co" NAME="pdCLUProcessCreate" href="#ws-CLUProcessCreate">ENTER TAL CLU_Process_Create_</a> OF <a href="#snclulib" class="index1">CLULIB</a> USING OMITTED ws-ProgramFile OF WS-CluProcessCreate OMITTED OMITTED OMITTED OMITTED OMITTED OMITTED ws-ErrorNbr OF WS-CluProcessCreate ws-ProcessNameOption OF WS-CluProcessCreate ws-ProcessName OF WS-CluProcessCreate GIVING ws-Result OF WS-CluProcessCreate <A class="co" HREF="#toc" NAME="pathsend">ENTER TAL SERVERCLASS_SEND_</A> <pre class=example> WORKING-STORAGE. 01 <A name="wsServerClass" class="ws-">WS-SERVERCLASS.</a> 02 MESSAGE PIC X(1500) VALUE SPACES. 02 PATHMON PIC X(15) VALUE SPACES. 02 PATHMON-LEN PIC S9(4) COMP VALUE 15. 02 SERVER-NAME PIC X(15). 02 SERVER-NAME-LEN PIC S9(4) COMP VALUE 15. 02 SEND-MESSAGE-LEN PIC S9(4) COMP VALUE 1040. 02 REPLY-MAX PIC S9(4) COMP VALUE 15. 02 REPLY-LEN PIC S9(4) COMP VALUE 0. 02 SERVER-TIMEOUT PIC S9(9) COMP VALUE 24000. 88 ONE-MINUTE VALUE 6000. 02 SERVER-ERROR PIC S9(4) COMP VALUE 0. 02 SERVER-ERROR-2 PIC S9(4) COMP VALUE 0. PROCEDURE DIVISION. INITIALIZE <A HREF="#wsServerClass" class="ws-">WS-SERVERCLASS</a> MOVE FUNCTION LENGTH(SERVER-MESSAGE OF <A HREF="#wsServerClass" class="ws-">WS-SERVERCLASS</a>) TO SEND-LEN OF <A HREF="#wsServerClass" class="ws-">WS-SERVERCLASS</a> TO REPLY-MAX OF <A HREF="#wsServerClass" class="ws-">WS-SERVERCLASS</a> MOVE FUNCTION LENGTH(PATHMON-NAME OF <A HREF="#wsServerClass" class="ws-">WS-SERVERCLASS</a>) TO PATHMON-NAME-LEN OF <A HREF="#wsServerClass" class="ws-">WS-SERVERCLASS</a> MOVE FUNCTION LENGTH(SERVER-NAME OF <A HREF="#wsServerClass" class="ws-">WS-SERVERCLASS</a>) TO SERVER-NAME-LEN OF <A HREF="#wsServerClass" class="ws-">WS-SERVERCLASS</a>. MOVE "SERVER-NAME" TO SERVER-NAME OF <A HREF="wsServerClass" class="ws-">WS-SERVERCLASS</a> ENTER TAL "SERVERCLASS_SEND_" USING PATHMON OF <A HREF="#wsServerClass" class="ws-">WS-SERVERCLASS</a> PATHMON-LEN OF <a href="#wsServerClass" class="ws-">WS-SERVERCLASS</a> SERVER-NAME OF <a href="#wsServerClass" class="ws-">WS-SERVERCLASS</a> SERVER-NAME-LEN OF <a href="#wsServerClass" class="ws-">WS-SERVERCLASS</a> SERVER-MESSAGE OF <a href="#wsServerClass" class="ws-">WS-SERVERCLASS</a> SEND-LEN OF <a href="#wsServerClass" class="ws-">WS-SERVERCLASS</a> REPLY-MAX OF <a href="#wsServerClass" class="ws-">WS-SERVERCLASS</a> REPLY-LEN OF <a href="#wsServerClass" class="ws-">WS-SERVERCLASS</a> SERVER-TIMEOUT OF <a href="#wsServerClass" class="ws-">WS-SERVERCLASS</a> GIVING SEND-ERROR OF <a href="#wsServerClass" class="ws-">WS-SERVERCLASS</a> IF SEND-ERROR NOT = 0 ENTER TAL "SERVERCLASS_SEND_INFO_" USING SERVER-ERROR SERVER-ERROR-2 END-IF. </pre> <A class="co" NAME="pdEnterDely" href="#ws-EnterDelay">ENTER TAL DELAY</a> USING ws-Delay. * Delay One Week SET DelayOneDay of ws-Delay TO TRUE MULTIPLY ws-Delay BY 7. ENTER TAL "DELAY" USING ws-Delay <A class="co" NAME="pdCobolAssign" href="#ws-CobolAssign">ENTER COBOLASSIGN </a> OF <a href="#sncobollib" class="index1">COBOLLIB</a> USING filehandle <a class=ws- href="#ws-CobolAssign">ws-FileName OF ws-CobolAssign</a> GIVING <a class=ws- href="#ws-CobolAssign">ws-Error OF ws-CobolAssign</a> <A class="co" NAME="pdCobol_Assign_" href="#ws-CobolAssign">ENTER COBOL_ASSIGN_ </a> OF <a href="#sncoblib" class="index1">COBOLLIB</a> USING filehandle <a class=ws- href="#ws-CobolAssign">ws-FileName OF ws-CobolAssign</a> <a class=ws- href="#ws-CobolAssign">ws-FileCode OF ws-CobolAssign</a> <a class=ws- href="#ws-CobolAssign">ws-FileType OF ws-CobolAssign</a> GIVING <a class=ws- href="#ws-CobolAssign">ws-Error OF ws-CobolAssign</a> <a class="co" href="#ws-EnterDely name="pdEnterDelay">* Delay One Week</a> SET DelayOneDay of ws-Delay TO TRUE MULTIPLY 7 BY ws-Delay. <a class="co">ENTER TAL "DELAY"</a> USING ws-Delay <a class=co name="pdevaluate">EVALUATE</a> {<b class=va>value</b>|<b class=ad>compute</b>|TRUE|FALSE} <i>ALSO {<b class=ws->variable</b>|literal-2|<b class=ad>compute</b>|TRUE|FALSE} </i> {WHEN <a class="if" href="#condition">condition</a>|ANY|TRUE|FALSE| <i>NOT</i>{<b class=ws->variable</b>|literal-3|<b class=ad>compute</b>} <i>THRU {<b class=ws->variable</b>|literal-4|<b class=ad>compute</b>} </i>} <i>ALSO {<a class="if" href="#condition">condition</a>|ANY|TRUE|FALSE| <i>NOT</i>{<b class=ws->variable</b>|literal-5|<b class=ad>compute</b>} <i>THRU {<b class=ws->variable</b>|literal-6|<b class=ad>compute</b>} </i>}</i>... statement} ... <i>WHEN OTHER statement </i> <i>END-EVALUATE </i> EVALUATE <a class=co name="pdExit">EXIT</a> PROGRAM|PARAGRAPH|SECTION|PERFORM <I>CYCLE</I> <a class=co name="pdGOTO">GO TO</a> paragraph <a class=co name="pdGOTODENDING">GO TO</a> paragraph... DEPENDING ON <b class=ws->variable-1-to-255</b> <a class=co name="pdif">IF</a> <a class="if" href="#condition">condition</a> <i>THEN </i> CONTINUE|statement... <i>ELSE CONTINUE|statement...</i> <i>END-IF </i> <a class=co name="pdInitialize">INITIALIZE</a> <b class=ws->variable</b>... <i>REPLACING ALPHABETIC|ALPHANUMERIC|NUMERIC|ALPHANUMERIC-EDITED BY literal</i> <a class=co name="pdInspect">* INSPECT variations</a> <a class=co>INSPECT</a> <b class=ws->variable</b> <a class=co name="pdInspectReplacing">REPLACING</a> CHARACTERS BY <b class=va>value</b> <i>BEFORE|AFTER INITIAL <b class=va>value</b></i>... ALL|LEADING|FIRST <b class=va>value</b> BY <b class=va>value</b> <i>BEFORE|AFTER INITIAL <b class=va>value</b></i>... <a class=co>INSPECT</a> <b class=ws->variable</b> <a class=co name="pdInspectTallying">TALLYING</a> <b class=ws->variable</b> FOR CHARACTERS <i>BEFORE|AFTER INITIAL <b class=va>value</b></i>... ALL|LEADING <b class=va>value</b> <i>BEFORE|AFTER INITIAL <b class=va>value</b></i> <a class=co>INSPECT</a> <b class=ws->variable</b> <a class=co name="pdInspectConverting">CONVERTING</a> <b class=va>value</b> TO <b class=va>value</b> <i>BEFORE|AFTER INITIAL <b class=va>value...</b></i> <a class=co name="pdLockFile">LOCKFILE</a> filehandle... <i>TIME LIMIT <a class=ws- href="#wsWaitSeconds"><i>ws-WaitSeconds</i></a></I> <a class=co name="pdMerge">MERGE</a> <a class=index1 href="#sdSortFile">sdSortFile</a> <i>{ON {ASCENDING|DESCENDING} KEY <a class="ws-" HREF="#sdSortFile">SortField1</a> }</i> <i>{ON {ASCENDING|DESCENDING} KEY <a class="ws-" HREF="#sdSortFile">SortField2</a> }</i> ... <i>COLLATING SEQUENCE IS ASCII|EBCDIC </i> USING filehandle... {<i>OUTPUT PROCEDURE IS paragraph-1 </i>| <i>GIVING filehandle...</i>} <a class=co name="pdMove">MOVE</a> <b class=va>value</b> TO <b class=ws->variable....</b> <a class="co" name="pdMoveCorr">MOVE CORR</a> <a class="ws-" href="#ws-Corr">ws-Corr-1</a> TO <a class="ws-" href="#ws-Corr">ws-Corr-2 </a> <a class=co name="pdMultiply">MULTIPLY</a> <b class=ws->value</b> BY <b class=ws->variable</b> <i>ROUNDED</i>... <i>ON SIZE ERROR statement </i> <i>NOT ON SIZE ERROR statement </i> <i>END-MULTIPLY </i> <a class=co name="pdMulTiplyGiving">MULTIPLY</a> <b class=ws->value</b> BY <b class=ws->value</b> GIVING <b class=ws->variable</b> <i>ROUNDED</i>... <i>ON SIZE ERROR statement </i> <i>NOT ON SIZE ERROR statement </i> <i>END-MULTIPLY </i> <a class=co name="pdOpen">OPEN</a> INPUT filehandle... OUTPUT filehandle... I-O filehandle... EXTEND filehandle... <a class=co name="pdOpenInput">OPEN INPUT </a> filehandle... <i>WITH TIME LIMITS</I> <I>SHARED|PROTECTED|EXLUSIVE</I> <I>SYNCDEPTH nn</i> <a class=co name="pdOpenOutput">OPEN OUTPUT</a> filehandle... <i>WITH TIME LIMITS</I> <I>SHARED|PROTECTED|EXLUSIVE</I> <I>SYNCDEPTH nn</I> <a class=co name="pdOpenIO">OPEN I-O</a> filehandle... <i>WITH TIME LIMITS</I> <I>SHARED|PROTECTED|EXLUSIVE</I> <I>SYNCDEPTH nn</I> <a class=co name="pdOpenExtend">OPEN EXTEND</a> filehandle... <i>WITH TIME LIMITS</I> <I>SHARED|PROTECTED|EXLUSIVE</I> <I>SYNCDEPTH nn</I> <a class=co name="pdPerform">PERFORM</a> paragraph-1<i> THRU paragraph-2</i> <i><b class=ws->value</b> TIMES</i> | <i>VARYING <b class=ws->variable</b> FROM <b class=ws->value</b> BY <b class=ws->value</b> UNTIL <a class="if" href="#condition">condition</a> </i><i>WITH TEST BEFORE|AFTER</i> <i>CONTINUE | statement...</i> <i>EXIT PERFORM</i> <i>EXIT PERFORM LOOP</i> </i>END-PERFORM </i> <A class=co name="pdReadNext">READ</a> filehandle NEXT|REVERSED <i>INTO <b class=ws->variable</b></i> <i>WITH LOCK TIME LIMIT <a href="#wsWaitSeconds">ws-WaitSeconds</a></i> | WITH PROMPT <b class=ws->variable</b></i> <i>AT END statement </i> <i>NOT AT END statement </i> <i>END-READ </i> <a class=co name="pdReadKey">READ</a> filehandle <i>INTO <b class=ws->variable</b> </i> <i>KEY IS <a class="ws-" href="#FD-KeyFile">FD-KeyFile</a> </i> <i>INVALID KEY statement </i> <i>NOT INVALID KEY statement </i> <i>END-READ </i> <A class=co name="#pdRELEASE">RELEASE</a> <a class=index1 href="#sdSortFile">SortRecord</a> <i>FROM <b class=ws->variable</b></i> <pre class=example> SORT-INPUT-PROCEDURE. RELEASE SortRecord. </pre> <A class=co name="#pdREPLACE">REPLACE</a> ==search== BY ==replace== | OFF. <pre class=example> DATA DIVISION. REPLACE ==OFFICES== BY ==10== ==SQ-FT-SIZE== BY ==5==. ... 01 ws-OFFICE-AREA. 03 OFFICE-INFO OCCURS OFFICES TIMES. 05 DISTRICT PIC 99. 05 SQUARE-FEET PIC S9(SQ-FT-SIZE). ... PROCEDURE DIVISION. ... PERFORM REPORT-OFFICE OFFICES TIMES. </pre> <A class=co name="pdRETURN">RETURN</a> <a class=index1 href="#sdSortFile">sdSortFile</a> <i>INTO <b class=ws->variable</b></i> <i>AT END statement </i> <i>NOT AT END statement </i> <i>END-RETURN</i> <pre class=example> SORT-OUTPUT-PROCEDURE. RETURN SortFile.</pre> <a class=co name="pdREWRITE">REWRITE</a> FD-record <i>FROM <b class=ws->variable</b></i> <i>WITH UNLOCK</i> <i>INVALID KEY statement</i> <i>NOT INVALID KEY statement</i> <i>END-REWRITE </i> <a class=co name="pdSearchVarying">SEARCH</a> <a class=ws- href="#ws-SearchVarying">ws-UnSortedRecord</a> <i>VARYING {<b class=ws->variable</b>|ws-UnSortedKey}</i> <i>AT END statement </i> WHEN <a class="if" href="#condition">condition</a> statement...|CONTINUE <i>END-SEARCH</i> <a class=co name="pdSearchAll">SEARCH ALL</a> <a class=ws- href="#ws-SearchAll">ws-SortedRecord</a> <i>AT END statement </i> WHEN {<b class=ws->variable</b> = {<b class=ws->var</b>-3|literal-1|<b class=ad>compute</b>}|condition-1} <i>AND {<b class=ws->var</b>-4 = {<b class=ws->var</b>-5|literal-2|<b class=ad>compute</b>}|condition-2}</i>... {statement...|CONTINUE} <i>END-SEARCH </i> <pre class=example> 01 COMMANDS. 05 FILLER PIC X(6) VALUE "ADD". 05 FILLER PIC X(6) VALUE "DELETE". 05 FILLER PIC X(6) VALUE "EXIT". 05 FILLER PIC X(6) VALUE "LIST". ... 01 COMMANDS-IN-TABLE REDEFINES COMMANDS. 05 COMMAND-ENTRIES PIC X(6) OCCURS 6 TIMES ASCENDING KEY IS COMMAND-ENTRIES INDEXED BY TABLE-INDEX. ... 01 COMMAND-NUMBERS. 05 COMMAND-INDEX PIC 99 COMP VALUE 1. 05 COMMAND-IN PIC X(6). ... PROCEDURE DIVISION. ... SEARCH ALL COMMAND-ENTRIES AT END PERFORM COMMAND-ERROR-ROUTINE GO TO GET-ANOTHER-COMMAND WHEN COMMAND-ENTRIES(TABLE-INDEX) = COMMAND-IN CONTINUE END-SEARCH SET COMMAND-INDEX TO TABLE-INDEX </pre> <a class=co name="pdSet">SET</a> index|<b class=ws->variable</b>... TO index|<b class=va>value</b> <b class=co>SET</b> index... UP|DOWN BY <b class=va>value</b> <b class=co>SET</b> <b class=co>88-level...</b> TO TRUE <a class=co name="pdSort" href="#sdSortFile">SORT</a> SD-filehandle <i>ON ASCENDING KEY <a class=ws- href="#sdSortFile">SD-element</a></i>... <i>ON DESCENDING KEY <a class=ws- href="#sdSortFile">SD-element</a></i>... <i>WITH DUPLICATES IN ORDER</i> <i>COLLATING SEQUENCE IS ASCII|EBCDIC</i> <i>USING filehandle... GIVING filehandle...</i> <b class=co>SORT</b> SD-filehandle {<i>ON ASCENDING|DESCENDING KEY <a class=ws- href="#sdSortFile">SortField1</a></i>...}...} {WITH <i>DUPLICATES</i> IN ORDER} {<i>COLLATING SEQUENCE IS ASCII|EBCDIC</i> USING filehandle... | INPUT PROCEDURE IS sort-input-paragraph {THRU paragraph} GIVING filehandle... | OUTPUT PROCEDURE IS sort-output-paragraph {THRU paragraph} sort-output-paragraph <b class=co>RELEASE</b> Sd-record <i>FROM <b class=ws->variable</b></i> <a class=co name="pdStart">START</a> filehandle <i>KEY IS =|KEY IS >|KEY IS NOT <|KEY IS >= <a class="ws-" href="#SDFile">sdSortFile</a> </i> <i> INVALID KEY statement </i> <i>NOT INVALID KEY statement </i> <i>END-START </i> <a class=co name="pdStop">STOP</a> {RUN|literal-1} <a class=co name="pdString">STRING</a> <b class=va>value...</b> DELIMITED BY <b class=va>value</b>|SIZE ... INTO <b class=ws->variable</b> <i>WITH POINTER <b class=ws->variable</b> </i> <i>ON OVERFLOW statement </i> <i>NOT ON OVERFLOW statement </i> <i>END-STRING </i> <a class=co name="pdSubtract">SUBTRACT</a> <b class=va>value...</b> FROM<b class=ws->variable</b> <i>ROUNDED </i> ... <i>ON SIZE ERROR statement </i> <i>NOT ON SIZE ERROR statement </i> <i>END-SUBTRACT </i> <a class=co name="pdSubtractGiving">SUBTRACT</a> <b class=va>value...</b> FROM <b class=va>value</b> GIVING <b class=ws->variable</b> <i>ROUNDED </i> ... <i>ON SIZE ERROR statement </i> <i>NOT ON SIZE ERROR statement </i> <i>END-SUBTRACT </i> <a class=co name="pdUnstring">UNSTRING</a> <b class=ws->variable</b> <i>DELIMITED BY { <i>ALL}</i> <b class=va>value</b> <i>{OR ALL</i> <b class=va>value</b>}...</i> INTO <b class=ws->variable</b> <i>DELIMITER IN <b class=ws->variable-delimiter</b> </i> <i>COUNT IN <b class=ws->variable-counter</b> </i> ... <i>WITH POINTER <b class=ws->variable-pointer</b> </i> <i>TALLYING IN <b class=ws->variable-tally</b> </i> <i>ON OVERFLOW statement </i> <i> NOT ON OVERFLOW statement </i> <i>END-UNSTRING </i> <a class=co name="pdWriteSeq">WRITE</a> SequentialFile <i>FROM <b class=ws->Fd-record</b> </i> <i>BEFORE|AFTER <i>ADVANCING</i> PAGE|<b class=va>value</b> LINE</i> <i>END-WRITE </i> <a class=co name="pdWrite">WRITE</a> filehandle <i>FROM <b class=ws->Fd-record</b> </i> <i>INVALID KEY statement </i> <i>NOT INVALID KEY statement </i> <i>END-WRITE </i> </PRE> <br><br> <!----------------------------------------------------------------> <A class="index2" href="javascript:history.back()" name="SqlCI">SQLCI</A> <PRE> <a class="co" name="SqlCreate">CREATE</a> table_name { LIKE table_name { WITH COMMENTS|CONSTRAINTS|HEADINGS|HELP TEXT } } CATALOG $vol.subvol|=define <i> PHYSVOL physvol ORGANIZATION|ORGANISATION K|E|R PARTITION (partition1, partion2) PARTITION ARRAY STANDARD|EXTENDED|FORMAT2ENABLED SECURITY "NNNN" SIMULARITY CHECK ENABLED|DISABLED ALLOCATE nn AUDIT|NO AUDIT AUDITCOMPRESS|NO AUDITCOMPRESS BLOCKSIZE nn BUFFERED|NO BUFFERED CLEARONPURGE|NO CLEARONPURGE DCOMPRESS 1|2 |NO DCOMPRESS EXTENT (nn,nn) FORMAT 1|2 ICOMPRESS|NO ICOMPRESS LOCKLENGTH nn MAXEXTENTS nn NOPURGEUNTIL date RECLENGTH nn SERIAL WRITES|NO SERIAL WRITES TABLE CODE nn VERIFIEDWRITES|NO VERIFIEDWRITES </i> ( col_name data-type <i>HEADING "string"</i> <i>DEFAULT CURRENT|SYSTEM|NULL|value</i> <i>NO DEFAULT</i> <i>NOT NULL</i> == Strings. == byte=one byte, len <=4059, can have UPSHIFT byte_col PIC|CHAR|VARCHAR<i>(len)</i> <i>UPSHIFT</i> <I>CHARACTER SET UNKNOWN</i> <i>CHARACTER SET ISO88591</i> == Western Europian (English,German,Spanish,Italian) <i>CHARACTER SET ISO88592</i> == Eastern Europian <i>CHARACTER SET ISO88593</i> == Turkish,Maltese <i>CHARACTER SET ISO88594</i> == Lithuanian,Greenland <i>CHARACTER SET ISO88595</i> == Bulgarian,Russian,Macedonian <i>CHARACTER SET ISO88596</i> == Arabic <i>CHARACTER SET ISO88597</i> == Greek <i>CHARACTER SET ISO88598</i> == Hebrew <i>CHARACTER SET ISO88599</i> == Turkish <i>CHARACTER SET KANJI </i> == Chinese (2 bytes) <i>CHARACTER SET KSC5601 </i> == Korean (2 bytes) COLLATE CHARACTER SET char_col NCHAR|NATIONAL CHAR (size) == Strings, fixed length byte_col PIC X(size) == Same as CHAR(size) byte_col CHAR(size) == Same as PIC X == Strings, variable length byte_col VARCHAR(size) == Uses an extra 2 bytes for size indicator. byte_col CHAR VARYING (size) == Same as VARCHAR char_col NCHAR|NATIONAL CHAR VARYING (size) == Display Numerics. If int > 9, it must be SIGNED. int + decimal <= 18 == SIGN LEADING means nothing numeric_asci DECIMAL (digits,intportion) <i>SIGNED|UNSIGNED</i> numeric_asci PIC <i>S</i>9(int) <i>SIGN LEADING</i> numeric_asci PIC <i>S</i>9(int)V(decimal) numeric_asci PIC S9(nn)V(nn) <I>DISPLAY</I> <I>SIGN IS LEADING</I> == Binary Numerics numeric_binary NUMERIC (max<i>,decimalpart</i>) <i>SIGNED|UNSIGNED</i> == max <=18 numeric_binary PIC <i>S</i>9(max)V(decimal) COMP == max + decimal <=18 == SMALLINT = 2 Bytes 0 to 65535 or -32768 to 32767 int16_col SMALLINT <i>SIGNED|UNSIGNED</i> == like PIC S9(4) COMP int16_col PIC <i>S</i>9(4) COMP == INT = 4 Bytes 0 to 4294967295 or signed -2147483648 to 2147483647 int32_col INT <i>SIGNED|UNSIGNED</i> == like PIC S9(8) COMP int32_col PIC <i>S</i>9(8) COMP == LARGEINT = 8 Bytes -2**63 to 2**63 -1 int64_col LARGEINT <i>SIGNED</i> == like PIC S9(16) COMP int64_col PIC S9(16) COMP == FLOAT REAL = FLOAT(22) = 4 bytes 9(n)V9(7). decimal32_col FLOAT <I>(22|54)</I> REAL == FLOAT DOUBLE PRECISION = FLOAT(54) = 8 bytes 9(n)V9(16). decimal64_col FLOAT <I>(22|54)</I> DOUBLE PRECISION == DATE "yyyy-mm-dd"|"mm/dd/yyyy"|"dd.mm.yyyy" == Literal DATE "yyyy-mm-dd" date_col DATE == 4 bytes, same as DATETIME YEAR TO DAY == DATETIME "yyyy-mm-dd:23:59:59.999999"|"mm/dd/yyyy 12:59:59.999999 AM|PM"|"dd.mm.yyyy 23.59.59.999999" == Literal DATETIME "2004-01-22:13:40:05.55" YEAR TO FRACTION (2) datetime_col DATETIME [YEAR|MONTH|DAY|HOUR|SECOND|FRACTION(6) TO ] YEAR|MONTH|DAY|HOUR|SECOND|FRACTION(6) == TIME time_col TIME == 3 bytes, same as DATETIME YEAR TO FRACTION(6) timestamp_col TIMESTAMP == 11 bytes interval_col INTERVAL YEAR|MONTH|DAY|HOUR|SECOND|FRACTION(6) [ TO YEAR|MONTH|DAY|HOUR|SECOND|FRACTION(6)] ) , {PRIMARY} KEY ( col_name ASC|DESC , col_name ASCENDING|DESCENDING ) CLUSTERING KEY == Adds SYSKEY at the end to allow duplicates ( col1 ASC|DESC , col2 ASC|DESC ) </PRE> <!----------------------------------------------------------------> <A class="index2" href="javascript:history.back()" name="SqlSelects">SQL SELECTS</A> <PRE> <a class="co" name="SqlSelect">SELECT</a> <i>DISTINCT</i> * , col_name1 , col_name2, 3, col_amount1, col_amount2, alias2.col_name3, alias3.col_name4 , col_datetime , col_date , col_time , col_timestamp , (CAST(col_timestamp AS DATE) - col_date) DAY , TRIM(col_name1) || "," || TRIM(col_name2) , col_null , "2011-04-27" DATE , col_datetime CASE col_index WHEN 1 THEN "VALUE 1" WHEN 2 THEN "VALUE 2" ELSE THEN NULL END INTO :col-name1 , :col-name2, :col-name3 OF my-area, :col-amount1, :col-amount2, :col-name3, :col-name4 , :col-datetime TYPE AS DATETIME [YEAR|MONTH|DAY|HOUR|SECOND|FRACTION(6) TO ] YEAR|MONTH|DAY|HOUR|SECOND|FRACTION(6) , :col-date TYPE AS DATE , :col-time TYPE AS TIME , :col-timestamp TYPE AS TIMESTAMP , :cast-day TYPE AS DAY , :col_name1_plus_name2 , :col-null INDICATOR hst-null-ind == < 0 means not present , :col-literal TYPE AS INTERVAL DAY == , :col_index-value INDICATOR hst-index-value FROM table-name1 , table-name2 alias2 , table-name3 alias3 , view-name alias4 , table-name4 j1 LEFT JOIN table-name5 j2 ON j1.colname = j2.colname , table-name6 j6 INNER JOIN table-name7 j7 ON j6.colname = j7.colname WHERE col_date = :ws-date TYPE AS DATE AND col_name1 in ("JAMES", "JOE") AND col_name1 in (SELECT col_name FROM =NEW-NAMES BROWSE ACCESS) AND EXISTS (SELECT col_index_value FROM =other_table b WHERE alias2.col_index_value = b.col_index_value BROWSE ACCESS) AND col_date = DATETIME "2004-01-22:13:40:05.55" YEAR TO FRACTION(2) HAVING SUM(col_amount)|MIN(col_amount)|MAX(col_amount) BROWSE|STABLE|REPEATABLE ACCESS IN SHARE|EXCLUSIVE MODE GROUP BY col_name1<i>, col_name2...</i> == Use with the SUM(),MIN(),MAX() ORDER BY col_name1 <i>ASC|DESC</i> <i>,col_name2,alias2.col_name3...</i> UNION <i>ALL</i> select-statement FOR UPDATE OF col_name1 <i>,col_name2...</i> <!----------------------------------------------------------------> <A class="index2" href="javascript:history.back()" NAME="condition">Conditions</A> A condition is a special piece of code that allows- you to instruct the computer to compare two pieces of data. Conditions are used in <A HREF="#if">IF</A> statements and in the While/Until clauses of the <A HREF="#perform">PERFORM</A> statement</P> Conditions have the syntax: <I>data-1</I> <B>operator</B> <I>data-2</I> <br>where <I>data-1</I> and <I>data-2</I> can be a <A HREF="#literal">literal</A> or a <A HREF="#fields"> field</A>. <I>data-2</I> can also be a COBOL literal such as SPACES or ZEROS. <PRE> IF condition THEN ELSE END-IF PERFORM UNTIL condition END-PERFORM condition = <a href=#88-levels>88 Level</a>, NOT, =, >, >=, <=, AND, OR, IS NOT LESS THAN, IS LESS THAN IS GREATER THAN , IS NOT GREATER THAN, IS EQUAL TO, IS NOT EQUAL TO (condition) AND (condition) (condition) OR (condition) field EQUAL value or value or value </PRE> <P>Also see <A HREF="#88-Levels">88-level Fields</A>.</P> <!----------------------------------------------------------------> <A class="index2" href="javascript:history.back()" NAME="88-Levels">88-level Fields</A> <P>A <A HREF="#fields">field</A> declared with a <A HREF="#lvlnbr">level number</A> of 88 is commonly known as a 'condition name'. This name can be used anywhere a <A HREF="#conditions"> condition</A> can be used and is generally more readable. Condition names are declared immediately after the field they are associated with. They use no storage (they take up no room).</P> <P>For example your application contains a field named ACCT-TYPE which is PIC 999. One particular section of code determines if the account is a checking account (account type 100, 110, 210 or 300), a savings account (type 150 or 175) or a CD/IRA (type 400). An IF statement could look like:</P> <TT><PRE> IF ws-ACCT-TYPE = 100 OR 110 OR 210 OR 300 <I>statement(s)</I> ELSE IF ws-ACCT-TYPE = 150 OR 175 <I>statement(s)</I> ELSE IF ws-ACCT-TYPE = 400 <I>statement(s)</I> END-IF END-IF END-IF </PRE></TT> <P>Logically accurate but not entirely clear what account types are what. Comments would help, but condition names will help more. Define as:</P> <TT><PRE> 01 ws-ACCT-TYPE PIC 999. 88 CHECKING-ACCT VALUE 100 110 210 300. 88 SAVINGS-ACCT VALUE 150 175. 88 CD-IRA-ACCT VALUE 400. </PRE></TT> <P>The same IF can now look like:</P> <TT><PRE> IF CHECKING-ACCT <I>statement(s)</I> ELSE IF SAVINGS-ACCT <I>statement(s)</I> ELSE IF CD-IRA-ACCT <I>statement(s)</I> END-IF END-IF END-IF </PRE></TT> <P>Now it's self-documenting. The added advantage is if another type of savings account is developed it only needs added at the condition name. The IF statement doesn't change.</P> <P>A specific value can appear in multiple condition names. Values associated with a condition name can be specified with THRU (i.e. VALUES 90 THRU 99). When checking condition names 'NOT' can be used. If a condition name only has one value a statement such as 'SET CD-IRA-ACCT TO TRUE' is valid and is the equivalent to 'MOVE 400 TO ws-ACCT-TYPE'.</P> <P>Also see <A HREF="#set">Set</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="contin">Continuation</A> <P>Statements can be continued over several lines without doing anything more than placing the code on separate lines. The compiler will figure it out.</P> <P>Very long alphanumeric <A HREF="#literal">literals</A> can be continued on multiple lines by placing a hyphen in column 7 of the continuation lines and placing the remainder of the literal there. This continuation of the literal requires a beginning single quote. The literal on the previous line does not have an ending single quote but is considered to extend to column 72.</P> <PRE><TT> MOVE 'THIS IS ONE SERIOUSLY LONG ALPHANUME - 'RIC LITERAL' TO ws-STRING. </TT></PRE> <P>The hyphen on the 2nd line is in column 7. The single quote on that line is in column 12 and the literal continues from there. The ending single quote on that line is required. Note that the portion of the literal that's on the first line does not have an ending quote. If the last 'E' is not in column 72 then it will be assumed that all characters between that 'E' and column 72 are spaces and will appear in the literal.</P> <P>Also valid with <A HREF="#value">value</A> clauses.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="ctrlbrk">Control Breaks</A> <P>Control breaks are a feature of <A HREF="#rpts">reports</A> that allow for the grouping of and accumulating subtotals for data that belong together based on the value of a <A HREF="#fields">field</A> (the control field). When the value for this field changes from one record to another the program "breaks" to do some special processing (like printing subtotals) before it goes on with the next record. The input file must be sorted on the control field(s).</P> <P>An example of a report with a single-level control break:</P> <TT><PRE> 04/20/1999 The ABC Company Page 1 Payroll Register Department: Janitorial Employee Nbr Name Hours Rate Pay 123 45 6789 Ray, Marcus 40.0 2.00 80.00 111 11 1111 Griese, Brian 50.0 2.50 125.00 Totals for department Janitorial: 90.0 205.00 Department: Research and Development 456 78 9123 Gates, Willy 12.0 800.00 9,600.00 ... ... ... ... ... Grand Totals: 1,002.5 258,125.00 </PRE></TT> <P>The control break is on department. Each control group (department) has it's own headings and footings (totals). Though it's not shown here in this example it's common for column headings to be repeated after each control heading.</P> <P>See the <A HREF="algs.html#ctrlbrk">algorithms</A> page for sample code.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="datatype">Data Types</A> <P>There are basically three types of data recognized by COBOL. Numeric data (both with or without decimal places: only 0-9, the decimal point and a sign allowed), alphabetic (only the characters A-Z) and alphanumeric (any characters). Alphabetic is rarely used.</P> <P>Math can only be performed on numeric <A HREF="#fields"> fields</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="dates">Dates</A> <P>Dates are common data for COBOL programs and must be manipulated often. Typically dates are stored in the Gregorian format, consisting of the familiar month, day and year. This is generally called the 'mmddyy' format, though the 'mmddyyyy' format is becoming the new standard (see the <A HREF="discuss.html">Y2K discussion</A> page). While those formats are familiar to the coders and users dates are more often stored in 'yymmdd' or 'yyyymmdd' format so that they can be sorted easily.</P> <P>So-called 'calendar math', where dates are used in calculations, can be a tedious process, unless your compiler supports the <A HREF="intrinsic.html#date">intrinsic date functions</A>. If not, remember the following about the Gregorian calendar:</P> <UL><LI>April, June, September and November only have 30 days</LI> <LI>February only has 28 days, 29 if a leap year</LI> <LI>All other months have 31 days</LI> <LI>The 'official' method of determining if a year is a leap year requires dividing the 4-digit year by 4, 100 and 400 and looking at the remainders of those three calculations. If the first remiander is 0 then the year is a leap year, but if the second remainder is also 0 then the year is not a leap year, but if the third remainder is also a 0 then the year is a leap year again. This is why 2000 is a leap year by 1900 and 2100 are not. These checks must be nested within each other, trying to put them in a single IF will not work.</LI></UL> <P>Also see <A HREF="#julian">Julian Dates</A>.</P> <A class="index2" HREF="#toc" NAME="declars">DECLARATIVES</A> <P>Delaratives are typically used in conjunction with FILE STATUS to determine the severity of a file I-O error. SELECT logicalname ASSIGN TO phyicalfilename FILE STATUS IS FileStatus. </P> <PRE> 01 FileStatus-MESSAGE. 05 FILE-I-O-TYPE PIC X(6) JUST RIGHT. 05 FILLER PIC X VALUE SPACES. 05 FILE-FAILED PIC X(6) VALUE SPACES. 05 FILLER PIC X VALUE SPACES. 05 FileStatus-MSG PIC X(21). 05 FILLER PIC X VALUE " " . 05 FileStatus PIC XX VALUE "00". 88 VALID-KEY VALUE "00". 05 FILLER PIC X VALUE ":" . 05 FILE-GUARDIAN-ERR PIC 999 VALUE ZERO. 88 FILE-TIMEOUT VALUE 40. /******************* PROCEDURE DIVISION. ******************** DECLARATIVES. INPUT-SECTION SECTION. USE AFTER STANDARD ERROR PROCEDURE ON INPUT. MOVE "INPUT" TO FILE-I-O-TYPE. PERFORM EDIT-FileStatus. I-O-SECTION SECTION. USE AFTER STANDARD ERROR PROCEDURE ON I-O. MOVE "OUTPUT" TO FILE-I-O-TYPE. PERFORM EDIT-FileStatus. OUTPUT-SECTION SECTION. USE AFTER STANDARD ERROR PROCEDURE ON OUTPUT. MOVE "I-O" TO FILE-I-O-TYPE. PERFORM EDIT-FileStatus. EXTEND-SECTION SECTION. USE AFTER STANDARD ERROR PROCEDURE ON EXTEND. MOVE "EXTEND" TO FILE-I-O-TYPE. PERFORM EDIT-FileStatus. EDIT-FileStatus SECTION. MOVE GUARDIAN-ERR TO FILE-GUARDIAN-ERR. IF FileStatus = "00" MOVE "Worked" TO FILE-FAILED MOVE "Successfully " TO FileStatus-MSG ELSE MOVE "Failed" TO FILE-FAILED MOVE 999 TO DISK-ERRORS EVALUATE FileStatus WHEN "05" MOVE "Open Failed " TO FileStatus-MSG WHEN "10" MOVE "End of File " TO FileStatus-MSG WHEN "30" MOVE "Permanent Error " TO FileStatus-MSG WHEN "21" MOVE "Rewrite Error " TO FileStatus-MSG WHEN "22" MOVE "Duplicate Key " TO FileStatus-MSG WHEN "23" MOVE "No Record Exist " TO FileStatus-MSG WHEN "24" MOVE "Write Past Eof " TO FileStatus-MSG WHEN "30" MOVE "Temporary Error " TO FileStatus-MSG WHEN "34" MOVE "Seq Write Past Eof " TO FileStatus-MSG WHEN "35" MOVE "Open File Error " TO FileStatus-MSG WHEN "37" MOVE "Device Open Error " TO FileStatus-MSG WHEN "38" MOVE "Open Parameter Error" TO FileStatus-MSG WHEN "41" MOVE "File is NOT Closed " TO FileStatus-MSG WHEN "42" MOVE "File is NOT Opened " TO FileStatus-MSG WHEN "43" MOVE "UnRead Del./Rewrite " TO FileStatus-MSG WHEN "44" MOVE "Rewrite Size Differs" TO FileStatus-MSG WHEN "46" MOVE "UnStarted Read Next " TO FileStatus-MSG WHEN "47" MOVE "Read/Start Open Err " TO FileStatus-MSG WHEN "48" MOVE "Write Open Error " TO FileStatus-MSG WHEN "49" MOVE "File not Opened I/O" TO FileStatus-MSG WHEN "90" MOVE "Open Not Timed I/O " TO FileStatus-MSG WHEN "91" MOVE "EditReadUnit Failed " TO FileStatus-MSG WHEN OTHER MOVE "Unknown condition " TO FileStatus-MSG. IF GUARDIAN-ERR = 40 MOVE "98" TO FileStatus. END DECLARATIVES. </PRE> <!----------------------------------------------------------------> <TT><PRE> IF ws-OSU > ws-MICHIGAN <I>statement(s)</I> ELSE <I>statement(s)</I> END-IF </TT></PRE> <P>Verbs that have end-delimiters are the comparison verbs (IF, EVALUATE), input/output (READ, WRITE, DELETE, REWRITE, ACCEPT), math (ADD, SUBTRACT, MULTIPLY, DIVIDE, COMPUTE), processing transfer (PERFORM, CALL) and some other lesser used verbs.</P> <P>When the compiler encounters a period it takes that as the end of the statement. A delimiter that is found after a period is in error.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="fields">Fields</A> <P>A field is what other languages call a variable. It's a place to store data. All fields must be declared in the DATA DIVISION. A field declaration has three parts: the <A HREF="#lvlnbr">level number</A>, the field name and the <A HREF="#pic">PIC clause</A>. <A HREF="#value">VALUE clauses</A> are optional.</P> <P>A valid field name is from 1 to 30 characters in length; contains only the letters A-Z, the digits 0-9 and the hyphen; contains at least one letter; does not begin or end with a hyphen; and is not a COBOL reserved word.</P> <P>Also see <A HREF="#qual">Qualified Fields</A>.</P> <A class="index2" HREF="#toc" NAME="hlval">HIGH-VALUES/LOW-VALUES</A> <P>These are special numeric <A HREF="#literal">literals</A> inherent to COBOL. HIGH-VALUES is the COBOL equivalent to infinity - no number is greater than HIGH-VALUES. Conversely, no number is less than LOW-VALUES.</P> <P>They can be used in <A HREF="#value">VALUE clauses</A>, <A HREF="#conditions">conditions</A> and <A HREF="#move"> MOVE</A> statements but math <I>cannot</I> be performed using these literals. <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="functions">FUNCTIONS</A> For TNS HP COBOL be sure to include ?ENV COMMON <TT><PRE> 01 ws-ACOS PIC S9V99 VALUE 3.14. MOVE FUNCTION ACOS(-1) TO ws-ACOS. 01 ws-ASIN PIC S9V99 VALUE 0.25. MOVE FUNCTION ASIN(-1) TO ws-ASIN. 01 ws-ATAN PIC S9V99 VALUE 1.5. MOVE FUNCTION ATAN(15.5) TO ws-ATAN. 01 ws-COS PIC S9V99 VALUE -0.83. MOVE FUNCTION COS(-10) TO ws-COS. 01 ws-CHAR PIC X VALUE "D". MOVE FUNCTION CHAR(69) TO ws-CHAR. SPECIAL-NAMES. ALPHABET CAPITAL-LETTERS IS 66 THRU 91. 01 ws-CHAR PIC X VALUE "A". MOVE FUNCTION CHAR(1) TO ws-CHAR. 01 ws-CURRENT-DATE. 05 ws-CURRENT-YYYY PIC 9(4). 05 ws-CURRENT-MM PIC 9(2). 05 ws-CURRENT-DD PIC 9(2). 05 ws-CURRENT-HH PIC 9(2). 05 ws-CURRENT-MI PIC 9(2). 05 ws-CURRENT-SS PIC 9(2). 05 ws-CURRENT-HU PIC 9(2). 05 ws-CURRENT-GMT-OFF PIC S9(4). MOVE FUNCTION CURRENT-DATE TO ws-CURRENT-DATE 01 ws-INTEGER-DATE PIC 9(8) VALUE 16010101. MOVE FUNCTION DATE-OF-INTEGER (1) TO ws-INTEGER-DATE 01 ws-YYYYDDD PIC 9(8) VALUE 1600001. MOVE FUNCTION DAY-OF-INTEGER (1) TO ws-YYYYDDD 01 ws-ANNUITY-AREA. 05 ws-INTEREST PIC 999 VALUE 6. 05 ws-PERIODS PIC 999 VALUE 12. 05 ws-ANNUAL-PERCENT PIC 999V999 VALUE 1.1. MOVE FUNCTION ANNUITY(ws-INTEREST ws-PERIODS) TO ws-ANNUAL-PERCENT </PRE></TT> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="julian">Julian Dates</A> <P>Julian is a date format that's an alternative to <A HREF="#dates">Gregorian dates</A>. It consists of a 3-digit day and a year; there are no months. The days range from 1 (Jan 1st) to either 365 or 366 (Dec 31), depending on if the year is a leap year or not. This is generally known as the 'dddyy' or 'dddyyyy' format, even though normally the date is stored as 'yyddd' or 'yyyyddd' to ease with sorting.</P> <P>Shops that make use of Julian dates will have callable routines that covert Julian to Gregorian and back again, because humans are comfortable with Gregorian dates. <A HREF="#funccal">Intrinsic date functions</A> available with newer COBOL compilers have these conversions built-in.</P> <P>Julian format has two advantages. First, it's smaller, so it takes up less space. Second, it eases with some calculations because it contains no months. For example, how many days are between Feb 5, 1997 and Nov 28, 1999? Convert to Julian (1997036 and 1999332) a quick subtraction gives 1026 days. Remember that 'borrowing' a year gives you 365 days.</P> <P>Getting a future date or past date can also be easier with Julian. What date is 45 days before Apr 15, 1999? Convert it to Julian (1999105), subtract 45 to get 1999060) and convert back to Gregorian (Mar 1, 1999).</P> <A class="index2" HREF="#toc" NAME="lvlnbr">Level Numbers</A> <P>Level numbers are used to group <A HREF="#fields">fields</A> in the Data Division. A field can then be defined as a collection of other fields. The higher the level number the lower in the heirarchy the field is. Normally, the field numbers 01, 05, 10, etc. are used. By spacing them out you leave yourself room in case a level needs to be added later. Valid level numbers are 0-49.</P> <P>Each FD is required to have an 01-level field defined. This is the record definition. It can be broken down into smaller fields if desired. For example:</P> <TT><PRE> 01 INPUT-RECORD. 05 IN-EMPLOYEE-NUMBER PIC 9(09). 05 IN-EMPLOYEE-NAME. 10 IN-EMP-LAST-NAME PIC X(30). 10 IN-EMP-FIRST-NAME PIC X(15). 10 IN-EMP-MIDDLE PIC X. 05 IN-BIRTH-DATE. 10 IN-BIRTH-DD PIC 99. 10 IN-BIRTH-MM PIC 99. 10 IN-BIRTH-YEAR. 15 IN-BIRTH-CC PIC 99. 15 IN-BIRTH-YY PIC 99. 05 IN-DEPARTMENT PIC X(05). </PRE></TT> <P>We have an 01-level field that is broken down into 4 fields (the 05-level fields). Two of the 05-level fields are also broken down. Employee number is an elementary field because it is not broken down into smaller fields. The employee name and birth date are group level fields because they are broken down into smaller fields. Only elementary fields have <A HREF="#pic"> PIC clauses</A>.</P> <P>The birth date is 8 characters long (the sum of the lengths of the elementary fields that compose it). All 8 characters can be accessed with one name (IN-BIRTH-DATE) or one of its pieces can be accessed by using that name instead (i.e. IN-BIRTH-MM).</P> <P>A group level item 'ends' when another field with the same level number, or one with a lower value, is encountered. For example, the list of fields within IN-BIRTH-YEAR ends when the 05-level IN-DEPARTMENT is encountered. A field of level 10 would also have ended it.</P> <P>All group level fields are considered to be <A HREF="#datatype">alphanumeric</A>.</P> <P>All of these level number concepts are valid for WORKING-STORAGE also.</P> <P>Also see <A HREF="#77-Levels">77-level Fields</A>   <A HREF="#88-Levels">88-level Fields</A>.</P> <A class="index2" HREF="#toc" NAME="literal">Literals</A> <P>Literals are specific values as opposed to fields. Alphanumeric literals are enclosed in single quotes. In the following statements:</P> <TT><PRE> MOVE 3.1415927 TO ws-PI. DISPLAY 'Enter a number: '. </PRE></TT> <P>3.1415927 is a <A HREF="#datatype">numeric</A> literal and 'Enter a number: ' is an <A HREF="#datatype">alphanumeric</A> literal. COBOL has some built-in literals like ZEROES and SPACES.</P> <P>Also see <A HREF="#contin">Continuation</A>   <A HREF="#hlval">HIGH-VALUES/LOW-VALUES</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="para">Paragraphs</A> <P>A paragraph is a section of COBOL code. Paragraph names start in the 'A' margin and follow the same naming rules that <A HREF="#fields"> fields</A> do. A paragraph ends when another paragraph name is encountered. Paragraphs can be executed with the <A HREF="#perform">PERFORM</A> statement.</P> <P>You can think of a pargraph as the equivalent of a subroutine in other languages. There are no arguments, all fields are thought of as global.</P> <P>Also see <A HREF="#section">Sections</A>.</P> <A class="index2" HREF="#toc" NAME="pic">PIC Clauses</A> <P>PIC (short for PICture) clauses describe the size and type of data for each <A HREF="#fields">field</A>. <A HREF="#datatype"> Numeric data</A> has a PIC character of 9, <A HREF="#datatype"> alphanumeric data</A> uses X and <A HREF="#datatype">alphabetic data</A> an A. Each 9, X or A represents one character. Length can also be represented by a repetition factor. The PIC clauses 9999 and 9(04) both define 4-digit numbers.</P> <P>The PIC character V is used to mark where a decimal point is. If you had a 8-digit numeric field but 2 of the digits are after the decimal point, you would define it as PIC 9(06)V99. The decimal point is implied, it is not physically there in the data. It also takes up no space. To allow for a field to hold either positive or negative numbers precede the leftmost PIC character with an S (PIC S999V99).</P> <P>There are several output PIC characters which help with formatting data for display or print. Numeric fields are <A HREF="#move"> MOVEd</A> to fields defined with these formatting PIC characters. Fields defined with these formatting PIC characters are considered <A HREF="#datatype">alphanumeric</A>. No calculations can be done with these fields. Newer versions of COBOL allow these fields to be MOVEd to straight numeric fields.</P> <P>To print a decimal point place a '.' in the desired place in the output PIC clause (i.e. PIC 999.99). You can place commas in output numbers also (i.e. PIC 999,999.99). In this manner the decimal point (and commas) do take up space. These are considered insertion characters - they insert themselves into the data. Other insertion characters are B (for a space), 0 (a zero) and / (useful in printing dates).</P> <P>There is Z, for suppressing leading zeroes. If the digit represented by a Z is a leading zero it will print as a blank. You normally have one 9 in the PIC clause, in the one's place. All other digits represented by Z's. Do not use Z's after the decimal point. If used with commas (i.e. PIC ZZZ,ZZ9.99) a comma will only print if the character to its left prints, else it prints as a blank.</P> <P>There are other zero suppression characters. A $ can be used just like the Z except that rightmost leading zero will print as a $ and all zeroes to the left of that will print as spaces. So the value of 125.00 MOVEd to a PIC $$$,$$9.99 will print as ' $125.00'. This behavior of the $ is called 'floating'. An * will work the same way (for check protection) but all * print, not just the one to the left of the most significant digit. When either the floating $ or the * is used in conjunction with commas the comma will only print as a comma if the character to its left prints as a digit. Depending on the situation it will otherwise print as a blank, $ or *.</P> <P>For sign control you can use + or - as an output PIC character. A + will print + for positive numbers and - for negative numbers. A - will print a - for negative numbers and a blank for positive numbers. Either can be repeated to suppress leading zeroes (like the $) and can 'float' (also like the $). Alternatively, a + or - can be placed to the right of the number.</P> <P>For accounting purposes the PIC characters 'DB' and 'CR' can also be used (i.e. PIC $$$,$$9.99DB). The DB or CR will only show if the value is negative. If positive they will print blanks.</P> <P>Also see <A HREF="#blank">Blank When Zero</A>   <A HREF="#trunc">Truncation</A>.</P> <A class="index2" HREF="#toc" NAME="qual">Qualified Fields</A> <P>It is legal in COBOL for different <A HREF="#fields">fields</A> to have the same name. These fields <I>cannot</I> be 01-level fields and cannot be part of the same group-level field.</P> <P>When referencing one of these fields the compiler requires the field to be qualified, meaning its group-level field must be specified. If both INPUT-RECORD and OUTPUT-RECORD contained a field named PAY-RATE then in code you cannot simply reference PAY-RATE, it would have to either be PAY-RATE OF INPUT-RECORD or PAY-RATE OF OUTPUT-RECORD.</P> <A class="index2" HREF="#toc" NAME="refmod">Reference Modification</A> <P>Reference modification allows- for the referencing of a portion of a field without having to make it a group-level field and defining each portion of the field that will be accessed.</P> <P>If you wanted to check the value of the 4th through 6th characters of a field to see if they were equal to ABC you can code:</P> <TT><PRE> IF ws-FIELD (4:3) = 'ABC' </PRE></TT> <P>The first number in the parenthesis represents the start position in the field and the second number represents the length. Both values have to be specified. COBOL treats all such references as <A HREF="#datatype">alphanumeric</A>.</P> <P>Since this is not a self-documenting feature it should not be used carelessly.</P> <A class="index2" HREF="#toc" NAME="rpts">Reports</A> <P>A report is simply a formatted representation of data, suitable for being printed on paper (hardcopy). Reports generically look like:</P> <TT><PRE> 04/20/1999 The ABC Company Page 1 Payroll Register Employee Nbr Name Hours Rate Pay 123 45 6789 Ray, Marcus 40.0 2.00 80.00 456 78 9123 Gates, Willy 12.0 800.00 9,600.00 ... ... ... ... ... Totals: 1,002.5 258,125.00 </PRE></TT> <P>The first two lines are page headings, which will appear on every page. The next printed line (following the blank line) is column headings. It's common for column heading lines to be printed on every page. Next come the detail lines - typically one per record. At the end of the report will be a total line (if you are totalling anything). Note that the first detail line is the 6th line printed on a page (must count the blank lines also).</P> <P>There are other types of lines that can appear on reports. Sometimes there are page footings (printed on the bottom of each page). There can also be report headings and report footings (only printed at the top and bottom of the report as opposed to each page).</P> <P>Note the formatting of the data. There are commas and leading zeroes are suppressed on page numbers and monetary figures. The date has slashes. Always make reports as easy to read as possible.</P> <P>See the <A HREF="algs.html#report">algorithms</A> page for sample code.</P> <P>Also see <A HREF="#pic">PIC clauses</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="section">Sections</A> <P>A section is a group of <A HREF="#para">paragraphs</A>. The section name must begin in the 'A' margin and be followed by the word 'SECTION'. Naming standards for sections are the same as those for paragraphs. A section ends when a new one begins.</P> <P>A section can be <A HREF="#perform">PERFORMed</A> in the same manner a paragraph is PERFORMed. The PERFORM only uses the section name, there is no reference to it actually being a section instead of a paragraph.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="subindx">Subscripts and indexes</A> <P>Subscripts and indexes are the two tools used to reference individual elements of a <A HREF="#table">table</A>. A subscript is a working-storage <A HREF="#fields">field</A> defined separately from the table and is completely available to the programmer. An index01 is created automatically by the system if it is directed to do so and only has limited availability to the programmer.</P> <P>An index01 cannot be part of a calculation, cannot be <A HREF="#move">MOVEd</A> to another field or cannot receive another field from a MOVE and it cannot be <A HREF="#display"> DISPLAYed</A>. To manipulate an index01 the <A HREF="#set">SET</A> statement must be used.</P> <P>The major difference between a subscript and an index01 is that a subscript is a position in the table (first element, 20th element, etc.). An index01 is a byte offset of an element relative to the beginning of the table. Since the first element is 0 bytes away from the start of the table, it has an index01 of 0. The 20th element (say each element is a PIC X(5)) starts 95 bytes from the start of the table so its index01 is 95. When manipulating an index01 the programmer does not do so by this byte offset. It is done by position in the table and the translation to byte offset is done internally by COBOL.</P> <P>See the <A HREF="algs.html#tables">algorithms</A> page for sample code on loading and searching tables.</P> <P>Also see <A HREF="#occurs">OCCURS clause</A>,   <A HREF="#set">Set</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="table">Tables</A> <P>Tables are the COBOL equivalent to arrays. It is a set of <A HREF="#fields">fields</A> with the same name and the same <A HREF="#datatype">data type</A>. To reference an individual element of the table a <A HREF="#subindx">subscript or index01</A> must be used.</P> <P>Tables are defined using the <A HREF="#occurs">OCCURS clause</A>.</P> <P>See the <A HREF="algs.html#tables">algorithms</A> page for sample code on loading and searching tables.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="trunc">Truncation</A> <P>Truncation is a phenomenon that occurs when the receiving <A HREF="#fields">field</A> of a <A HREF="#move"> MOVE</A> or a math operation is not big enough to hold what it's getting. For <A HREF="#datatype">alphanumeric</A> fields truncation happens on the right (move 'COBOL' to a PIC X(4) and you get 'COBO') and <A HREF="#datatype">numeric</A> it happens on the left (move 1000005 to a PIC 9(06) and you get 5). No warnings, no messages. Just the loss of data.</P> <P>Also see <A HREF="#onsize">On Size Error</A>.</P> <!----------------------------------------------------------------> <! Statements and Clauses follow> <A class="index2" HREF="#toc" NAME="77-Levels">77-level Fields</A> <P>A working storage <A HREF="#fields">field</A> can be declared with a <A HREF="#lvlnbr">level number</A> of 77. The 77 must be in column 8, the field cannot be a group-level field and the field cannot be part of a group-level field.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="accept">ACCEPT</A> <P>The ACCEPT statement is used to get information from a source other than a data file (like the keyboard or CPU clock).</P> The statement: ACCEPT <A HREF="#fields"><I>field</I></A> . <br> <P>will cause the program to wait until the enter key is pressed. Any data typed in before the enter key is pressed will then be placed in <I>field</I>. See <A HREF="howto.html#interact">How do I ...?</A> for issues with getting <A HREF="#datatype">numeric data</A> in this manner. See the <A HREF="algs.html#interact">algorithms</A> page for sample code on receiving and processing data received interactively.</P> <P>The ACCEPT statement can also be used to get information from the system clock such as the current date and time:</P> <TT><PRE> 01 ACCEPT-FIELDS. 05 ACCEPT-YYYYMMDD PIC 9(8). 05 ACCEPT-HHMMSSHH PIC 9(8). 05 ACCEPT-DDD PIC 9(5). 88 IS-JAN-1ST VALUE 1. 88 IS-FEB-1ST VALUE 32. 05 ACCEPT-DAY-OF-WEEK PIC 9. 88 IS-MON VALUE 1. 88 IS-TUE VALUE 2. 88 IS-WED VALUE 3. 88 IS-THU VALUE 4. 88 IS-FRI VALUE 5. 88 IS-SAT VALUE 6. 88 IS-SUN VALUE 7. ... ACCEPT <I>ACCEPT-YYYYMMDD</I> FROM DATE. ACCEPT <I>ACCEPT-HHMMSSHH</I> FROM TIME. ACCEPT <I>ACCEPT-DDD</I> FROM DAY. ACCEPT <I>ACCEPT-DAY-OF-WEEK</I> FROM DAY-OF-WEEK. DISPLAY "ENTER SOMETHING? " WITH NO ADVANCING. ACCEPT <I>field-4</I>. </PRE></TT> <P>Where:</P><UL> <P>Also see <A HREF="#delim">Delimiters</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="add">Add</A> <P>The basic form of the ADD statement is:</P> <TT><PRE> ADD 1, 2, 3, field-n TO RESULT-1 <I>, result-2, ...</I>. ADD 1, 2, 3, field-n GIVING RESULT-1 <I>, result-2, ...</I>. ADD 1, 2, 3, TO field-n GIVING RESULT-1 <I>, result-2, ...</I>. ADD CORRESPONDING GROUP-NAME TO GROUP-NAME<I> ROUNDED ON SIZE ERROR ... NOT ON SIZE ERROR ...</I> END-ADD </PRE></TT> <P>Also see <A HREF="#round">Rounded</A>,   <A HREF="#onsize">On Size Error</A>,   <A HREF="#trunc">Truncation</A>,   <A HREF="#delim">Delimiters</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="blank">Blank When Zero</A> <P>'BLANK WHEN ZERO' can be specified with a <A HREF="#pic">PIC</A> clause so that blanks are printed if the value of the field is zero. For example, 'PIC -,--9.99 BLANK WHEN ZERO'.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="call">Call</A> <P>The CALL statement is used to call another program. As long as the called program contains a <A HREF="#goback">GOBACK</A> or <A HREF="#exitprog">EXIT PROGRAM</A> then when the called program finishes control returns to the calling program.</P> <P>Fields can be passed from the calling program to the called program. These fields are in the calling program's WORKING-STORAGE SECTION and in the called program's LINKAGE SECTION. The <A HREF="#using"> USING</A> clause on the CALL specifies the fields to pass. The called program lists these fields in the USING clause of the PROCEDURE DIVISION. These fields don't have to have the same name in both programs, but the definitions must match.</P> <PRE><TT> CALL 'PGM2.OBJ'. CALL 'PGM6F.OBJ' USING ws-FLD-1 ws-FLD-2 ws-FLD-3 ws-FLD-4 ws-FLD-5 END-CALL. </TT></PRE> <P>See the <A HREF="algs.html#call">algorithms</A> page for sample code on calling another program.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="close">Close</A> <P>The CLOSE statement will close an open file. Attempting to close a closed file will produce a run-time error.</P> <P>One CLOSE statement can close multiple files.</P> <PRE><TT> CLOSE <I>file-name-1</I> <I>file-name-2</I>. </TT></PRE><BR> <P>Also see <A HREF="#open">Open</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="compute">Compute</A> <P>COMPUTE allows- you to combine several math operations in one statement, using familiar symbols instead of English-like sentances.</P> <TT><PRE> COMPUTE <I>field-1</I> = <I>expression</I>. </PRE></TT> <P>Expression is any valid mathematical expression involving <A HREF="#literal">literals</A>, <A HREF="#fields"> fields</A> and the following symbols: + (add), - (subtract), * (multiply), / (divide), ** (exponentiation). To code 2 to the 3rd power use '2 ** 3'.</P> <P>The order of operations is as follows-:</P> <OL><LI>Exponentiation, from right to left</LI> <LI>Multiplication and division, from left to right</LI> <LI>Addition and subtraction, from left to right</LI></OL> <P>Parenthesis can also be used to force the order in which the operations are carried out. Expressions inside parenthesis are computed first, from the innermost parenthesis to the outermost.</P> <P>COMPUTE comes with a warning. Some compilers will round/truncate each intermediate result as opposed to waiting until the end of all calculations. This can lead to erroneous results.</P> <P>Also see <A HREF="#round">Rounded</A>,   <A HREF="#onsize">On Size Error</A>,   <A HREF="#trunc">Truncation</A>,   <A HREF="#delim">Delimiters</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="copy">Copy</A> <P>COPY will insert the contents of the specified file into the program containing the COPY when the program is compiled. The file being copied is normally referred to as a copybook. COPYs can appear in any of the divisions. A period must terminate the COPY.</P> <P>Record layouts are commonly in copybooks. Every program that reads or writes the file can contain a COPY instead of having the same record definition repeated in several programs. If the record layout is changed the change needs to be in one place and the programs recompiled to grab the more recent version.</P> <PRE><TT> FD IN-CUSTOMER-MASTER RECORD CONTAINS 1200 CHARACTERS. COPY CUSTMAST. </TT></PRE> <P>A specific location for the copybook can be specified on the COPY by using either 'OF' or 'IN', followed by the library name.</P> <PRE><TT> FD IN-CUSTOMER-MASTER RECORD CONTAINS 1200 CHARACTERS. COPY CUSTMAST OF CPYBOOKS. </TT></PRE> <P>COPY supports a REPLACING clause, where text in the copybook is altered once it is inserted in the program. The original copybook is unchanged. <A HREF="#literal">Literals</A> and identifiers can be changed simply by specifying them in the command. Text can also be replaced, but requires the source and target text to be in between pairs of equal signs.</P> <PRE><TT> COPY CUSTMAST REPLACING CUST-NUMBER BY CUST-NBR. COPY CUSTMAST REPLACING ==CUST-== BY ==CUSTOMER-==, ==9(5)== BY ==X(5)==. </TT></PRE> <P>The first will change the name of a field, assuming it exists in the copybook. The second will change every occurrence of 'CUST-' to 'CUSTOMER-' and change all '9(5)' to 'X(5)'. Some record layout copybooks will have a dummy prefix on each field name and each time it is COPYed the prefix is changed by a REPLACING on the COPY. This allows- for the copybook to used for multiple files in the same program - each COPY REPLACEs the dummy prefix with a different value avoiding having multiple fields with the same name.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="corr">Corresponding</A> <P>MOVE CORRESPONDING (or just MOVE CORR) is used with group-level fields. Whenever the source and target group-level fields have elementary fields of <I>exactly the same name</I> then that field will be moved. Consider the following:</P> <TT><PRE> 01 GROUP-1. 01 GROUP-2. 05 FIELD-A PIC 999. 05 FIELD-E PIC 99. 05 FIELD-B. 05 FIELD-A PIC 9(4). 10 FIELD-C PIC X(12). 05 FIELD-BB. 10 FIELD-D PIC XXX. 10 FIELD-C PIC XXX. 05 FIELD-E PIC 99. 10 FIELD-D PIC X. 05 FIELD-F PIC X. 05 FIELD-G PIC X(10). </PRE></TT> <P>The statement 'MOVE CORRESPONDING GROUP-1 TO GROUP-2' will cause both FIELD-A and FIELD-E to be moved. FIELD-C and FIELD-D have different group-level names so they don't correspond.</P> <P>This command is very useful when reformatting records. It can replace dozens, even hundreds, of moves.</P> <P>Also see <A HREF="#move">Move</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="delete">Delete</A> <P>DELETE will delete the current record in a non-sequential file <A HREF="#open">OPENed</A> as 'I-O'. There must be a current record, so a successful <A HREF="#read">READ</A> or <A HREF="#readnext">READ NEXT</A> must precede the DELETE.</P> <PRE><TT> DELETE OT-FILE RECORD. </TT></PRE> <P>DELETE specifies the file name, followed by the word 'RECORD'.</P> <P>See the <A HREF="algs.html#nonseq">algorithms</A> page for sample code on using non-sequential files.</P> <P>Also see <A HREF="#invkey">Invalid Key</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="display">Display</A> <P>The DISPLAY statement is used to show information on the terminal screen. Any combination of <A HREF="#literal">literals</A> and <A HREF="#fields">fields</A> can be displayed. All of the following are valid:</P> <TT><PRE> DISPLAY <I>field-name</I>. DISPLAY 'Now performing paragraph 2000-READ'. DISPLAY 'Employee number = ' ws-EMPLOYEE-NBR. </PRE></TT> <P>Can use the clause 'WITH NO ADVANCING' after the value being displayed to prevent the cursor from dropping down a line on the screen. This can be useful for prompts for an <A HREF="#accept">ACCEPT</A> statement:</P> <TT><PRE> DISPLAY 'Enter a number: ' WITH NO ADVANCING. ACCEPT ws-NBR. </PRE></TT> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="divide">Divide</A> <P>The basic form of the DIVIDE statement is:</P> <TT><PRE> DIVIDE <I>value</I> INTO <I>field-1</I>. </PRE></TT> <P>which divides <I>value</I> (either a <A HREF="#literal"> literal</A> or a <A HREF="#fields">field</A>) into <I>field-1</I> and stores the result in <I>field-1</I>.</P> <P>It is possible to store the result in a separate field with the GIVING clause. When using GIVING you can opt to divide BY instead of divide INTO. This changes the positions of the divisor and dividend:</P> <TT><PRE> DIVIDE <I>value-1</I> INTO <I>value-2</I> GIVING <I>field-1</I>. DIVIDE <I>value-1</I> BY <I>value-2</I> GIVING <I>field-1</I>. </PRE></TT> <P>You can also specify the remainder of the division to be stored in a separate field (only valid with GIVING):</P> <TT><PRE> DIVIDE <I>value-1</I> INTO <I>value-2</I> GIVING <I>field-1</I> REMAINDER <I>field-2</I>. </PRE></TT> <P>While it is legal in COBOL to have REMAINDER when not working with integers it makes little sense to do so.</P> <P>Also see <A HREF="#round">Rounded</A>,   <A HREF="#onsize">On Size Error</A>,   <A HREF="#trunc">Truncation</A>,   <A HREF="#delim">Delimiters</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="evaluate">Evaluate</A> <P>The EVALUATE statement can be used to replace a nested- <A HREF="#if">IF</A> construct. It is the equivalent of a CASE or SWITCH statement of other languages.</P> <TT><PRE> EVALUATE ws-GRADE WHEN 100 DISPLAY 'PERFECT' WHEN 90 THRU 99 DISPLAY 'A' WHEN 80 THRU 89 DISPLAY 'B' WHEN 70 THRU 79 DISPLAY 'C' WHEN OTHER DISPLAY 'WOULD YOU LIKE FRIES WITH THAT?' END-EVALUATE. </PRE></TT> <P>Each 'WHEN' can only have one statement, though it can be a <A HREF="#perform">PERFORM</A>. If multiple WHENs are true only the first one checked will execute. The 'WHEN OTHER' is like a 'none of the above'.</P> <P>If two WHENs are 'stacked' (no statement between them) they are treated like an 'OR'. For example:</P> <TT><PRE> EVALUATE ws-AGE WHEN 0 THRU 4 WHEN 70 THRU 99 DISPLAY 'TAKE A NAP' END-EVALUATE. </PRE></TT> <P>The display will execute if ws-AGE falls in either range.</P> <P>Instead of EVALUATEing a field you can use 'EVALUATE TRUE'. Each WHEN must then contain a <A HREF="#conditions">condition</A>. The first WHEN containing a true condition is executed. This method releases you from the restriction of checking the same field with each WHEN. Also valid is 'EVALUATE FALSE' where the first WHEN containing a false condition is executed.</P> <P><A HREF="#88-Levels">Condition names</A> cannot be used when EVALUATEing a field. Condition names can only be used with 'EVALUATE TRUE' or 'EVALUATE FALSE'. When EVALUATEing a field the WHENs contain values, not conditions.</P> <P>Use EVALUATE ALSO to evaluate multiple fields/conditions at the same time.</P> <TT><PRE> EVALUATE ws-SEX ALSO ws-MARITAL-STATUS WHEN 'F' ALSO 'S' MOVE 'MISS' TO ws-TITLE WHEN 'F' ALSO 'M' MOVE 'MRS.' TO ws-TITLE WHEN 'M' ALSO 'S' MOVE 'MR.' TO ws-TITLE WHEN 'M' ALSO 'M' MOVE 'POOR MR.' TO ws-TITLE WHEN OTHER DISPLAY 'CALL SECURITY' END-EVALUATE. </PRE></TT> <P>You can use EVALUTE TRUE and FALSE with ALSO. Each WHEN will then contain one condition for each TRUE or FALSE.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="exec">EXEC</A> <tt><pre> EXEC SQL INCLUDE STRUCTURES ALL VERSION 345 END-EXEC. EXEC SQL INCLUDE SQLCA END-EXEC. EXEC SQL BEGIN DECLARE SECTION END-EXEC. EXEC SQL INVOKE =PS_ERR_LOG_VW AS ERRLOG-TBL END-EXEC. 01 ws-HOST-FIELDS. 05 ws-H-ACCT-NUM PIC X(08) VALUE SPACES. 05 ws-H-ACCT-PGM PIC X(10) VALUE SPACES. 05 ws-H-DATE-TODAY PIC X(10) VALUE SPACES. 01 ws-HOST-INDICATORS. 05 ws-H-ACCT-PGM-I PIC S9(4) COMP. EXEC SQL END DECLARE SECTION END-EXEC. ... PROCEDURE DIVISION. EXEC SQL WHENEVER SQLERROR PERFORM :COMMON-SQL-ERROR END-EXEC. EXEC SQL WHENEVER SQLWARNING PERFORM :COMMON-SQL-WARNING END-EXEC. EXEC SQL SELECT PARM_VALUE INTO :ws-PARM-VALUE FROM =PS_APPL_PARMS_VW WHERE PROGRAM_NAME = "ACTMGRCB" AND PARM_NAME = :ws-ACCOUNT-RANGE-NAME FOR BROws-E ACCESS END-EXEC. IF SQLCODE NOT = 0 .... END-IF. COMMON-SQL-ERROR. ENTER TAL "SQLCADISPLAY" USING SQLCA COMMON-SQL-WARNING. MOVE 0 TO SQLCODE OF SQLCA. </tt></pre> <!----------------------------------------------------------------> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="exit">Exit</A> <P>EXIT is used as the only statement in a paragraph that isn't supposed to do anything. This typically is used in conjunction with <A HREF="#perform">PERFORM THRUs</A>. The <A HREF="#para">paragraph</A> being PERFORMed THRU is the one containing the EXIT.</P> <PRE><TT> PERFORM 300-READ-FILE THRU 300-EXIT. . . . . . . 300-READ-FILE. READ IN-FILE AT END MOVE 'Y' TO ws-EOF-SW GO TO 300-EXIT END-READ. . . . . (MUCH LOGIC) . . . . PERFORM 400-WRITE-RECORD THRU 400-EXIT. 300-EXIT. EXIT. </TT></PRE> Other uses are EXIT PROGRAM, EXIT SECTION, EXIT PARAGRAPH, EXIT PERFORM <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="goto">Go To</A> <P>GO TO is used to transfer control to another part of the program. The target of a GO TO is a <A HREF="#para">paragraph</A> name.</P> <P>Unlike a <A HREF="#perform">PERFORM</A> a GO TO will not return when the paragraph finishes.</P> <PRE><TT> GO TO 300-EXIT. </TT></PRE> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="goback">Goback</A> <P>GOBACK is used in a called program instead of a <A HREF="#stoprun">STOP RUN</A>. It will return execution to the calling program where a STOP RUN will terminate all currently running programs.</P> <P>Also see <A HREF="#exitprog">Exit Program</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="if">If</A> <P>The IF statement is used to limit the execution of code so that it only happens under certain <A HREF="#conditions">conditions</A>. The standard form is:</P> <TT><PRE> IF <I>condition</I> <I>statement(s)</I> END-IF. </PRE></TT> <P>The <I>statement(s)</I> are only executed if the <I>condition</I> is true. Each IF is allowed to have an ELSE. The <I>statement(s)</I> in the ELSE are only executed if the <I>condition</I> is false:</P> <TT><PRE> IF <I>condition</I> <I>statement(s)</I> ELSE <I>statement(s)</I> END-IF. </PRE></TT> <P>There must be at least one statement in either portion of the IF. If you do not want any processing done you can use the CONTINUE or NEXT SENTENCE statement:</P> <TT><PRE> IF <I>condition</I> CONTINUE ELSE <I>statement(s)</I> END-IF. </PRE></TT> <P>IFs can be nested (one IF inside another). COBOL will match an ELSE or an END-IF with the nearest IF that does not yet already have an ELSE or END-IF paired with it.</P> <P>IFs can also be used to check types. An <A HREF="#fields"> field</A> can be checked to see if it contains valid <A HREF="#datatype"> numerics</A> with:</P> <TT><PRE> IF <I>field</I> IS NUMERIC </PRE></TT> <P>IS NOT NUMERIC is also valid. In the same manner a numeric field can be checked to see if IS POSITIVE, IS NEGATIVE or IS ZERO.</P> <P>The END-IF <A HREF="#delim">delimiter</A> is not required. A period will end all IFs.</P> <P>Also see <A HREF="#evaluate">Evaluate</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="init">Initialize</A> <P>The INITIALIZE command is used to set all of the values for <A HREF="#fields">fields</A> in the same group-level field to either 0 or spaces, depending on the field's definition. The statement:</P> <TT><PRE> INITIALIZE ws-GROUP. </PRE></TT> <P>where:</P> <TT><PRE> 01 ws-GROUP. 05 ws-FIELD-1 PIC X(05). 05 ws-FIELD-2 PIC 999. 05 ws-FIELD-3 PIC S9(04)V99. 05 ws-FIELD-4 PIC X(100). </PRE></TT> <P>is the equivalent to MOVEing SPACES to ws-FIELD-1 and ws-FIELD-4 and MOVEing ZEROS to ws-FIELD-2 and ws-FIELD-3. The nice thing is that as elementary fields are added to the group the INITIALIZE will automatically take care of them.</P> <P>INITIALIZE will not change the value of any FILLER items. If a non-FILLER item has a <A HREF="#value">VALUE clause</A> it will still get either ZEROS or SPACES with the INITIALIZE statement. The VALUE is ignored.</P> <P>Also see <A HREF="#move">Move</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="inspect">Inspect</A> <P>INSPECT has two purposes. It can count the number of times a particular character appears in an alphanumeric string, and it can change those characters to another.</P> <TT><PRE> INSPECT <I>field-1</I> TALLYING <I>field-2</I> FOR <I>target</I>. </PRE></TT> <P>Where <I>field-1</I> is an alphanumeric field and <I>field-2</I> is a numeric field that will hold the count.</P> <P><I>target</I> has a few different possibilities. It can be the word CHARACTERS in which case <I>field-2</I> holds the number of characters in the alphanumeric string. Or a specific character can INSPECTed for using either ALL or LEADING followed by the character. Finally, any of these forms can be ended with a BEFORE/AFTER INITIAL clause:</P> <TT><PRE> INSPECT ws-A TALLYING ws-N FOR ALL '*' INSPECT ws-A TALLYING ws-N FOR LEADING SPACES INSPECT ws-A TALLYING ws-N FOR CHARACTERS AFTER INITIAL SPACE INSPECT ws-A TALLYING ws-N FOR ',' BEFORE INITIAL '0' </PRE></TT> <P>To use INSPECT to change particular characters in an alphanumeric string, use REPLACING instead of TALLYING. The CHARACTERS, ALL and LEADING clauses are valid with REPLACING, as is FIRST. You can also use the BEFORE/AFTER INITIAL clause with REPLACING.</P> <TT><PRE> INSPECT ws-A REPLACING ALL SPACES BY ZEROES INSPECT ws-A REPLACING FIRST 'A' BY 'B' INSPECT ws-A REPLACING ALL ' ' BY '0' AFTER INITIAL ',' </PRE></TT> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="invkey">Invalid Key</A> <P>The INVALID KEY clause is used with any type of non-sequential I-O statement. It specifies a statement to be executed if the command fails. Any statement such as READ or WRITE with any relative or index01ed file should include this clause. For example:</P> <TT><PRE> MOVE ws-KEY TO FILE-KEY. READ index01-FILE INVALID KEY PERFORM 300-RECORD-NOT-FOUND END-READ. </PRE></TT> <P>Upon an unsuccesful READ (for example, if no record in the file has that key) the specified statement is executed instead of the program crashing. There is an optional NOT INVALID KEY clause that can be included (must be after the INVALID KEY). It is best if only one statement is used in either the INVALID KEY or NOT INVALID KEY clause.</P> <P>See the <A HREF="algs.html#nonseq">algorithms</A> page for sample code on using non-sequential files.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="merge">Merge</A> <P>The merge is used to sort multiple files into one. Each of these files requires its own FD in the FILE SECTION, as does the combined file. All of these files must obviously have the same record format. The merge requires another entry in the FILE SECTION, an SD instead of an FD.</P> <TT><PRE> MERGE <I>sd-file-name</I> ON ASCENDING KEY <I>sd-field-name</I> USING <I>fd-input-file-name-1</I> <I>fd-input-file-name-2</I> GIVING <I>fd-output-file-name</I> </PRE></TT> <P>To sort multiple fields list them in the desired order. DESCENDING KEYs can be mixed with ASCENDING KEYs in the same MERGE (but only use 'ON' once). List the input files in the desired order in the USING clause.</P> <P>Like the <A HREF="#sort">SORT</A> an OUTPUT procedure can be specified (requiring a <A HREF="#return">RETURN</A>) instead of the GIVING, but the MERGE does not support the INPUT PROCEDURE option.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="move">Move</A> <P>The MOVE statement is used to place a value in a <A HREF="#fields">field</A>. It is kind of like an assignment statement in other languages though it does not allow for computations. Even though the statement is a move, it is more like a copy. The data is still in its original place as well as the receiving field. The standard form of statement is:</P> <TT><PRE> MOVE <I>value</I> TO <I>field</I>. </PRE></TT> <P>where <I>value</I> can be a <A HREF="#literal">literal</A> or a field. A list of fields can follow the TO causing the <I>value</I> to be MOVEd to each of the fields.</P> <P>With a <A HREF="#datatype">numeric</A> move the source and destination are checked for the location of the decimal place (if one is not explicitly defined it is assumed to be to the right of the rightmost digit) and the move is done based on that. For example, MOVEing the value 80.375 to a PIC 9(06)V99 will cause the receiving field to contain 80.37 and MOVEing the value 3.1415927 to a PIC 9(08) will cause the receiving field to contain 3.</P> <P><A HREF="#datatype">Alphanumeric</A> and <A HREF="#datatype">alphabetic</A> moves first move the leftmost character of the sending field to the leftmost character of the receiving field, then the next character, and so on. All group-level MOVEs are considered alphanumeric.</P> <P>If the receiving field is larger than the data being MOVEd then the field will be padded. Alphanumeric fields are padded on the right with spaces, numerics are padded on the left with zeroes. If a numeric has more decimal places than the data being MOVEd then zeroes will be padded on the right in the decimal portion of the receiving field.</P> <P>Also see <A HREF="#trunc">Truncation</A>,   <A HREF="#corr">Corresponding</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="multiply">Mulitply</A> <P>The basic form of the multiply statement is:</P> <TT><PRE> MULTIPLY <I>value</I> BY <I>field-1</I>. </PRE></TT> <P>which multiplys <I>value</I> (either a <A HREF="#literal"> literal</A> or a <A HREF="#fields">field</A>) by <I>field-1</I> and stores the result in <I>field-1</I>.</P> <P>It is possible to store the result in a separate field with the GIVING clause:</P> <TT><PRE> MULTIPLY <I>value-1</I> BY <I>value-2</I> GIVING <I>field-1</I>. </PRE></TT> <P>Also see <A HREF="#round">Rounded</A>,   <A HREF="#onsize">On Size Error</A>,   <A HREF="#trunc">Truncation</A>,   <A HREF="#delim">Delimiters</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="occurs">Occurs</A> <P>Occurs is used to define a table. It is followed by the number of elements in the table. COBOL does not support dynamic tables - the size must be specified.</P> <TT><PRE> 01 ws-TABLE. 05 ws-ELEMENT OCCURS 100 TIMES PIC 9(5). </PRE></TT> <P>Defines a table with 100 elements. The allowable <A HREF="#subindx">subscripts</A> for this table are 1 through 100. To access a specific element of the table you would use something like ws-ELEMENT (27). A space is required before and after the parenthesis. The subscript can be a <A HREF="#fields">field</A> but cannot be an expression. The subscript can be a separate working-storage numeric field or COBOL can told to create an <A HREF="#subindx">index01</A>, like in the following:</P> <TT><PRE> 01 ws-TABLE. 05 ws-ELEMENT OCCURS 100 TIMES index01ED BY ws-INDX PIC 9(5). </PRE></TT> <P>The field ws-INDX is automatically created by COBOL.</P> <P>The OCCURS can be on a group-level field which would then create a table containing multiple instances of each of the elementary fields. The OCCURS <I>cannot</I> appear on an 01-level field. It is also invalid on <A HREF="#77-Levels">77-level fields</A> and <A HREF="#88-Levels">88-level fields</A>.</P> <TT><PRE> 01 ws-TABLE-AREA. 05 ws-TABLE OCCURS 100 TIMES. 10 ws-KEY PIC XX. 10 ws-VALUE-1 PIC 9(5). 10 ws-VALUE-2 PIC 9(6)V99. </PRE></TT> <P>This would create 100 elements of each of the 3 elementary fields.</P> <TT><PRE> 01 FILLER VALUE 'MONTUEWEDTHUFRISATSUN'. 05 ws-DAYS-OF-WEEK OCCURS 7 TIMES. </PRE></TT> <P>Creates a table with 7 elements and also initializes them. This was not possible until a very recent version of COBOL. A <A HREF="#redef">redfines</A> had to be used.</P> <P>See the <A HREF="algs.html#tables">algorithms</A> page for sample code on loading and searching tables.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="onsize">On Size Error</A> <P>When used with one of the math verbs (<A HREF="#add">ADD</A>, <A HREF="#subtract">SUBTRACT</A>, <A HREF="#multiply">MULTIPLY</A>, <A HREF="#divide">DIVIDE</A>, <A HREF="#compute">COMPUTE</A>) it allows- COBOL to detect <A HREF="#trunc">truncation</A> and divide-by-zero situations and execute a specified instruction instead of doing the calculation. The one statement can be a <A HREF="#perform">PERFORM</A>. For example:</P> <TT><PRE> DIVIDE ws-TOTAL BY ws-COUNT GIVING ws-PCT ROUNDED ON SIZE ERROR MOVE 0 TO ws-PCT END-DIVIDE. </PRE></TT> <P>A statement can also be specified for 'NOT ON SIZE ERROR'.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="open">Open</A> <P>The open statement will open a file. Attempting to open an opened file will produce a run-time error. Accessing an unopened file will also produce a run-time error. You must specify whether the file is being opened as an input file or an output file.</P> <P>Opening an existing file as output will cause the contents of the file to lost immediately after it is opened.</P> <P>One read statement can open multiple files, even mixing input and output.</P> <PRE><TT> OPEN INPUT <I>file-name-1</I> <I>file-name-2</I>. OPEN OUTPUT <I>file-name-1</I> <I>file-name-2</I>. OPEN INPUT <I>file-name-1</I> <I>file-name-2</I> OUTPUT <I>file-name-3</I> <I>file-name-4</I>. </TT></PRE><BR> <P>Also see <A HREF="#close">Close</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="perform">Perform</A> <P>The perform statement will execute the specified <A HREF="#para">paragraph</A> and then control will return to the statement following the perform. There are no restrictions as to the physical placement of a paragraph compared to the perform statement that executes it.</P> <P>There are several variations controlling the performing of paragraphs. A paragraph cannot perform itself; COBOL has no recursion.</P> <PRE><TT> PERFORM <I>paragraph-name</I>. PERFORM <I>paragraph-name</I> WHILE <I>condition</I>. PERFORM <I>paragraph-name</I> UNTIL <I>condition</I>. PERFORM <I>paragraph-name</I> VARYING <I>field-1</I> FROM <I>value-1</I> BY <I>value-2</I> UNTIL <I>condition</I>. PERFORM <I>paragraph-name</I> <I>value-1</I> TIMES. </TT></PRE> <P>Where any of the <I>value</I>s can be <A HREF="#literal"> literals</A> or <A HREF="#fields">fields</A>.</P> <P>Each of the examples can also be specified with a THRU option, allowing for a sequence of paragraphs to be executed.</P> <PRE><TT> PERFORM <I>paragraph-name-1</I> THRU <I>paragraph-name-2</I> </TT></PRE> <P><I>Paragraph-name-2</I> will also be executed.</P> <P>There is also what's known as an in-line perform where a block of code appears between a PERFORM and END-PERFORM. No paragraph name is specified. For example:</P> <TT><PRE> PERFORM UNTIL ws-END-OF-FILE <I>statement(s)</I> READ IN-FILE AT END MOVE 'Y' TO ws-END-OF-FILE-SW END-READ END-PERFORM </PRE></TT> <P>When using the UNTIL option with a perform or in-line perform the 'UNTIL <I>condition</I>' clause can be preceded by 'WITH TEST AFTER' to have COBOL check the condition after the loop instead of before. This will cause the loop to always be executed at least once. This has the effect of a REPEAT-UNTIL loop of other languages.</P> <P>Also see <A HREF="#conditions">Conditions</A>   <A HREF="#delim">Delimiters</A>   <A HREF="#section">Sections</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="read">Read</A> <P>The read statement will read the next record from the specified file and place the data in the record layout of that file's FD. The file must be already open as input. Reading an unopend file or attempting to read beyond the end of a file will produce a run-time error. The AT END clause is required.</P> <PRE><TT> READ <I>file-name</I> AT END <I>statement</I> END-READ. </TT></PRE> <P>Optional clauses are NOT AT END and INTO. NOT AT END specifies a statement to be executed if the read did not hit the end of the file. INTO specifies a working-storage <A HREF="#fields">field</A> into which the system will place the input record.</P> <PRE><TT> READ <I>file-name</I> INTO <I>working-storage field</I> AT END <I>statement</I> NOT AT END <I>statement</I> END-READ. </TT></PRE><BR> <P>Also see <A HREF="#delim">Delimiters</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="readnext">Read Next</A> <P>The READ NEXT is used after a successful <A HREF="#start">START</A> to read records along the established access path. The condition used by the START is not "remembered" by the READ NEXT so after each successful READ NEXT the record must be checked to see if it still matches whatever criteria the program is calling for. A successful read only means that a record was retrieved.</P> <TT><PRE> READ <I>index01ed-file-name</I> NEXT RECORD AT END <I>statement</I> END-READ </PRE></TT> <P>Since this is still a "sequential" process the READ NEXT requires an AT END clause. The optional NOT AT END clause is supported.</P> <P>See the <A HREF="algs.html#altindex01">algortihms</A> page for code examples.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="redef">Redefines</A> <P>The REDEFINES clause allows- you to have multiple <A HREF="#fields">field</A> definitions for the same piece of storage. The same data then can be referenced in multiple ways.</P> <P>Take a simple example, useful for data validation:</P> <TT><PRE> 01 ws-NUMBER-X PIC X(8). 01 ws-NUMBER REDEFINES ws-NUMBER-X PIC 9(6)V99. </PRE></TT> <P>This portion of the data division only consumes 8 bytes of storage, not 16. Each of the two PIC clauses is describing the same 8 bytes of data, just doing it differently.</P> <P>Once data is in ws-NUMBER-X it can be checked to see if it is <A HREF="#datatype">numeric</A> (IF ws-NUMBER-X IS NUMERIC). If so, ws-NUMBER can then be used as part of a calculation. If the data happens to be non-numeric then this type of code will prevent the program from choking. We access the data as <A HREF="#datatype"> alphanumeric</A> (any data allowed) to see if it is safe to access it as numeric before actually attempting to do so.</P> <P>Note that once the data was moved to ws-NUMBER-X it was also moved to ws-NUMBER because they both describe the same portion of storage.</P> <P>There are a few rules with REDEFINES:</P> <UL><LI>A redefinition must have the same <A HREF="#lvlnbr">level number</A> as the field it is redefining</LI> <LI>The redefinition must immediately follow the field it is redefining (i.e. if an 05-level field is being redefined then the redefinition <B>must</B> be the next 05-level field)</LI> <LI>Cannot have a REDEFINES of an 01-level field in an FD</LI> <LI>The redefinition <I>should</I> be the same size as the field it is redefining though not all compilers require this</LI> <LI>It is possible to redefine at the group level though each group-level field does not have to the same number of elementary fields</LI> <LI>Not all compilers allow <A HREF="#value">VALUE</A> with REDEFINES. It's a bad idea in any case</LI> <LI>Can have multiple REDEFINES of the same field</LI></UL> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="release">Release</A> <P>The RELEASE statment is required in an INPUT PROCEDURE of a <A HREF="#sort">SORT</A>. It is used to specify that a record is to be included in the sort.</P> <TT><PRE> RELEASE <I>sd-record-name</I> RELEASE <I>sd-record-name</I> FROM </I>working-storage-field</I> </PRE></TT> <P>Only RELEASEd records will be sorted.</P> <P>See the <A HREF="algs.html#sort">algorithms</A> page for sample code on using the SORT statement.</P> <P>Also see <A HREF="#return">Return</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="return">Return</A> <P>The RETURN statment is required in an OUTPUT PROCEDURE of a <A HREF="#sort">SORT</A>. It is used to retrieve a record from the sort back into your program.</P> <TT><PRE> RETURN <I>sd-file-name</I> AT END <I>statement</I> END-RETURN </PRE></TT> <P>The records are RETURNed in the sorted order.</P> <P>Like the <A HREF="#read">READ</A> statement the RETURN supports the NOT AT END and INTO optional clauses. Also like the READ, it is best if only one statement is used in either the AT END or NOT AT END clauses.</P> <P>See the <A HREF="algs.html#sort">algorithms</A> page for sample code on the SORT statement.</P> <P>Also see <A HREF="#release">Release</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="rewrite">Rewrite</A> <P>REWRITE will update the current record in a non-sequential file <A HREF="#open">OPENed</A> as 'I-O'. There must be a current record, so a successful <A HREF="#read">READ</A> or <A HREF="#readnext">READ NEXT</A> must precede the REWRITE. Following the READ/READ NEXT and before the REWRITE some information on the record will presumably be changed.</P> <PRE><TT> REWRITE IN-FILE-REC. </TT></PRE> <P>REWRITE specifies the record, not the file.</P> <P>See the <A HREF="algs.html#nonseq">algorithms</A> page for sample code on using non-sequential files.</P> <P>Also see <A HREF="#invkey">Invalid Key</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="round">Rounded</A> <P>Rounded is a clause valid with any of the math verbs (<A HREF="#add">ADD</A>, <A HREF="#subtract">SUBTRACT</A>, <A HREF="#multiply">MULTIPLY</A>, <A HREF="#divide">DIVIDE</A>, <A HREF="#compute">COMPUTE</A>). Place it in the command after the name of the <A HREF="#fields">field</A> that will receive the result:</P> <PRE><TT> ADD IN-AMOUNT TO ws-BALANCE ROUNDED. MULTIPLY IN-HOURS BY IN-RATE GIVING ws-PAY ROUNDED. COMPUTE ws-CUBE ROUNDED = ws-NBR ** ws-POWER. </TT></PRE> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="search">Search</A> <P>The search command is used to search a <A HREF="#table"> table</A> for a particular entry. The table must have an <A HREF="#subindx">index01</A> (see <A HREF="#occurs"> OCCURS</A>). The format is:</P> <PRE><TT> SEARCH <I>field</I> AT END <I>statement-1</I> WHEN <I>condition</I> <I>statement-2</I> END-SEARCH. </TT></PRE> <P>The <I>field</I> is the field with the OCCURS clause. WHEN specifies the <A HREF="#conditions">condition</A> on which to end the search (usually when some field equals a table entry) Only one statement can be specified in the WHEN but it can be a <A HREF="#perform">PERFORM</A>. The AT END clause is optional, specifying one statement to be executed if the entire table is searched without satisfying the WHEN condition. It is recommended, however.</P> <P>For example:</P> <PRE><TT> * ALWAYS SET THE index01 TO 1 BEFORE A SEARCH SET ws-INDX TO 1. SEARCH ws-TABLE AT END MOVE ZEROES TO SALES-TAX WHEN IN-STATE = ws-TABLE-STATE (ws-INDX) MOVE ws-TABLE-TAX TO SALES-TAX END-SEARCH. </TT></PRE> <P>There can be multiple WHENs but the search stops once the condition of a WHEN is satisfied. To allow for multiple search matches use a <A HREF="#perform">PERFORM VARYING</A>, which can increment an index01.</P> <P>If the table entries are sequenced by the field being searched then a binary search can be used instead. Use SEARCH ALL instead of SEARCH. It is more efficient than a regular search, especially with large tables. The SEARCH ALL has some limitations:</P> <UL><LI>Only one WHEN is permitted</LI> <LI>The WHEN condition can only test equality</LI> <LI>The WHEN condition cannot contain an OR</LI> <LI>The table field must be to the left of the = in the condition</LI></UL> <P>See the <A HREF="algs.html#tables">algorithms</A> page for sample code on loading and searching tables.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="set">Set</A> <P>Set can be used to manipulate an <A HREF="#subindx"> index01</A>:</P> <TT><PRE> SET ws-INDX TO ws-NUMBER. SET ws-INDX UP BY 1. SET ws-INDX DOWN BY 3. </PRE></TT> <P>Note that while an index01 is actually a byte offset within a table COBOL does not expect you to work on that level. Setting an index01 to 2 will cause it to point to the 2nd element in the table, regardless of its offset. Likewise, seting an index01 up one will move it to the next element in the table, regardless of the size of the element. COBOL will translate it to the proper offset for you.</P> <P>Set can also be used with <A HREF="#88-Levels">condition names</A> as an alternative to a <A HREF="#move">MOVE</A>. Consider the following:</P> <TT><PRE> 01 ws-END-OF-FILE-SW PIC X VALUE 'N'. 88 END-OF-FILE VALUE 'Y'. </PRE></TT> <P>It is then permissible to code:</P> <TT><PRE> SET END-OF-FILE TO TRUE. </PRE></TT> <P>This is the equivalent to "MOVE 'Y' TO ws-END-OF-FILE-SW" but it is more readable. Most compilers will not allow a condition name with multiple values to be used in a SET. It is not a good idea in any case.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="sort">Sort</A> <P>The sort statement is used to sort a file. It requires a work file area that is defined in the FILE SECTION, just like any other file, except it is an SD instead of an FD. The basic sort statement looks like:</P> <TT><PRE> SORT <I>sd-file-name</I> ON ASCENDING KEY <I>sd-field-name</I> USING <I>fd-input-file-name</I> GIVING <I>fd-output-file-name</I> </PRE></TT> <P>Multiple fields can be used in the sort, just list them in the desired order. DESCENDING KEY can be specified instead of ASCENDING KEY. DESCENDING KEY and ASCENDING KEY can be combined in the same statement.</P> <P>The SORT statement will open and close both the input and output files automatically. The field(s) to be sorted on must be defined in the SD of the sort file.</P> <P>An INPUT PROCEDURE can be specified instead of an input file. This allows- the flexibility of selecting specific records to be sorted or to do other types of processing before the sort. Likewise, an OUTPUT PROCEDURE can be used instead of an output file. An INPUT PROCEDURE requires a <A HREF="#release"> RELEASE</A> statement and an OUTPUT PROCEDURE requires a <A HREF="#return">RETURN</A> statement. For example:</P> <TT><PRE> SORT <I>sd-file-name</I> ON ASCENDING KEY <I>sd-field-name</I> INPUT PROCEDURE IS <I>paragraph-1</I> OUTPUT PROCEDURE IS <I>paragraph-2</I> </PRE></TT> <P>This statement will execute <I>paragraph-1</I>, perform the sort and then execute <I>paragraph-2</I>. An INPUT PROCEDURE can be used with GIVING and an OUTPUT PROCEDURE can be used with USING. Each of these options allows- the THRU option (i.e. <I>paragraph-a</I> THRU <I>paragraph-b</I>).</P> <P>The clause 'WITH DUPLICATES IN ORDER' can be included in the statement (after the last ASCENDING/DESCENDING KEY). This will cause any records with the same value(s) for the sort field(s) to be kept in their original order. Not specifying this will not necessarily change their original order, but there is no guarantee.</P> <P>See the <A HREF="algs.html#sort">algorithms</A> page for sample code on using the SORT statement.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="start">Start</A> <P>The Start statement is used to establish an access path for an index01ed file with alternate keys (see the <A HREF="algs.html#altindex01">algortihms</A> page for code examples). Note that keys in alternate index01es are not necessarily unique and the START is used in conjunction with the <A HREF="#readnext"> READ NEXT</A> statement to find and retrieve and these records.</P> <PRE><TT> START <I>index01ed-file-name</I> KEY EQUALS <I>alternate-key-field-in-FD</I> END-START </TT></PRE> <P>The alternate key field must already be populated with a value.</P> <P>The first record in the file with that value for the alternate key is read. It is a good idea to include a <A HREF="#invkey">INVALID KEY</A> clause in any START to handle the case where there is no record in the file with the appropriate alternate key.</P> <P>Instead of 'EQUALS' the START also supports '>' and 'NOT <'.</P> <P>With some compilers a START with an EQUALS will read a record if an appropriate one exists, but a START with a '>' or 'NOT <' will not retrieve a record under any circumstances. Other compilers will never have a START actually read a record.</P> <P>See the <A HREF="algs.html#nonseq">algorithms</A> page for sample code on using non-sequential files.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="stoprun">Stop Run</A> <P>The stop run statement will cause a normal termination to your program.</P> <PRE><TT> STOP RUN. </TT></PRE><BR> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="string">String</A> <P>The STRING is used to concatenate (join) multiple fields or <A HREF="#literls">literals</A> into one field. It replaces a series of <A HREF="#move">MOVEs</A>. For example:</P> <TT><PRE> 01 ws-DATE-FIELDS. 05 ws-YEAR PIC X(4) VALUE '2000'. 05 ws-MONTH PIC XX VALUE '12'. 05 ws-DAY PIC XX VALUE '24'. 01 ws-DISPLAY-DATE PIC X(10). ..... STRING ws-MONTH DELIMITED BY SPACE '/' DELIMITED BY SIZE ws-DAY DELIMITED BY SPACE '/' DELIMITED BY SIZE ws-YEAR DELIMITED BY SPACE INTO ws-DISPLAY-DATE. </PRE></TT> <P>After the above statement is executed ws-DISPLAY-DATE will contain '12/24/2000'. DELIMITED BY SPACE means to use as much of that field or literal that appears before the first space. If there are no spaces (like in the example) then the entire field or literal is used. Any character can be used in the DELIMITED BY clause.</P> <P>Literals are usually DELIMTED BY SIZE, meaning to use the whole thing.<P> <P>The DELIMITED BY character is never included in the combined field.</P> <P>Also see <A HREF="#unstring">Unstring</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="subtract">Subtract</A> <P>The basic form of the subtract statement is:</P> <TT><PRE> SUBTRACT <I>value</I> FROM <I>field-1</I>. </PRE></TT> <P>which subtracts <I>value</I> (either a <A HREF="#literal"> literal</A> or a <A HREF="#fields">field</A>) from <I>field-1</I> and stores the result in <I>field-1</I>. A list of fields can follow the FROM which will subtract the value from each of them. A list of values can be before the FROM which would subtract all of them from <I>field-1</I>.</P> <P>It is possible to store the result in a separate field with the GIVING clause:</P> <TT><PRE> SUBTRACT <I>value-1</I> FROM <I>value-2</I> GIVING <I>field-1</I>. </PRE></TT> <P>Also see <A HREF="#round">Rounded</A>,   <A HREF="#onsize">On Size Error</A>,   <A HREF="#trunc">Truncation</A>,   <A HREF="#delim">Delimiters</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="unstring">Unstring</A> <P>The UNSTRING is used to split a field into multiple fields using a particular character to determine where to split the field. For example:</P> <TT><PRE> 01 ws-NAME-FIELDS. 05 ws-FIRST PIC X(10). 05 ws-MIDDLE PIC X. 05 ws-LAST PIC X(14). 01 ws-WHOLE-NAME PIC X(25) VALUE 'HOMER J SIMPSON'. ..... UNSTRING ws-WHOLE-NAME DELIMITED BY SPACE INTO ws-FIRST, ws-MIDDLE, ws-LAST. </PRE></TT> <P>The above statement will take the all of WHOLE-NAME, up to but not including the 1st space, and place it into ws-FIRST. The the part that is between the 1st and 2nd spaces, not including either one, is placed in ws-MIDDLE, and so on.<P> <P>Also see <A HREF="#string">String</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="usage">Usage</A> <P>USAGE can be used in conjunction with the <A HREF="#pic">PIC clause</A> to specify how numeric data is to be stored. The most common options are DISPLAY (the default), COMP and COMP-3. COMP is short for COMPUTATIONAL, which can also be used. The words 'USAGE IS' are optional. USAGE is only valid with <A HREF="#datatype">numeric</A> fields. It can be specified as follows-:</P> <TT><PRE> 01 ws-FIELDS. 05 ws-DISPLAY-1 PIC 9(4). 05 ws-DISPLAY-2 PIC 999 USAGE IS DISPLAY. 05 ws-COMP-1 PIC S9999 USAGE IS COMPUTATIONAL. 05 ws-COMP3-1 PIC 9(5)V99 COMP-3. </PRE></TT> <P>A number stored as COMP is in binary format. A COMP-3 number is stored as packed-decimal.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="using">Using</A> <P>The USING clause is used to pass parameters from one program to another. It appears in the <A HREF="#call">Call</A> statement of the calling program to specify the parameter list. These parameters must be working storage fields.</P> <P>The called program must have a USING clause on its PROCEDURE DIVISION statement followed by the parameters the program is receiving. These fields are defined in the LINKAGE SECTION of the DATA DIVISION, which follows- the WORKING-STORAGE SECTION. All of the received fields are updateable by the called program.</P> The parameters do not have to have the same names in the calling and called programs but the sizes and data types have to match.</P> <TT><PRE> (In calling program) CALL 'PGM2.OBJ' USING ws-FIELD-1, ws-FIELD-2, ws-FIELD-3 END-CALL (In called program) PROCEDURE DIVISION USING LK-FIELD-A, LK-FIELD-B, LK-FIELD-C </PRE></TT> <P>See the <A HREF="algs.html#call">algorithms</A> page for sample code on calling one program from another.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="value">Value</A> <P>Value allows- you to initialize a field at the same time it is defined. The VALUE clause follows- the <A HREF="#pic">PIC clause</A> and must be the proper type of data. The value can be changed in code at any time.</P> <TT><PRE> 05 ws-NBR-LINES-PER-PAGE PIC 99 VALUE 60. 05 FILLER PIC X(6) VALUE 'PAGE: '. </PRE></TT> <P>Some compilers will require the VALUE data to be the proper size also, others will <A HREF="#trunc">truncate</A> to fit. Most compilers will not allow VALUEs in input FDs - it is a bad idea in any case.</P> <P>Also see <A HREF="#contin">Continuation</A>   <A HREF="#init">Initialize</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="write">Write</A> <P>The write statement will write data to the specified file. The file must be opened for output. Attempting to write to an unopened file or a file opened for input will produce a run-time error.</P> <PRE><TT> WRITE <I>record-name</I>. </TT></PRE><BR> <P>Optional clauses are FROM, BEFORE and AFTER. FROM specifies a working-storage <A HREF="#fields">field</A> from which the system will select the data that is to be written. FROM can appear with either BEFORE or AFTER.</P> <P>BEFORE and AFTER specify actions to be taken by the printer along with writing a record of data. You can either specify the number of lines that are to be advanced or you can specify advancing to the top of the next page. BEFORE and AFTER cannot appear in the same write.</P> <PRE><TT> WRITE <I>record-name</I> FROM <I>working-storage field</I> END-WRITE. WRITE <I>record-name</I> AFTER ADVANCING <I>value</I> LINES END-WRITE. WRITE <I>record-name</I> AFTER PAGE END-WRITE. </TT></PRE><BR> <P>Where <I>value</I> can be a <A HREF="#literal">literal</A> or a <A HREF="#fields">field</A>.</P> <P>Also see <A HREF="#delim">Delimiters</A>.</P> <!----------------------------------------------------------------> <A class="index2" HREF="#toc" NAME="definitions">DEFINITIONS</A> <pre> <a name="Reserve2Areas" href="javascript:history.back()">Reserve2Areas</a> RESERVE n <I>AREA|AREAS</I> . RESERVE 1 = No block buffering is used RESERVE 2 = use FAST I-O RESERVE 32 = SEQUENTIAL BLOCK BUFFERING is used </pre> <pre> <a class="index1" name="filename" href ="javascript:history.back()">FileName</a> \Node.$VOL.SUBVOL.File =DefineName Defines names are entered in Tacl as: ADD DEFINE =definename, CLASS MAP, FILE \now.$VOL.SUBVOL.FILE </pre> <pre> </pre> </BODY> <script type="text/javascript"> function ShowHideDiv(xdh0, xdh1, xdh2, xdh3, xdh4, xdh5) { var xxSize = 5; var xx = new Array() xx[0] = xdh0; xx[1] = xdh1; xx[2] = xdh2; xx[3] = xdh3; xx[4] = xdh4; xx[5] = xdh5; //for (n=1;n<=xxSize;n++){HideDiv(xx[n])} if (document.getElementById(xx[0]).style.display == 'none') { ShowDiv(xx[0]) } else { HideDiv(xx[0]) } } function ShowDiv(xdx) { if (!document.getElementById(xdx)) { return; } document.getElementById(xdx).style.visibility = 'visible'; document.getElementById(xdx).style.display = 'block'; document.cookie = xdx + '=visible; expires=Sun, 1 Jan 2006 20:47:11 UTC; path=/'; } function HideDiv(xdx) { if (!document.getElementById(xdx)) { return; } document.getElementById(xdx).style.visibility = 'hidden'; document.getElementById(xdx).style.display = 'none'; document.cookie = xdx + '=hidden; expires=Sun, 1 Jan 2040 20:47:11 UTC; path=/'; } </script> </HTML> |
04/09/2011 18:22:28 jim BuschGardens-Wedding | Sat |||||||||||||||||||
04/09/2011 18:12:28 jim BuschGardens-Kangaroos | Sat |||||||||||||||||||
04/09/2011 17:32:54 jim BuschGardens-DMX | Sat |||||||||||||||||||
04/09/2011 17:06:55 jim BuschGardens Coaster | Sat |||||||||||||||||||
04/09/2011 16:34:08 jim BushGardens-Jim,Becky | Sat |||||||||||||||||||
04/09/2011 14:48:24 jim DavisIsland Festival-Planes | Sat |||||||||||||||||||
04/03/2011 20:10:18 jim StPetersburg-ByTheBay | Sun |||||||||||||||||||
04/02/2011 19:32:52 jim ClearwaterBeach-Beach | Sat |||||||||||||||||||
04/02/2011 18:32:04 jim ClearwaterBeach-Pirate | Sat |||||||||||||||||||
04/02/2011 18:16:20 jim ClearwaterBeach-Break Dancin | Sat |||||||||||||||||||
04/02/2011 17:57:26 jim ClearwaterBeach, FL | Sat |||||||||||||||||||
04/02/2011 15:52:10 jim NewportRichie-Falcons | Sat |||||||||||||||||||
04/02/2011 15:48:42 jim NewportRichie-Indians | Sat |||||||||||||||||||
04/02/2011 15:43:38 jim NewportRichie-HulaDancer | Sat |||||||||||||||||||
04/02/2011 15:41:22 jim NewportRichie Fair-20110402 | Sat |||||||||||||||||||
04/02/2011 15:40:36 jim NewportRichie Fair | Sat |||||||||||||||||||
03/25/2011 10:48:04 jim Clearwater Turtles | Fri |||||||||||||||||||
03/25/2011 10:45:22 jim Clearwater Pool | Fri |||||||||||||||||||
03/24/2011 15:43:16 jim BuschGardens-Charo | Thu |||||||||||||||||||
03/24/2011 14:28:04 jim BuschGardens-PrairieDogs | Thu |||||||||||||||||||
03/24/2011 14:06:04 jim BuschGardens-Africa | Thu |||||||||||||||||||
03/24/2011 13:41:46 jim BuschGardens-Egypt | Thu |||||||||||||||||||
03/24/2011 13:35:56 jim BuschGardens-Coasters | Thu |||||||||||||||||||
03/24/2011 13:31:12 jim BuschGardens-Gators | Thu |||||||||||||||||||
03/24/2011 12:17:46 jim BuschGardens-RhinoRally | Thu |||||||||||||||||||
03/24/2011 12:16:22 jim Tampa-I275 | Thu |||||||||||||||||||
03/22/2011 09:59:49 jim Dustin leaves for BootCamp Today | Tue |||||||||||||||||||
Don't forget to call him. |
03/18/2011 15:26:26 jim Pelican Island-Whiskey Joes | Fri |||||||||||||||||||
03/18/2011 15:02:18 jim Whiskey Joes-Becky,Jim | Fri |||||||||||||||||||
03/18/2011 14:58:12 jim BayToShore Pulloff | Fri |||||||||||||||||||
03/17/2011 06:09:39 jim Watched 24 - Season 7 | Thu |||||||||||||||||||
It took 20 hours! |
03/16/2011 16:33:46 jim BuschGardens-Ape Habitat | Wed |||||||||||||||||||
03/16/2011 16:24:46 jim BuschGardens-Zebra | Wed |||||||||||||||||||
03/16/2011 15:19:14 jim BuschGardens-The Phoenix | Wed |||||||||||||||||||
03/16/2011 15:02:34 jim BuschGardens-Rhino | Wed |||||||||||||||||||
03/16/2011 15:01:58 jim BuschGardens-Elephants | Wed |||||||||||||||||||
03/16/2011 14:03:08 jim BuschGardens | Wed |||||||||||||||||||
03/16/2011 13:27:28 jim BuschGardens-Tigers | Wed |||||||||||||||||||
03/16/2011 13:01:44 jim BuschGardens-Coaster | Wed |||||||||||||||||||
03/16/2011 12:42:44 jim BuschGardens-Tony Orlando | Wed |||||||||||||||||||
03/16/2011 12:30:30 jim BuschGardens-Birds | Wed |||||||||||||||||||
<< 04/2010 < 03/2011 Calendar 05/2011 > 04/2012 >> | Sign InView Other Logs |