You are here: Home > Knowledge Refreshers

KR editions 31 to 32


KR- 31, 32 (SPECIAL NAMES)

Have you ever wondered about the highlighted line (which appears in many COBOL codes which produce reports)? 

CONFIGURATION SECTION. 

SOURCE-COMPUTER. IBM-370-168. 
OBJECT-COMPUTER. IBM-370-168. 

SPECIAL-NAMES. C01 IS TO-TOP-OF-PAGE. 

or perhaps something like 

SPECIAL-NAMES. 
C01 IS TOP-PAGE. 

Special names are used to give alternate user defined names to system-defined environment variables. (Might sound a little wierd but read on.....). 

Using special-names, you can assign values to variables which are not declared in your code (like the CURRENCY SIGN example which we'll look at tommorrow) or you can also provide alternate names to system defined environment variables, as in: 

SPECIAL-NAMES. C01 IS TO-TOP-OF-PAGE. 

C01 - C12 are known as printer channels (or rather they can be used to emulate printers). In simple terms they can be used for line and form-feeds (i.e. form feed is writing to a new page). So in the above statement we just define TO-TOP-OF-PAGE as an alternate name for C01. In our code we would write: 

WRITE FILE-REC FROM DATA-REC AFTER ADVANCING TO-TOP-OF-PAGE 

and if you take a look at the file (where you've written the record) you'll find the form feed on column 1, line 1 (it might just be the character 1 at that position). And you can see this only in VIEW mode and not in BROWSE mode. 

Let's take another simple example: 

By default the currency sign used in COBOL is the dollar $. Now if you want to use something other than $ (let's say @), then you can do so by defining this in the SPECIAL-NAMES section. 

SPECIAL-NAMES. CURRENCY SIGN IS '@'. 

Now in the code (or working-storage variable) you can use @ instead of $. Ex: 

01 WS-CURR2 PIC @9(4). 

When you display WS-CURR2 the output will have a @. If you moved the value 9999 then the display would be: @9999 

Summary: 

Special names are used to give alternate user defined names to system-defined environment variables (like the C01 example). 

Using special-names, you can assign values to variables which are not declared in your code (like the CURRENCY SIGN example)


 

 



Go back to the main contents page