ContentsIndexPreviousNext

6.1 Preparing and Compiling Your COBOL Program

After the environment has been set up for Acu4GL, you are ready to use the system. The following example illustrates how to set up a COBOL program to use your Acu4GL RDBMS product.


Note: If you are not familiar with the XFD directives described in Chapter 4, "Using Directives," you may want to read that chapter before continuing with this section.

The purchase-orders file from a COBOL program at an imaginary company will be stored in the database. This file contains the records that handle all of the information from the company's purchase orders.

Within the purchase-orders file, are two record types:

The file is keyed off the purchase-order-number. We will build and examine the database table three times, to illustrate three different approaches to using the COBOL file description:

Here's the sample code:

IDENTIFICATION DIVISION.
program-id.  purchase.
ENVIRONMENT DIVISION.
input-output section.
file-control.

select p-o-file
assign to disk "purch1"
organization is indexed
access mode is dynamic
record key is p-o-number
file status is p-o-status.

DATA DIVISION.
file section.
fd p-o-file.
01 p-o-record.
   03 p-o-division-number                pic 9(3).
   03 p-o-record-type                    pic x.
      88 header-record                   value "h".
      88 detail-record                   value "d".
   03 p-o-number                         pic 9(10).
   03 p-o-number-detail redefines
         p-o-number.
      05 picking-ticket-number           pic 9(6).
      05 shipping-region                 pic 9(2).
      05 p-o-customer-type               pic 9(2).
      05 p-o-customer-breakdown redefines
            p-o-customer-type.
         07 customer-category            pic x.
         88 p-o-customer-retail          value "r".
         88 p-o-customer-whlsale         value "w".
         07 customer-pay-format          pic x.
            88 is-net-30                 value "3".
            88 is-net-10                 value "1".
   03 p-o-date.
      05 p-o-yy                          pic 9(2).
      05 p-o-mm                          pic 9(2).
      05 p-o-dd                          pic 9(2).

01 p-o-detail-record.
   03 p-o-dept-number                    pic 9(3).
   03 p-o-record-type                    pic x.
   03 detail-p-o-number                  pic 9(10).
   03 p-o-shipping-info.
      05 p-o-quantity-to-ship            pic s9(4) comp.
      05 p-o-total-quantity              pic s9(4) comp.
   03 p-o-notes.
      05 notes-line occurs 3 times       pic x(40).
working-storage section.
01 p-o-status                            pic x(2).

PROCEDURE DIVISION.
level-1 section.
main-logic.

open output p-o-file.
close p-o-file.
stop run.

More:

6.1.1 Approach One

6.1.2 Approach Two

6.1.3 Approach Three