How to call SORT from COBOL Program

QlikView+Jobs
QlikView+Jobs

 

IDENTIFICATION DIVISION.
 PROGRAM-ID.
     COBOLPGM.
 ENVIRONMENT DIVISION.
 INPUT-OUTPUT SECTION.
 FILE-CONTROL.
     SELECT SD-FILE ASSIGN TO
     DUMMYNM.
     SELECT MASTER-FILE ASSIGN TO
     MASTIN.
     SELECT SORTED-MASTER-FILE ASSIGN TO
     MASTOUT.
     SELECT PRINT-FILE ASSIGN TO
     PRINTFL.
 DATA DIVISION.
 FILE SECTION.
 SD  SD-FILE
     DATA RECORD IS SD-RECORD.
 01  SD-RECORD.
  05 TITLE-IN   PICTURE X(75).
  05 AUTH-LN-IN   PICTURE X(15).
  05 AUTH-FN-IN   PICTURE X(15).
  05 PUB-IN    PICTURE X(4).
  05 COUR-DEPT-IN  PICTURE X(5).
  05 COUR-NO-IN   PICTURE X(5).
  05 COUR-NAM-IN   PICTURE X(25).
  05 INST-LN-IN   PICTURE X(15).
  05 INST-INIT-IN   PICTURE X(2).
  05 NO-STOCK-IN   PICTURE 9(8) BINARY.
  05 NO-SOLD-IN   PICTURE 9(8) BINARY.
  05 PRICE-IN   PICTURE 9(8) BINARY.
 FD  MASTER-FILE
     DATA RECORD IS MASTER-RECORD.
 01  MASTER-RECORD.
  05 FILLER    PICTURE X(173).

 FD  SORTED-MASTER-FILE
     DATA RECORD IS SORTED-MASTER-RECORD.
 01  SORTED-MASTER-RECORD.
  05 FILLER    PICTURE X(173).

 FD  PRINT-FILE
     DATA RECORD IS OUTPUT-REPORT-RECORD.
 01  OUTPUT-REPORT-RECORD.
  05 REPORT-OUT   PICTURE X(120).
  .
  .
  .

 PROCEDURE DIVISION.
  .
  .
  .

 SORT-ROUTINE SECTION.
     SORT SD-FILE
     ASCENDING KEY TITLE-IN
     USING MASTER-FILE
     GIVING SORTED-MASTER-FILE.
     IF SORT-RETURN > 0
     DISPLAY "SORT FAILED".
     .
     .
     .
SORT-REPORT SECTION.
     print a report on PRINT-FILE using SORTED-MASTER-FILE.
     .
     .
     .
     STOP RUN.
Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.