From: vvdag@alliant1.lerc.nasa.gov (Don Georgevich)
Subject: Need help on a very simple COBOL program.
Organization: NASA Lewis Research Center
Date: Wed, 14 Oct 1992 17:47:06 GMT

I am a NOVICE COBOL programmer who is in a real bind with major time
constraints.   I need some help on how to complete a very simple COBOL
program.  If there is anyone out there who can spare a few minutes of their
time and offer some tips on how I should proceed in completing the following
program, I would be very appreciative.

The instructions are to modify the existing attached COBOL program, which
reads in a sequential file of inventory records, and to edit these records and
print both an expanded inventory report as well as an exception report.

In addition to generating the error report, keep count of the number of
correct and the number error records encountered and print these totals at the
bottom of their respective reports.

Only four numeric fields should be edited:  PART-COST, PART-WAREHOUSE-CODE,
PART-QUANTITY and PART-SUPPLIER-CODES.  For the first three fields, replace
all leading spaces by zeroes, then check for any non-numeric characters and,
for those cases where limits on values are known, do a range check.  For PART-
SUPPLIER-CODES, replace all spaces by zeroes.  The exception report will list
all those records which have an invalid warehouse code or invalid supplier
codes as well as those records which have invalid fields for the value and
quantity of each specific part.  If at least one valid supplier code is
present then don't treat a zero supplier code as an error, but if all are zero
then it is an error.  The error report should clearly indicate what errors
have been detected for each record.



RM/Co* Ver 1.04 30-5ep-92 10:19:01                                  
DON: A:\DON.CBL                                                        

0003
0004       *      Written by Don Georgevich       
0005       *      September 25, 1992
0006
0007       *      This program reads in a line-sequential file called
0008       *      "INVNTRY.DAT" and writes it out as "REPORT".
0009
0010       *      MODIFICATIONS
0011
0012       *      by Don Georgevich
0013       *      September 30, 1992
0014
0015       *      The WORKING STORAGE SECTION has been modified to copy
0016       *      in the file "INVDSC.CPY".
0017
0018       *      The MAIN ROUTINE section has been modified to READ INTO
0019       *      PART-INVENTORY-RECORD and WRITE FROM PART-INVENTORY-RECORD.
0020
0021
0022          ENVIRONMENT DIVISION.
0023          CONFIGURATION SECTION.
0024          SOURCE-COMPUTER. IBM-PC.
0025
0026          INPUT-OUTPUT SECTION.
0027          FILE-CONTROL.
0028              SELECT INVENTORY-FILE ASSIGN TO DISK "A:\INVNTRY.DAT"
0029                                  ORGANIZATION IS LINE SEQUENTIAL.
0030              SELECT REPORT-FILE ASSIGN TO DISK "A:\REPORT"
0031                                  ORGANIZATION IS LINE SEQUENTIAL.
0032
0033          DATA DIVISION.
0034
0035          FILE SECTION.
0036
0037          FD INVENTORY-FILE.
0038          01 INVENTORY-RECORD.
0039              10 IN-LINE PIC X(60).
0040
0041          FD REPORT-FILE.
0042          01 REPORT-RECORD.
0043              10 INN-LINE PIC X(60).
0044
0045
0046
0047
0048
0049
0050          WORKING-STORAGE SECTION.
0051              COPY "A:\INVDSC.CPY".
0052
0053          01 PART-INVENTORY-RECORD.


