I seem to get only a blank output with headings on my coding. The program reads my data file which I have on floppy disk and is supposed to print invalid data items on a printed error report.
Valid data is supposed to save back to disk as a validated file to be used in a further program.
Could anyone please suggest some additional coding or suggest where I am going wrong befor I tear my last remaining hair out. Sorry about the layout, I am unsure how to attach the file to my thread!!!!
Cheers GAZ Sausages@scurfield.fsnet.co.uk
IDENTIFICATION DIVISION.
PROGRAM-ID. 495955P1.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT TRANSACTION-FILE ASSIGN TO "495955TD.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT VALID-FILE ASSIGN TO "495955VF.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT INVALID-FILE ASSIGN TO PRINTER.
DATA DIVISION.
FILE SECTION.
FD TRANSACTION-FILE.
01 I-R-RECORD.
03 RECORD-TYPE PIC X.
88 VALID-TYPE VALUES "I" "R" "D" "C".
03 IN-CUSTCODE.
05 INCODE-DIGIT.
07 INCODE-DGT PIC 9 OCCURS 4.
05 INCODE-CHKDGT PIC X.
03 IN-PARTNO.
05 INPART-DIGIT.
07 INPART-DGT PIC 9 OCCURS 5.
05 INPART-CHKDGT PIC X.
03 IN-QUANTITY.
05 IN-QUANT PIC X(4).
01 DELETION.
03 PIC X(6).
01 CREATION.
03 PIC X(6).
03 CUST-NAME PIC X(20).
03 CUST-ADDRESS PIC X(60).
03 CUST-BAL.
05 CUST-BALANCE PIC X(9).
03 CREDIT-LIM.
05 CREDIT-LIMIT PIC X(7).
FD VALID-FILE.
01 VALID-REC PIC X(102).
FD INVALID-FILE
LINAGE IS 60 LINES
WITH FOOTING AT 56
LINES AT TOP 2
LINES AT BOTTOM 4.
01 PRINT-RECORD PIC X(120).
WORKING-STORAGE SECTION.
01 W-REC-COUNT PIC 999 VALUE 0.
01 W-PAGENO PIC 99 VALUE 0.
01 W-LINENO PIC 99.
01 W-DOS-DATE.
03 W-DOS-YEAR PIC 99.
03 W-DOS-MONTH PIC 99.
03 W-DOS-DAY PIC 99.
01 W-IN-DATE.
03 W-IN-YEAR PIC 99.
03 W-IN-MONTH PIC 99.
03 W-IN-YEAR PIC 99.
*WS SECTION FOR BREAKING THE CUSTOMER CODE INTO *PARTS FOR
*MODULUS 11 CHECK
01 W-CUSTCODE-WEIGHTS VALUE "5432".
03 W-C-WT PIC 9 OCCURS 4.
01 W-C-SUB PIC 9.
01 W-C-PRODUCT PIC 99.
01 W-C-SUM PIC 999.
01 W-C-MOD PIC 99 VALUE 11.
01 W-C-REM PIC 99.
01 W-C-CHK.
03 W-C-CHK-NUM PIC 9.
*BREAK THE PART NUMBER DOWN FOR MODULUS 11 CHECK
01 W-PARTNO-WEIGHTS VALUE "65432".
03 W-P-WT PIC 9 OCCURS 5.
01 W-P-SUB PIC 9.
01 W-P-PRODUCT PIC 99.
01 W-P-SUM PIC 999.
01 W-P-MOD PIC 99 VALUE 11.
01 W-P-REM PIC 99.
01 W-P-CHK.
03 W-P-CHK-NUM PIC 9.
01 W-ERROR-REC-FLAG PIC X VALUE "N".
88 VALID-RECORD VALUE "Y".
01 END-TRANSACTION-FILE-FLAG PIC X VALUE "N".
88 END-OF-TRANSACTION-FILE VALUE "Y".
01 P-HDG.
03 PIC X(4) VALUE
"DATE".
03 PIC X VALUE SPACES.
03 PIC X(10) VALUE SPACES.
03 P-HDG-DAY PIC 99.
03 PIC X VALUE "/".
03 P-HDG-MONTH PIC 99.
03 PIC X VALUE "/".
03 P-HDG-YEAR PIC 99.
03 PIC X(36) VALUE
"ZENITH-PAINTS-INVALID-RECORDS-REPORT".
03 PIC X(31) VALUE
"PAGE.".
03 P-PAGENO PIC Z9.
01 P-SUB-HDG.
03 PIC X(11) VALUE
"RECORD-TYPE".
03 PIC X(13) VALUE
"CUSTOMER-CODE".
03 PIC X(15) VALUE
"PART-NUMBER".
03 PIC X(16) VALUE
"QUANTITY".
03 PIC X(16) VALUE
"REJECTION REASON".
01 P-DETAIL-LINE.
03 PIC X(15) VALUE SPACES.
03 P-RECORD-TYPE PIC X.
03 PIC X(15) VALUE SPACES.
03 P-CUST-CODE PIC 9(5).
03 PIC X(23) VALUE SPACES.
03 P-PART-NO PIC 9(6).
03 PIC X(20) VALUE SPACES.
03 P-IR-QUANT PIC 9(4).
03 PIC X(12) VALUE SPACES.
03 P-REJECTION-REASON PIC X(21).
01 P-FILE-EMPTY-LINE.
03 PIC X(35) VALUE
"NO RECORDS ON THIS FILE".
01 P-FINAL-LINE.
03 PIC X(35) VALUE
"*NO MORE INVALID RECORDS*".
PROCEDURE DIVISION.
CONTROL-PARAGRAPH.
PERFORM INITIAL-PROCESS
PERFORM MAIN-PROCESS UNTIL END-OF-TRANSACTION-FILE
PERFORM TERMINATION
STOP RUN.
INITIAL-PROCESS.
OPEN INPUT TRANSACTION-FILE
OUTPUT INVALID-FILE
VALID-FILE
ACCEPT W-DOS-DATE FROM DATE
*DOS stores the date in YYMMDD format.
*Adjustment is needed for DDMMYY format in the heading.
MOVE W-DOS-YEAR TO P-HDG-YEAR
MOVE W-DOS-MONTH TO P-HDG-MONTH
MOVE W-DOS-DAY TO P-HDG-DAY
PERFORM PRINT-HEADINGS
READ TRANSACTION-FILE AT END
DISPLAY "FILE CONTAINS NO RECORDS*"
MOVE "Y" TO END-TRANSACTION-FILE-FLAG
END-READ.
PRINT-HEADINGS.
MOVE 0 TO W-LINENO
ADD 1 TO W-PAGENO
MOVE W-PAGENO TO P-PAGENO
WRITE PRINT-RECORD FROM P-HDG AFTER PAGE
WRITE PRINT-RECORD FROM P-SUB-HDG AFTER 1
MOVE SPACES TO PRINT-RECORD
WRITE PRINT-RECORD AFTER 1.
MAIN-PROCESS.
IF RECORD-TYPE = "I" OR "R" THEN
PERFORM VALIDATE-CUSTCODE
PERFORM VALIDATE-PARTNO
PERFORM VALIDATE-QUANTITY
WRITE VALID-REC
ELSE
IF RECORD-TYPE = "D" THEN
PERFORM VALIDATE-CUSTCODE
WRITE VALID-REC
ELSE
IF RECORD-TYPE = "C" THEN
PERFORM VALIDATE-CUSTCODE
PERFORM VALIDATE-CUST-NAME
PERFORM VALIDATE-CUST-BALANCE
PERFORM VALIDATE-CREDIT-LIMIT
WRITE VALID-REC
ELSE
IF W-REC-COUNT = 0 THEN
PERFORM PRINT-HEADINGS
WRITE PRINT-RECORD FROM
P-FILE-EMPTY-LINE AFTER 2
END-IF
END-IF
END-IF
MOVE "Y" TO W-ERROR-REC-FLAG
MOVE "INVALID RECORD TYPE" TO P-REJECTION-REASON.
END-IF.
VALIDATE-CUSTCODE.
*this procedure will validate the Customer Code using Modul us 11
*the 5th digit is the check digit
IF INCODE-DIGIT NOT NUMERIC THEN
MOVE "Y" TO W-ERROR-REC-FLAG
MOVE "CUSTOMER CODE NOT NUMERIC" TO P-REJECTION-REASON
ELSE
MOVE ZERO TO W-C-SUM
PERFORM VARYING W-C-SUB FROM 1 BY 1
UNTIL W-C-SUB > 4
MULTIPLY INCODE-DGT (W-C-SUB) BY W-C-WT (W-C-SUB)
GIVING W-C-PRODUCT
ADD W-C-PRODUCT TO W-C-SUM
END-PERFORM
END-IF
DIVIDE W-C-SUM BY W-C-MOD GIVING W-C-SUM
REMAINDER W-C-REM
IF W-C-REM > 1 THEN
SUBTRACT W-C-REM FROM W-C-MOD GIVING W-C-CHK-NUM
ELSE
IF W-C-REM = 1 THEN
MOVE ZERO TO W-C-CHK
ELSE
MOVE "X" TO W-C-CHK
END-IF
END-IF
IF INCODE-CHKDGT NOT = W-C-CHK THEN
MOVE "INVALID CUSTOMER CODE" TO P-REJECTION-REASON
END-IF.
VALIDATE-PARTNO.
*this procedure will validate the part number using Modulus
*11 the 6th digit is the check digit.
IF INPART-DIGIT NOT NUMERIC THEN
MOVE "Y" TO W-ERROR-REC-FLAG
MOVE "PART NUMBER NOT NUMERIC" TO P-REJECTION-REASON
ELSE
MOVE ZERO TO W-P-SUM
PERFORM VARYING W-P-SUB FROM 1 BY 1
UNTIL W-P-SUB > 5
MULTIPLY INPART-DGT (W-P-SUB) BY W-P-WT (W-P-SUB)
GIVING W-P-PRODUCT
ADD W-P-PRODUCT TO W-P-SUM
END-PERFORM
END-IF
DIVIDE W-P-SUM BY W-P-MOD GIVING W-P-SUM
REMAINDER W-P-REM
IF W-P-REM > 1 THEN
SUBTRACT W-P-REM FROM W-P-MOD GIVING W-P-CHK-NUM
ELSE
IF W-P-REM = 1 THEN
MOVE ZERO TO W-P-CHK
ELSE
MOVE "X" TO W-P-CHK
END-IF
END-IF
IF INPART-CHKDGT NOT = W-C-CHK THEN
MOVE "INVALID CUSTOMER CODE" TO P-REJECTION-REASON
END-IF
IF W-P-CHK-NUM NOT = W-P-CHK THEN
MOVE "INVALID PART NUMBER" TO P-REJECTION-REASON
MOVE "Y" TO W-ERROR-REC-FLAG
END-IF.
VALIDATE-QUANTITY.
IF IN-QUANT NOT NUMERIC THEN
MOVE "QUANTITY INVALID" TO P-REJECTION-REASON
MOVE "Y" TO W-ERROR-REC-FLAG
END-IF.
VALIDATE-CUST-NAME.
IF CUST-NAME = SPACES THEN
MOVE "NO CUSTOMER NAME" TO P-REJECTION-REASON
MOVE "Y" TO W-ERROR-REC-FLAG
END-IF.
VALIDATE-CUST-BALANCE.
IF CUST-BALANCE NOT NUMERIC THEN
MOVE "NON NUMERIC BALANCE" TO P-REJECTION-REASON
MOVE "Y" TO W-ERROR-REC-FLAG
END-IF.
VALIDATE-CREDIT-LIMIT.
IF CREDIT-LIMIT NOT NUMERIC THEN
MOVE "NON NUMERIC CREDIT LIMIT" TO P-REJECTION-REASON
MOVE "Y" TO W-ERROR-REC-FLAG
END-IF.
WRITE VALID-REC FROM CREATION.
TERMINATION.
CLOSE TRANSACTION-FILE
CLOSE INVALID-FILE
CLOSE VALID-FILE
STOP RUN.
Valid data is supposed to save back to disk as a validated file to be used in a further program.
Could anyone please suggest some additional coding or suggest where I am going wrong befor I tear my last remaining hair out. Sorry about the layout, I am unsure how to attach the file to my thread!!!!
Cheers GAZ Sausages@scurfield.fsnet.co.uk
IDENTIFICATION DIVISION.
PROGRAM-ID. 495955P1.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT TRANSACTION-FILE ASSIGN TO "495955TD.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT VALID-FILE ASSIGN TO "495955VF.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT INVALID-FILE ASSIGN TO PRINTER.
DATA DIVISION.
FILE SECTION.
FD TRANSACTION-FILE.
01 I-R-RECORD.
03 RECORD-TYPE PIC X.
88 VALID-TYPE VALUES "I" "R" "D" "C".
03 IN-CUSTCODE.
05 INCODE-DIGIT.
07 INCODE-DGT PIC 9 OCCURS 4.
05 INCODE-CHKDGT PIC X.
03 IN-PARTNO.
05 INPART-DIGIT.
07 INPART-DGT PIC 9 OCCURS 5.
05 INPART-CHKDGT PIC X.
03 IN-QUANTITY.
05 IN-QUANT PIC X(4).
01 DELETION.
03 PIC X(6).
01 CREATION.
03 PIC X(6).
03 CUST-NAME PIC X(20).
03 CUST-ADDRESS PIC X(60).
03 CUST-BAL.
05 CUST-BALANCE PIC X(9).
03 CREDIT-LIM.
05 CREDIT-LIMIT PIC X(7).
FD VALID-FILE.
01 VALID-REC PIC X(102).
FD INVALID-FILE
LINAGE IS 60 LINES
WITH FOOTING AT 56
LINES AT TOP 2
LINES AT BOTTOM 4.
01 PRINT-RECORD PIC X(120).
WORKING-STORAGE SECTION.
01 W-REC-COUNT PIC 999 VALUE 0.
01 W-PAGENO PIC 99 VALUE 0.
01 W-LINENO PIC 99.
01 W-DOS-DATE.
03 W-DOS-YEAR PIC 99.
03 W-DOS-MONTH PIC 99.
03 W-DOS-DAY PIC 99.
01 W-IN-DATE.
03 W-IN-YEAR PIC 99.
03 W-IN-MONTH PIC 99.
03 W-IN-YEAR PIC 99.
*WS SECTION FOR BREAKING THE CUSTOMER CODE INTO *PARTS FOR
*MODULUS 11 CHECK
01 W-CUSTCODE-WEIGHTS VALUE "5432".
03 W-C-WT PIC 9 OCCURS 4.
01 W-C-SUB PIC 9.
01 W-C-PRODUCT PIC 99.
01 W-C-SUM PIC 999.
01 W-C-MOD PIC 99 VALUE 11.
01 W-C-REM PIC 99.
01 W-C-CHK.
03 W-C-CHK-NUM PIC 9.
*BREAK THE PART NUMBER DOWN FOR MODULUS 11 CHECK
01 W-PARTNO-WEIGHTS VALUE "65432".
03 W-P-WT PIC 9 OCCURS 5.
01 W-P-SUB PIC 9.
01 W-P-PRODUCT PIC 99.
01 W-P-SUM PIC 999.
01 W-P-MOD PIC 99 VALUE 11.
01 W-P-REM PIC 99.
01 W-P-CHK.
03 W-P-CHK-NUM PIC 9.
01 W-ERROR-REC-FLAG PIC X VALUE "N".
88 VALID-RECORD VALUE "Y".
01 END-TRANSACTION-FILE-FLAG PIC X VALUE "N".
88 END-OF-TRANSACTION-FILE VALUE "Y".
01 P-HDG.
03 PIC X(4) VALUE
"DATE".
03 PIC X VALUE SPACES.
03 PIC X(10) VALUE SPACES.
03 P-HDG-DAY PIC 99.
03 PIC X VALUE "/".
03 P-HDG-MONTH PIC 99.
03 PIC X VALUE "/".
03 P-HDG-YEAR PIC 99.
03 PIC X(36) VALUE
"ZENITH-PAINTS-INVALID-RECORDS-REPORT".
03 PIC X(31) VALUE
"PAGE.".
03 P-PAGENO PIC Z9.
01 P-SUB-HDG.
03 PIC X(11) VALUE
"RECORD-TYPE".
03 PIC X(13) VALUE
"CUSTOMER-CODE".
03 PIC X(15) VALUE
"PART-NUMBER".
03 PIC X(16) VALUE
"QUANTITY".
03 PIC X(16) VALUE
"REJECTION REASON".
01 P-DETAIL-LINE.
03 PIC X(15) VALUE SPACES.
03 P-RECORD-TYPE PIC X.
03 PIC X(15) VALUE SPACES.
03 P-CUST-CODE PIC 9(5).
03 PIC X(23) VALUE SPACES.
03 P-PART-NO PIC 9(6).
03 PIC X(20) VALUE SPACES.
03 P-IR-QUANT PIC 9(4).
03 PIC X(12) VALUE SPACES.
03 P-REJECTION-REASON PIC X(21).
01 P-FILE-EMPTY-LINE.
03 PIC X(35) VALUE
"NO RECORDS ON THIS FILE".
01 P-FINAL-LINE.
03 PIC X(35) VALUE
"*NO MORE INVALID RECORDS*".
PROCEDURE DIVISION.
CONTROL-PARAGRAPH.
PERFORM INITIAL-PROCESS
PERFORM MAIN-PROCESS UNTIL END-OF-TRANSACTION-FILE
PERFORM TERMINATION
STOP RUN.
INITIAL-PROCESS.
OPEN INPUT TRANSACTION-FILE
OUTPUT INVALID-FILE
VALID-FILE
ACCEPT W-DOS-DATE FROM DATE
*DOS stores the date in YYMMDD format.
*Adjustment is needed for DDMMYY format in the heading.
MOVE W-DOS-YEAR TO P-HDG-YEAR
MOVE W-DOS-MONTH TO P-HDG-MONTH
MOVE W-DOS-DAY TO P-HDG-DAY
PERFORM PRINT-HEADINGS
READ TRANSACTION-FILE AT END
DISPLAY "FILE CONTAINS NO RECORDS*"
MOVE "Y" TO END-TRANSACTION-FILE-FLAG
END-READ.
PRINT-HEADINGS.
MOVE 0 TO W-LINENO
ADD 1 TO W-PAGENO
MOVE W-PAGENO TO P-PAGENO
WRITE PRINT-RECORD FROM P-HDG AFTER PAGE
WRITE PRINT-RECORD FROM P-SUB-HDG AFTER 1
MOVE SPACES TO PRINT-RECORD
WRITE PRINT-RECORD AFTER 1.
MAIN-PROCESS.
IF RECORD-TYPE = "I" OR "R" THEN
PERFORM VALIDATE-CUSTCODE
PERFORM VALIDATE-PARTNO
PERFORM VALIDATE-QUANTITY
WRITE VALID-REC
ELSE
IF RECORD-TYPE = "D" THEN
PERFORM VALIDATE-CUSTCODE
WRITE VALID-REC
ELSE
IF RECORD-TYPE = "C" THEN
PERFORM VALIDATE-CUSTCODE
PERFORM VALIDATE-CUST-NAME
PERFORM VALIDATE-CUST-BALANCE
PERFORM VALIDATE-CREDIT-LIMIT
WRITE VALID-REC
ELSE
IF W-REC-COUNT = 0 THEN
PERFORM PRINT-HEADINGS
WRITE PRINT-RECORD FROM
P-FILE-EMPTY-LINE AFTER 2
END-IF
END-IF
END-IF
MOVE "Y" TO W-ERROR-REC-FLAG
MOVE "INVALID RECORD TYPE" TO P-REJECTION-REASON.
END-IF.
VALIDATE-CUSTCODE.
*this procedure will validate the Customer Code using Modul us 11
*the 5th digit is the check digit
IF INCODE-DIGIT NOT NUMERIC THEN
MOVE "Y" TO W-ERROR-REC-FLAG
MOVE "CUSTOMER CODE NOT NUMERIC" TO P-REJECTION-REASON
ELSE
MOVE ZERO TO W-C-SUM
PERFORM VARYING W-C-SUB FROM 1 BY 1
UNTIL W-C-SUB > 4
MULTIPLY INCODE-DGT (W-C-SUB) BY W-C-WT (W-C-SUB)
GIVING W-C-PRODUCT
ADD W-C-PRODUCT TO W-C-SUM
END-PERFORM
END-IF
DIVIDE W-C-SUM BY W-C-MOD GIVING W-C-SUM
REMAINDER W-C-REM
IF W-C-REM > 1 THEN
SUBTRACT W-C-REM FROM W-C-MOD GIVING W-C-CHK-NUM
ELSE
IF W-C-REM = 1 THEN
MOVE ZERO TO W-C-CHK
ELSE
MOVE "X" TO W-C-CHK
END-IF
END-IF
IF INCODE-CHKDGT NOT = W-C-CHK THEN
MOVE "INVALID CUSTOMER CODE" TO P-REJECTION-REASON
END-IF.
VALIDATE-PARTNO.
*this procedure will validate the part number using Modulus
*11 the 6th digit is the check digit.
IF INPART-DIGIT NOT NUMERIC THEN
MOVE "Y" TO W-ERROR-REC-FLAG
MOVE "PART NUMBER NOT NUMERIC" TO P-REJECTION-REASON
ELSE
MOVE ZERO TO W-P-SUM
PERFORM VARYING W-P-SUB FROM 1 BY 1
UNTIL W-P-SUB > 5
MULTIPLY INPART-DGT (W-P-SUB) BY W-P-WT (W-P-SUB)
GIVING W-P-PRODUCT
ADD W-P-PRODUCT TO W-P-SUM
END-PERFORM
END-IF
DIVIDE W-P-SUM BY W-P-MOD GIVING W-P-SUM
REMAINDER W-P-REM
IF W-P-REM > 1 THEN
SUBTRACT W-P-REM FROM W-P-MOD GIVING W-P-CHK-NUM
ELSE
IF W-P-REM = 1 THEN
MOVE ZERO TO W-P-CHK
ELSE
MOVE "X" TO W-P-CHK
END-IF
END-IF
IF INPART-CHKDGT NOT = W-C-CHK THEN
MOVE "INVALID CUSTOMER CODE" TO P-REJECTION-REASON
END-IF
IF W-P-CHK-NUM NOT = W-P-CHK THEN
MOVE "INVALID PART NUMBER" TO P-REJECTION-REASON
MOVE "Y" TO W-ERROR-REC-FLAG
END-IF.
VALIDATE-QUANTITY.
IF IN-QUANT NOT NUMERIC THEN
MOVE "QUANTITY INVALID" TO P-REJECTION-REASON
MOVE "Y" TO W-ERROR-REC-FLAG
END-IF.
VALIDATE-CUST-NAME.
IF CUST-NAME = SPACES THEN
MOVE "NO CUSTOMER NAME" TO P-REJECTION-REASON
MOVE "Y" TO W-ERROR-REC-FLAG
END-IF.
VALIDATE-CUST-BALANCE.
IF CUST-BALANCE NOT NUMERIC THEN
MOVE "NON NUMERIC BALANCE" TO P-REJECTION-REASON
MOVE "Y" TO W-ERROR-REC-FLAG
END-IF.
VALIDATE-CREDIT-LIMIT.
IF CREDIT-LIMIT NOT NUMERIC THEN
MOVE "NON NUMERIC CREDIT LIMIT" TO P-REJECTION-REASON
MOVE "Y" TO W-ERROR-REC-FLAG
END-IF.
WRITE VALID-REC FROM CREATION.
TERMINATION.
CLOSE TRANSACTION-FILE
CLOSE INVALID-FILE
CLOSE VALID-FILE
STOP RUN.