HPlogo MPE XL Native Language Programmer's Guide: 900 Series HP 3000 Computer Systems > Appendix F Example Programs

Sort from a COBOLII Program

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

This program shows how to sort an input file (formal designator INPTFILE) to an output file (formal designator OUTPFILE) using a COBOLII SORT verb.

Lines 3.5 and 4.1 show how to specify the language to determine the collating sequence.

   1     $CONTROL USLINIT

   1.1    IDENTIFICATION DIVISION.

   1.2    PROGRAM-ID.    EXAMPLE.

   1.3   * ------------------------------------------------

   1.4    ENVIRONMENT DIVISION.

   1.5    INPUT-OUTPUT SECTION.

   1.6    FILE-CONTROL.

   1.7    SELECT INPTFILE ASSIGN TO "INPTFILE".

   1.8    SELECT OUTPFILE ASSIGN TO "OUTPFILE".

   1.9    SELECT SORTFILE ASSIGN TO "SORTFILE".

   2     * ------------------------------------------------

   2.1    DATA DIVISION.

   2.2    FILE SECTION.

   2.3    SD   SORTFILE.

   2.4    01   SORTFILE-RECORD.

   2.5         05  SORTFILE-KEY    PIC X(4).

   2.6         05  FILLER          PIC X(68).

   2.7

   2.8    FD   INPTFILE.

   2.9    01   INPTFILE-RECORD     PIC X(72).

   3

   3.1    FD   OUTPFILE.

   3.2    01   OUTPFILE-RECORD     PIC X(72).

   3.3

   3.4    WORKING-STORAGE SECTION.

   3.5    01   LANGUAGE            PIC S9(4) COMP VALUE 12.

   3.6   * ------------------------------------------------

   3.7    PROCEDURE DIVISION.

   3.8    MAIN SECTION.

   3.9        SORT SORTFILE

   4               ASCENDING SORTFILE-KEY

   4.1             SEQUENCE IS LANGUAGE

   4.2             USING  INPTFILE

   4.3             GIVING OUTPFILE.

   4.4        STOP RUN.

In the example execution, the input and output files are associated with the terminal ($STDIN and $STDLIST):

   :FILE INPTFILE=$STDIN

   :FILE OUTPFILE=$STDLIST

   :RUN PROGRAM;MAXDATA=12000



   character

   credt

   DEBIT

   :EOD



   credit

   character

   DEBIT



   END OF PROGRAM

   :
Feedback to webmaster