Question:
I have a COBOL program that will not work, if someone can help me figure out why that would be wonderful.?
Brenda
2012-09-30 06:46:55 UTC
IDENTIFICATION DIVISION.
AUTHOR. BRENDA STRUB
PROGRAM-ID. BSprogram4.
DATE-WRITTEN. 9/15/2012.
DATE-COMPILED. 9/29/2012.
SECURITY. HIGH-SECURITY.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CUST-FILE
ASSIGN TO
"C:\COBOLFILES\BSprogram4\CH0601 CUSTFILE.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT PRINT-FILE
ASSIGN TO
"C:\COBOLFILES\BSprogram4\CH0601 CUSTFOUT.TXT"
ORGANIZATION IS LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD CUST-FILE
RECORD CONTAINS 24 CHARACTERS.
01 IN-CUSTOMER-REC.
05 INTIAL1 PIC X.
05 INTIAL2 PIC X.
05 LNAME PIC X(10).
05 MONTH-OF-TRANSACTION PIC X(2).
05 YEAR-OF-TRANSACTION PIC X(4).
05 TRANSACTION-AMT PIC 9(6).
FD PRINT-FILE.
01 OUT-CUSTOMER-REC PIC X(80).

WORKING-STORAGE SECTION.
01 WS-WORK-AREAS.
05 ARE-THERE-MORE-RECORDS PIC X(5) VALUE 'YES'.

01 HL-HEADER-1.
05 PIC X(5) VALUE SPACES.
05 PIC X(4) VALUE 'NAME'.
05 PIC X(5) VALUE SPACES.
05 PIC X(20) VALUE
'DATE OF TRANSACTIONS'.
05 PIC X(6) VALUE SPACES.
05 PIC X(21) VALUE
'AMOUNT OF TRANSACTION'.
01 SPACER.
05 PIC X(20) VALUE SPACES.
01 CUST-REC-LINE.
05 INTIAL1-OUT PIC X.
05 DECIMAL PIC X VALUE '.'.
05 INTIAL2-OUT PIC X.
05 DECIMAL2 PIC X VALUE '.'.
05 LNAME-OUT PIC X(10).
05 PIC X(6) VALUE SPACES.
05 MONTH-OF-TRANSACTION-OUT PIC X(2).
05 SLASH PIC X VALUE '/'.
05 YEAR-OF-TRANSACTION-OUT PIC X(4).
05 PIC X(12) VALUE SPACES.
05 TRANSACTION-AMT-OUT PIC $ZZZ,ZZ9.

PROCEDURE DIVISION.
100-MAIN-MODULE.
OPEN INPUT CUST-FILE
OUTPUT PRINT-FILE
WRITE OUT-CUSTOMER-REC FROM SPACER
WRITE OUT-CUSTOMER-REC FROM HL-HEADER-1
WRITE OUT-CUSTOMER-REC FROM SPACER

PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO'
READ CUST-FILE
AT END
MOVE 'NO' TO ARE-THERE-MORE-RECORDS
NOT AT END
PERFORM 200-CALC-RTN
END-READ
END-PERFORM
CLOSE CUST-FILE
PRINT-FILE
STOP RUN.

200-CALC-RTN.
MOVE INTIAL1 TO INTIAL1-OUT
MOVE INTIAL2 TO INTIAL2-OUT
MOVE LNAME TO LNAME-OUT
MOVE MONTH-OF-TRANSACTION TO MONTH-OF-TRANSACTION-OUT
MOVE YEAR-OF-TRANSACTION TO YEAR-OF-TRANSACTION-OUT
MOVE TRANSACTION-AMT TO TRANSACTION-AMT-OUT
WRITE OUT-CUSTOMER-REC FROM CUST-REC-LINE.
end program BSprogram4.
Three answers:
Techwing
2012-09-30 06:56:16 UTC
You need to explain what you mean by "does not work." What is it doing that you don't want it to do?
TheMadProfessor
2012-10-01 14:29:41 UTC
Does the file not exist at all, exists but is completely empty, exists but only contains the header or what?



Just as a possibility, it might not like the spaces embedded in the file names.
heredoggie
2012-09-30 15:04:59 UTC
What exactly are the errors you receive: are they syntactical, logic errors, 'not defined' type of errors, record length errors, etc.



You must be very specific in detailing error messages to receive help.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...