0054             02  PART-CODE                 PIC X(01).
0055             02  PART-NUMBER               PIC X(09).
0056             02  PART-DESCRIPTION          PIC X(l9).
0057             02  PART-COST                 PIC 99V99.
0058             02  PART-WAREHOUSE-CODE       PIC 9(01).
0059             02  PART-QUANTITY             PIC 9(03).
0060             02 PART-LOCATION.
0061                 03 PART-AILSE             PIC 9(02).
0062                 03 PART-BIN               PIC 9(02).
0063             02 PART-ORDER-INFO.
0064                 03 PART-REVIEW-POINT      PIC 9(03).
0065                 03 PART-MIN-ORDER-QTY     PIC 9(03).
0066                 03 PART-LEAD-TIME         PIC 9(02).
0067                 03 PART-SUPPLIER-CODES.
0068                         04 PART-SUPPLIER-CODE OCCURS 4 TIMES
0069                                             PIC X(02).
0070             02  FILLER                      PIC X(24).
0071
0072             01 WAREHOUSE-VALUES.
0073             02  FILLER              PIC X(13) VALUE 'BUFFALO      '.
0074             02  FILLER              PIC X(13) VALUE 'CHICAGO      '.
0075             02  FILLER              PIC X(13) VALUE 'CINCINNATI   '.
0076             02  FILLER              PIC X(13) VALUE 'CLEVELAND    '.
0077             02  FILLER              PIC X(13) VALUE 'DETROIT      '.
0078             02  FILLER              PIC X(13) VALUE 'LOS ANGELES  '.
0079             02  FILLER                 PIC X(13) VALUE 'SAN FRANCISCO'.
0080
0081        01 WAREHOUSE-TABLE                 REDEFINES WAREHOUSE-VALUES.
0082            02 WAREHOUSE-NAME               OCCURS 7 TIMES PIC X(13).
0083
0084        01 SUPPLIER-VALUES.
0085           02  FILLER              PIC X(20) VALUE '05ADCO MANUFACTURING'.
0086           02  FILLER               PIC X(20) VALUE '08BURROUGHS CORP. '.
0087           02  FILLER              PIC X(20) VALUE 'lOCOMMERCIAL CORP. '.
0088           02  FILLER              PIC X(20) VALUE '15JOHNSON & JOHNSON '.
0089           02  FILLER              PIC X(20) VALUE '20KOLBROOK & WILSON '.
0090           02  FILLER              PIC X(20) VALUE '25LEDDERS SCREW GEAR'.
0091           02  FILLER              PIC X(20) VALUE '30MINNESOTA MINING '.
0092           02  FILLER              PIC X(20) VALUE '35NOXEMA INDUSTRIES '.
0093           02  FILLER              PIC X(20) VALUE '40NATIONAL SEMICOND.'.
0094           02  FILLER              PIC X(20) VALUE '450CCIDENTAL PETRO. '.
0095           02  FILLER              PIC X(20) VALUE '50PONDS-CHESEBOROUGH'.
0096           02  FILLER              PIC X(20) VALUE '52SUNBEAM TOOL MFGS.'.
0097           02  FILLER                PIC X(20) VALUE '55TESDATA CORP. '.
0098           02  FILLER              PIC X(20) VALUE '60WACO MANUFACTURING'.
0099
0100        01 SUPPLIER-TABLE REDEFINES SUPPLIER-VALUES.
0101             05  SUPPLIER-ENTRY OCCURS 14 TIMES
0102                 INDEXED BY SUPPLIER-INDEX.
0103                 10 SUPPLIER-CODE PIC X(02).
0104                 10 SUPPLIER-NAME PIC X(18).
0105
0106


0107        01 FLAGS-REC.
0108            
02          OUT-OF-RECS-FLAG      PIC X.
0109
0110
0111
0112
0113
0114
0115        PROCEDURE DIVISION.
0116
0117        MAIN-ROUTINE.
0118            OPEN INPUT INVENTORY-FILE.
0119            OPEN OUTPUT REPORT-FILE.
0120
                READ INVENTORY-FILE INTO PART-INVENTORY-RECORD.
0121            PERFORM 100-INITIALIZE
0122               UNTIL OUT-OF-RECS-FLAG = 'Y'.
0123
0124            PERFORM 110-FINALIZE
0125            STOP RUN.
0126
0127
0128
0129        100-INITIALIZE.
0130            MOVE SPACES TO INVENTORY-RECORD.
0131            
                WRITE REPORT-RECORD FROM PART-INVENTORY-RECORD.

0132            READ INVENTORY-FILE INTO PART-INVENTORY-RECORD
0133               AT END MOVE 'Y' TO OUT-OF-RECS-FLAG.
0134            
0135
0136
0137
0138
0141
0142        110-FINALIZE.
0143            CLOSE INVENTORY-FILE.
0144            CLOSE REPORT-FILE.       
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155

Read only size:                     450 (X"OOOOOlC2") bytes
Read/write size:                    892 (X"0000037C") bytes
Overlayable segment size:             O (X"OOOOOOOO") bytes