AcuSort Code Sample

The following sample code describes the SELECT and FD for an orders-detail indexed file:

SELECT OPTIONAL Orders-Detail
           ASSIGN       TO DISK "ORDRDETL"
           ORGANIZATION IS INDEXED
           ACCESS MODE  IS DYNAMIC
           LOCK MODE    IS AUTOMATIC
           FILE STATUS  IS ORDERS-DETAIL-STATUS
           RECORD KEY   IS Prime = ORDERS-DETAIL-PRIMARY-KEY


       FD  ORDERS-DETAIL.
       01 ORDERS-DETAIL-RECORD.
           05 ORDERS-DETAIL-PRIMARY-KEY.
               10 ORDETL-CUSTOMER  PIC  X(10).
               10 ORDETL-DATE.
                   15 ORDETL-DT-YYYY   PIC  9(4).
                   15 ORDETL-DT-MM     PIC  99.
                   15 ORDETL-DT-DD     PIC  99.
               10 ORDETL-TIME.
                   15 ORDETL-HR        PIC  99.
                   15 ORDETL-MIN       PIC  99.
                   15 ORDETL-SEC       PIC  99.
                   15 ORDETL-TH-SEC    PIC  99.
               10 ORDETL-PROD-NO   PIC  X(10).
           05 ORDETL-DESCRIPTION           PIC  X(80).
           05 ORDETL-QTY       PIC  9(5).
           05 ORDETL-PRICE     PIC  9(9)v99.
           05 ORDETL-TOTAL-PRICE           PIC  9(9)v99.

In this sample, we illustrate the sort of the orders-detail file based on three fields: orderl-customer, ordetl-price, and ordetl-description. Each field is to be sorted in ascending order, and the resulting output file includes only records in which ordetl-date is equal to or greater than May 3, 2006.

The AcuSort take file paramfile1 contains the following options:

sort fields (1, 10, ch, a, 122, 11, nu, a, 37, 80, ch, a)
use c:\acuprod\data\ordrdetl org ix
   record f 143
   key (1, 36, P)
give c:\acuprod\data\ordrdet_sorted
   include cond = 11 8 nu ge 20060503

If we include our AcuSort instructions in a take file named paramfile1, our command line would be

acusort take paramfile1