Example and How-to Programs

Several example programs are available for students. They show many COBOL commands used to process reports for student file. The files are available in TSO at ba0112.sample.cbl and are named exmpl1 through exmpl5 (How do I get there?)

Some example programs on the web with explanations:
File nameNamePurpose
exmpl1Example 1See how a simple program works. Click on a line number and you'll get an explanation of what that line does
exmpl2Example 2See how to do a page break (print new pages when you reach too many lines), with code and an explanation for each step
exmpl485Example 4 in COBOL 85See how to do a control break, with code and an explanation for each step

Getting to the sample programs

To get to the sample programs in the TSO, select edit (option 2) from the main menu and then type in the following values and hit enter:

Project: ba0112

Group: sample

Type: cbl

Member: exmpl1 (type exmpl2 if you want the second example, exmpl3 for the third, etc.)


   Menu  RefList  RefMode  Utilities  LMF  Workstation  Help
 ------------------------------------------------------------------------------
                                Edit Entry Panel             
 Command ===>
 
 ISPF Library:
    Project . . . ba0112
    Group . . . . sample   . . .          . . .          . . .
    Type  . . . . CBL
    Member  . . .                 (Blank or pattern for member selection list)
 
 Other Partitioned or Sequential Data Set:
    Data Set Name . . .
    Volume Serial . . .           (If not cataloged)
 
 Workstation File:
    File Name . . . . .
 
 Initial Macro  . . . .                  Options
 Profile Name . . . . .                  /  Confirm Cancel/Move/Replace
 Format Name  . . . . .                     Mixed Mode
 Data Set Password  . .                     Edit on Workstation
 

Printing the sample programs

To print the sample program, type dsprint at the command ===> prompt. Then type 'ba0112.sample.cbl(exmpl1)' for the dataset, rmt15 for the destination (Adams Hall printer), and ALL for both the column and lines range. Then hit enter to print. You should get a message, PROCESSING HAS BEEN COMPLETED FOR DATASET. Press enter to clear the message. If you got an error message, check how you spelled the dataset and try again. Press F3 to exit out of the printer menu.

--------------------------------  DSPRINT  ------------------------------------
 Command ===>
                   Dataset ===> 'ba0112.sample.cbl(exmpl1)'
 
                     Forms ===>                 (PRT2/0111/...)
               Destination ===> Rmt15           (MRAW/MRB2/LOCAL/RMT3/...)
          Print train(UCS) ===>                 (TN or PN - Default is any)
 Forms control buffer(FCB) ===>                 (8068/8088/...)
                    Copies ===>                 (Defaults to 1)
                      Fold ===>                 (Defaults to 132)
                  Truncate ===>                 (Defaults to no-truncate)
                   Spacing ===>                 (Single/Double/Cchar)
                     Eject ===>                 (Y/N)
              Column range ===> ALL             (e.g. 16:22)
               Lines range ===> ALL             (e.g. 1000:1500)
         Line number field ===>                 (e.g. NUM(73,8) OR NONUM)
                Top margin ===>                 (Default is  0)
               Page length ===>                 (Default is 55)
             Bottom margin ===>                 (Default is  0)
 
      Press ENTER to print the dataset using the options above, or
      Press the END KEY to exit without printing