IGZ0201W and IGZ0035S errors in COBOL - cobol

*-----------------------
IDENTIFICATION DIVISION.
*-----------------------
PROGRAM-ID. TOPACCTS
AUTHOR. Sohan Kundu.
*--------------------
ENVIRONMENT DIVISION.
*--------------------
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PRINT-LINE ASSIGN TO PRTLINE.
SELECT ACCT-REC ASSIGN TO ACCTREC.
*-------------
DATA DIVISION.
*-------------
FILE SECTION.
FD PRINT-LINE RECORD CONTAINS 80 CHARACTERS RECORDING MODE F.
01 PRINT-REC.
05 FILLER PIC X(01) VALUE SPACES.
05 FIRST-NAME-O PIC X(11).
05 FILLER PIC X(02) VALUE SPACES.
05 LAST-NAME-O PIC X(22).
05 FILLER PIC X(02) VALUE SPACES.
05 ACCT-BALANCE-O PIC X(12).
05 FILLER PIC X(30) VALUE SPACES.
*
FD ACCT-REC RECORD CONTAINS 80 CHARACTERS RECORDING MODE F.
01 ACCT-FIELDS.
05 FIRST-NAME PIC X(11).
05 LAST-NAME PIC X(22).
05 FILLER PIC X(28).
05 ACCT-BALANCE PIC X(12).
05 FILLER PIC X(7).
*
WORKING-STORAGE SECTION.
01 FLAGS.
05 LASTREC PIC X VALUE SPACE.
*
01 TOTAL-CLIENTS.
05 FILLER PIC X(14) VALUE
'# OF RECORDS: '.
05 CLIENTS PIC 9(3) VALUE ZERO.
05 FILLER PIC X(63) VALUE SPACES.
*
01 HEADER-1.
05 FILLER PIC X(30) VALUE 'REPORT FOR TOP ACCOUNT HOLDERS'.
05 FILLER PIC X(50) VALUE SPACES.
*
01 HEADER-2.
05 FILLER PIC X(05) VALUE 'Year '.
05 HDR-YR PIC 9(04).
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(06) VALUE 'Month '.
05 HDR-MO PIC X(02).
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(04) VALUE 'Day '.
05 HDR-DAY PIC X(02).
05 FILLER PIC X(53) VALUE SPACES.
*
01 HEADER-3.
05 FILLER PIC X(11) VALUE 'First Name '.
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(10) VALUE 'Last Name '.
05 FILLER PIC X(14) VALUE SPACES.
05 FILLER PIC X(08) VALUE 'Balance '.
05 FILLER PIC X(35) VALUE SPACES.
*
01 HEADER-4.
05 FILLER PIC X(11) VALUE '-----------'.
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(10) VALUE '----------'.
05 FILLER PIC X(14) VALUE SPACES.
05 FILLER PIC X(08) VALUE '--------'.
05 FILLER PIC X(35) VALUE SPACES.
*
01 WS-CURRENT-DATE-DATA.
05 WS-CURRENT-DATE.
10 WS-CURRENT-YEAR PIC 9(04).
10 WS-CURRENT-MONTH PIC 9(02).
10 WS-CURRENT-DAY PIC 9(02).
05 WS-CURRENT-TIME.
10 WS-CURRENT-HOURS PIC 9(02).
10 WS-CURRENT-MINUTE PIC 9(02).
10 WS-CURRENT-SECOND PIC 9(02).
10 WS-CURRENT-MILLISECONDS PIC 9(02).
*
*------------------
PROCEDURE DIVISION.
*------------------
OPEN-FILES.
OPEN INPUT ACCT-REC.
OPEN OUTPUT PRINT-LINE.
*
WRITE-HEADERS.
MOVE FUNCTION CURRENT-DATE TO WS-CURRENT-DATE-DATA.
MOVE WS-CURRENT-YEAR TO HDR-YR.
MOVE WS-CURRENT-MONTH TO HDR-MO.
MOVE WS-CURRENT-DAY TO HDR-DAY.
WRITE PRINT-REC FROM HEADER-1.
WRITE PRINT-REC FROM HEADER-2.
MOVE SPACES TO PRINT-REC.
WRITE PRINT-REC AFTER ADVANCING 1 LINES.
WRITE PRINT-REC FROM HEADER-3.
WRITE PRINT-REC FROM HEADER-4.
MOVE SPACES TO PRINT-REC.
*
READ-NEXT-RECORD.
PERFORM READ-RECORD
PERFORM UNTIL LASTREC = 'Y'
PERFORM IS-BALANCE-HIGH
PERFORM READ-RECORD
END-PERFORM
.
*
CLOSE-STOP.
WRITE PRINT-REC FROM TOTAL-CLIENTS.
CLOSE ACCT-REC.
CLOSE PRINT-LINE.
STOP RUN.
*
READ-RECORD.
READ ACCT-REC
AT END MOVE 'Y' TO LASTREC
END-READ.
*
IS-BALANCE-HIGH.
IF FUNCTION NUMVAL-C(ACCT-BALANCE) > 8500000 THEN
ADD 1 TO CLIENTS
PERFORM WRITE-RECORD
END-IF.
*
WRITE-RECORD.
MOVE FIRST-NAME TO FIRST-NAME-O.
MOVE LAST-NAME TO LAST-NAME-O.
MOVE ACCT-BALANCE TO ACCT-BALANCE-O.
WRITE PRINT-REC.
*
I want to read the account details from an input file and print if the balance is more than 8500000.
The code is showing the following error:
IGZ0201W A file attribute mismatch was detected. File PRINT-LINE in program TOPACCTS had a record length of 81 and
the file specified in the ASSIGN clause had a record length of 80.
IGZ0035S There was an unsuccessful OPEN or CLOSE of file PRTLINE in program TOPACCTS at relative location X'1E8'.
Neither FILE STATUS nor an ERROR declarative were specified. The status code was 39.
From compile unit TOPACCTS at entry point TOPACCTS at compile unit offset +000001E8 at entry offset +000001E8
at address 1B8001E8.

In the JCL that you are using to execute this program (as a batchjob), within the step with EXEC PGM=TOPACCTS, make sure that you use a DD-card for your output file PRTLINE which looks similar to this:
//PRTLINE DD DISP=(NEW,CATLG),DSN=YOUR.DSN.GOES.HERE,
// UNIT=SYSDA,SPACE=(CYL,(5,5)),
// RECFM=FB,LRECL=80
That way you'll avoid the status code '39', which indicates that there is a mismatch between your record length of 80 (as shown in your program with CONTAINS 80 CHARACTERS), and whatever you specified in your JCL's DD-card.

Related

Invalid type cast from 'null'

I am still new to COBOL and have been working on a project for school for almost a week now. I am running OpenCobol 1.1.
When I try to compile it I get this error.
typeck.c:5912: Invalid type cast from 'null'
Tag 1 0 Tag 2 10
Aborting compile of lab4.cob at line 214
I've been frustrated because I've tried changing the code around a lot with no luck.
Procedure Division.
000-Main.
Perform 100-initialize
Perform Until EndOfFile = "Y"
Read Lab4-in-File
At End
Move "Y" To EndOfFile
Not At End
Perform 300-process
End-Read
End-Perform
Perform 900-finalize
Stop Run.
100-intialize.
Perform 110-open-files
Perform 120-get-data.
110-open-files.
Open Input Lab4-in-File
Output Ot-File.
120-get-date.
Accept WS-date from date yyyymmdd
Move WS-Year To PH-Year
Move WS-Month To PH-Month
Move WS-Day To PH-Day.
300-process.
Move Dept-no To dl-dep-no
Move Employee-no To dl-emp-no
If First-name Not = "Null"
String First-name Delimited By Size
" " Delimited By Size
Last-name Delimited By Size
Into dl-emp
else
Move Last-name To dl-emp
End-If
Move Job-title To dl-job
Move DOH To dl-doh
Move Mar-status To dl-marital
Move Dependents To dl-dependents
Move MCoverage To dl-insurance
Move DCoverage To dl-insurance
Move VCoverage To dl-insurance
Move 401K To dl-401k
Move Pay-code To dl-pay-code
If Pay-code = "C" Or "S"
Compute Pay-hold rounded =
Pay / 12
Move Pay-hold To dl-monthly-pay
else
Compute Pay-hold rounded =
Pay * HPW * 4
Move Pay-hold To dl-monthly-pay
End-If
If Pay-code = "C"
Compute Com-hold rounded =
Act-sale * C-rate
Move Com-hold To dl-commission
Else
Move 0 To dl-commission
End-If
Perform 800-print
Multiply C-rate By Act-sale Giving
total-sales
Add Pay To total-sales.
800-print.
If LineNum > LinesPerPage
Perform 825-new-page
End-If
Write Lab4-Record2 From Detail-Line
**After advancing 1 line** *> This is line 214
Add 1 To LineNum.
825-new-page.
If PageNum > 0
Write Lab4-Record2 From Blank-line
After advancing 1 line
End-If
Add 1 To PageNum
Move PageNum To PH-PageNo
Write Lab4-Record2 From Page-Header
After advancing page
Write Lab4-Record2 From Blank-line
After advancing 1 line
Write Lab4-Record2 From Column-Header
After advancing 1 line
Write Lab4-Record2 From Blank-line
After advancing 1 line
Move 5 To LineNum.
900-finalize.
Perform 950-print-monthly-total
Perform 999-close-files.
950-print-monthly-total.
If LineNum + 1 > LinesPerPage
Perform 825-new-page
End-If
Write Lab4-Record2 From Blank-line
After advancing 1 line
Move total-sales To Total-pay
Write Lab4-Record2 From Total-Line
After advancing 1 line
Add 2 To LineNum.
999-close-files.
Close Lab4-in-File Ot-File.
I would really appreciate it if someone could help me find what is causing the error. Thanks in advance!
Working-Storage Section.
01 EndOfFile Pic X Value "N".
01 Report-fields.
05 PageNum Pic 9(3) value 0.
05 LinesPerPage Pic 9(2) value 40.
05 LineNum Pic 9(2) value 41.
01 WS-date.
05 WS-Year Pic 9(4).
05 WS-Month Pic 99.
05 WS-Day Pic 99.
01 total-fields.
05 total-sales Pic 9(11)v99 Value 0.
01 Page-Header.
05 PH-Month Pic Z9/.
05 PH-Day Pic 99/.
05 PH-Year Pic 9999.
05 Pic X(7) Value Spaces.
05 Pic X(29) Value "Stomper &" &
" Wombat's Emporium"
05 Pic X(6) Value "Page:".
05 PH-PageNo Pic ZZ9.
01 Column-Header.
05 Pic X(8) Value "Dep #".
05 Pic X(15) Value "Emp #".
05 Pic X(27) Value "Employee".
05 Pic X(18) Value "Title".
05 Pic X(9) Value "DOH".
05 Pic X(9) Value "Marital".
05 Pic X(7) Value "#Deps".
05 Pic X(6) Value "Ins".
05 Pic X(6) Value "401K".
05 Pic X(6) Value "Pay".
05 Pic X(27) Value "Expected " &
"Pay + Commission".
01 Pay-hold Pic 9(9)V9(2) Value 0.
01 Com-hold Pic 9(9)V9(2) Value 0.
01 Detail-Line.
05 dl-dep-no Pic X(5).
05 Pic X(1) Value spaces.
05 dl-emp-no Pic X(5).
05 Pic X(1) Value spaces.
05 dl-emp Pic X(35).
05 Pic X(1) Value spaces.
05 dl-job Pic X(20).
05 Pic X(1) Value spaces.
05 dl-doh Pic X(8).
05 Pic X(1) Value spaces.
05 dl-marital Pic X.
05 Pic X(1) Value spaces.
05 dl-dependents Pic 9(2).
05 Pic X(1) Value spaces.
05 dl-insurance Pic X(3).
05 Pic X(1) Value spaces.
05 dl-401k Pic Z.9ZZ.
05 Pic X(1) Value spaces.
05 dl-pay-code Pic X.
05 Pic X(1) Value spaces.
05 dl-monthly-pay Pic $$$$,$$$,$$9.99.
05 Pic X(1) Value spaces.
05 dl-commission Pic $$$,$$9.99.
01 Total-Line.
05 Pic X(61) Value Spaces.
05 Pic X(24) Value "Total" &
" Expected Payroll: ".
05 Total-pay Pic $$$$,$$$,$$$,$$9.99.
01 Blank-line Pic X Value spaces.
The compiler has a broken parser. It is broken because of a coding error (still a compiler bug). In cases like this you only have the chance to either spot the error or - much better - use a newer version.
I've just put your code in an online compiler using the last release of the compiler: GnuCOBOL 2.2. I highly suggest to upgrade to at least this version.
See your code here - I've just added a minimal header and end.
Then click on "Execute" and you compile it online, leading to the following error messages:
main.cobc: 27: error: duplicate PICTURE clause
main.cobc: 27: error: duplicate VALUE clause
main.cobc: 64: error: a Z or * which is after the decimal point cannot follow 9
If you check the line 27 in this program you see
05 Pic X(29) Value "Stomper &" &
" Wombat's Emporium" *> <<- missing period
05 Pic X(6) Value "Page:".
Fixed code is also available.

Cobol output file not displaying properly

I'm trying to output 2 different lines in my cobol program, but it isn't outputting the way I want it to. Instead of writing one of each line it is writing two of the second line.
My code is:
DATA DIVISION.
FILE SECTION.
FD INVENT-FILE-IN.
01 INVENTORY-RECORD-IN.
05 PART-NUMBER PIC 9(5).
05 PART-NAME PIC X(20).
05 QUANTITY-ON-HAND PIC 9(3).
05 UNIT-PRICE PIC 9V99(6).
05 RE-ORDER-POINT PIC 9(3).
05 SUPPLIER-ID PIC X(2).
FD INVENT-REPORT-OUT.
01 INVENTORY-RECORD-OUT.
05 FILLER PIC X(1) VALUE SPACES.
05 PART-NUMBER PIC 9(5).
05 FILLER PIC X(3) VALUE SPACES.
05 PART-NAME PIC X(20).
05 FILLER PIC X(1) VALUE SPACES.
05 QUANTITY-ON-HAND PIC 9(4).
05 FILLER PIC X(1) VALUE SPACES.
05 UNIT-PRICE PIC 9V99(6).
05 FILLER PIC X(2).
05 INVENTORY-VALUE PIC 9V99(10).
01 INVENTORY-RECORD-HDR-LN1.
05 FILLER PIC X(9) VALUE SPACES.
05 FILLER PIC X(20) VALUE "INVENTORY REPORT FOR".
05 FILLER PIC X(3) VALUE SPACES.
05 CURRENT-MONTH PIC 9(2).
05 FILLER PIC X(18) VALUE SPACES.
01 INVENTORY-RECORD-HDR-LN2.
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(7) VALUE "PART NO".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(9) VALUE "PART NAME".
05 FILLER PIC X(13) VALUE SPACES.
05 FILLER PIC X(2) VALUE "OH".
05 FILLER PIC X(2) VALUE SPACES.
05 FILLER PIC X(5) VALUE "PRICE".
05 FILLER PIC X(6) VALUE SPACES.
05 FILLER PIC X(5) VALUE "VALUE".
05 FILLER PIC X(2) VALUE SPACES.
01 INVENTORY-RECORD-END.
05 TOTAL-VALUE PIC 9(7)V99.
05 NUM-RECORDS-IN PIC 9(3).
05 NUM-RECORDS-OUT PIC 9(3).
FD RE-ORDER-FILE.
01 REORDER-RECORD-OUT.
05 PART-NUMBER PIC 9(5).
05 PART-NAME PIC X(20).
05 QUANTITY-ON-HAND PIC 9(3).
05 SUPPLIER-ID PIC X(2).
PROCEDURE DIVISION.
OPEN-RTN.
OPEN INPUT INVENT-FILE-IN.
OPEN OUTPUT INVENT-REPORT-OUT.
OPEN OUTPUT RE-ORDER-FILE.
PERFORM HEADER1-RTN.
HEADER1-RTN.
MOVE FUNCTION CURRENT-DATE(5:2) TO CURRENT-MONTH.
WRITE INVENTORY-RECORD-HDR-LN1.
PERFORM HEADER2-RTN.
HEADER2-RTN.
WRITE INVENTORY-RECORD-HDR-LN2
END-WRITE.
PERFORM CLOSE-RTN.
CLOSE-RTN.
CLOSE INVENT-FILE-IN.
CLOSE INVENT-REPORT-OUT.
CLOSE RE-ORDER-FILE.
STOP RUN.
The output file turns out like this:
PART NO PART NAME O11 PRICE VALUE
PART NO PART NAME O11 PRICE VALUE
But I want it to turn out like this:
INVENTORY REPORT FOR 11
PART NO PART NAME OH PRICE VALUE
These are just the headers for the rest of the data, and I can't figure out how to get them both to display properly. Any help is appreciated.

When I add slashes I get numbers added to the record

01 EMPLOYEE-RECORD1.
...
05 EMPLOYEEDOB1.
10 MONTH1 PIC 99.
*> here 10 FILLER PIC X(1) VALUE "/".
10 DAY11 PIC 99.
*> here 10 FILLER PIC X(1) VALUE "/".
10 YEARS1 PIC 9(4).
*> here
05 EMPLOYEE_YEARLYPAY1 PIC ZZ,ZZZV99.
...
There is more to the program and I will provide the code if necessary. In short my program takes input from a file and then loads it into a temp record. Then I copy the data from the temp record into the record for the output file and it writes it to the output file. When it writes it I lose the pay data and it adds numbers for the DOB instead of slashes. Why? What am I doing wrong?
program-id. Program1 as "NAME403.Program1".
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPFILE
ASSIGN TO "C:\COBOLClass\DataFiles\NAME402.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT NEWEMPFILE
ASSIGN TO "C:\COBOLClass\DataFiles\NAME403.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
data division.
FILE SECTION.
FD EMPFILE.
01 EMPLOYEE-RECORD.
05 EMPLOYEE_ADDRESS.
10 BLDGNUMB-AND-STREET PIC X(10).
10 CITY PIC X(10).
10 STATE PIC X(10).
10 ZIPCODE PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEENUMB PIC 9(6).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEEDOB.
10 MONTH PIC 99.
10 DAY1 PIC 99.
10 YEARS PIC 9(4).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_FNAME PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_MNAME PIC X(2).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_LNAME PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_YEARLYPAY PIC ZZ,ZZZ.99.
FD NEWEMPFILE.
01 EMPLOYEE-RECORD1.
05 EMPLOYEENUMB1 PIC 9(6).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_FNAME1 PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_MNAME1 PIC X(2).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_LNAME1 PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEEDOB1.
10 MONTH1 PIC 99.
10 FILLER PIC X VALUE "/".
10 DAY11 PIC 99.
10 FILLER PIC X VALUE "/".
10 YEARS1 PIC 9(4).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_YEARLYPAY1 PIC ZZ,ZZZ.99.
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_ADDRESS1.
10 BLDGNUMB-AND-STREET1 PIC X(10).
10 CITY1 PIC X(10).
10 FILLER PIC X(10) VALUE SPACE.
10 STATE1 PIC X(10).
10 FILLER PIC X(10) VALUE SPACE.
10 ZIPCODE1 PIC X(10).
10 FILLER PIC X(166) VALUE "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------".
05 EMPLOYEE_LNAME PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_YEARLYPAY PIC ZZ,ZZZ.99.
FD NEWEMPFILE.
01 EMPLOYEE-RECORD1.
05 EMPLOYEENUMB1 PIC 9(6).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_FNAME1 PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_MNAME1 PIC X(2).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_LNAME1 PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEEDOB1.
10 MONTH1 PIC 99.
10 FILLER PIC X VALUE "/".
10 DAY11 PIC 99.
10 FILLER PIC X VALUE "/".
10 YEARS1 PIC 9(4).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_YEARLYPAY1 PIC ZZ,ZZZ.99.
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_ADDRESS1.
10 BLDGNUMB-AND-STREET1 PIC X(10).
10 CITY1 PIC X(10).
10 FILLER PIC X(10) VALUE SPACE.
10 STATE1 PIC X(10).
10 FILLER PIC X(10) VALUE SPACE.
10 ZIPCODE1 PIC X(10).
10 FILLER PIC X(166) VALUE ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------".
working-storage section.
01 EMPLOYEE-RECORD-TEMP.
05 EMPLOYEE_ADDRESS-TEMP.
10 BLDGNUMB-AND-STREET-TEMP PIC X(10).
10 CITY-TEMP PIC X(10).
10 STATE-TEMP PIC X(10).
10 ZIPCODE-TEMP PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEENUMB-TEMP PIC 9(6).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEEDOB-TEMP.
10 MONTH-TEMP PIC 99.
10 DAY1-TEMP PIC 99.
10 YEARS-TEMP PIC 9(4).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_FNAME-TEMP PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_MNAME-TEMP PIC X(2).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_LNAME-TEMP PIC X(10).
05 FILLER PIC X(10) VALUE SPACE.
05 EMPLOYEE_YEARLYPAY-TEMP PIC ZZ,ZZZ.99.
01 SWITCHES.
05 CUSTMAST-EOF-SWITCH PIC X VALUE "N".
02 COUNTER PIC 9 VALUE 1.
procedure division.
000-STARTPROGRAM.
open input EMPFILE
output NEWEMPFILE.
PERFORM 100-GET-INFROMATION
UNTIL CUSTMAST-EOF-SWITCH="Y".
display "END OF SESSION.".
stop run.
100-GET-INFROMATION.
read EMPFILE into EMPLOYEE-RECORD-TEMP
at END
MOVE EMPLOYEE_ADDRESS-TEMP TO EMPLOYEE_ADDRESS1.
MOVE BLDGNUMB-AND-STREET-TEMP TO BLDGNUMB-AND-STREET1.
MOVE CITY-TEMP TO CITY1.
MOVE STATE-TEMP TO STATE1.
MOVE ZIPCODE-TEMP TO ZIPCODE1.
MOVE EMPLOYEENUMB-TEMP TO EMPLOYEENUMB1.
MOVE MONTH-TEMP TO MONTH1.
MOVE DAY1-TEMP TO DAY11.
MOVE YEARS-TEMP TO YEARS1.
MOVE EMPLOYEE_FNAME-TEMP TO EMPLOYEE_FNAME1.
MOVE EMPLOYEE_MNAME-TEMP TO EMPLOYEE_MNAME1.
move EMPLOYEE_LNAME-TEMP TO EMPLOYEE_LNAME1.
move EMPLOYEE_YEARLYPAY-TEMP to EMPLOYEE_YEARLYPAY1.
WRITE EMPLOYEE-RECORD1.
if COUNTER=5
close EMPFILE
close NEWEMPFILE
move "Y" to CUSTMAST-EOF-SWITCH
ELSE ADD 1 to COUNTER.
The actual MOVE or READ ... INTO are missing but I assume you (directly or indirectly) move a PIC 9(06) item to EMPLOYEEDOB1 which is a different format actual a PIC X(08).
As long as the question isn't improved (by showing both the data definition and the statement for the "copy") I say the answer to "What am I doing wrong?" is: You use the wrong definition for EMPLOYEEDOB1 and/or "copy" the data in falsely.
The target field definition must either match the original data or be changed to an edited field like PIC 99/99/99 (where the / are added automatically in the DISPLAY/WRITE you do with it) - in the later case: be aware that you cannot do any arithmetic with an edited field.
Alternative: MOVE all three parts of the date-of-birth (DOB) on their own and you can keep your definition (only useful if you want to do anything with the three parts afterwards).

Not a uniquely defined Name?

I keep getting the error
"LOWMID-COMMISSION-CTR" was not a uniquely defined name. The definition
to be used could not be determined from the context.
And similar on all of my counters. I have no idea where I'm going wrong here, how is it not a uniquely defined name when it is clearly in the WORKING-STORAGE SECTION? Do I put it somewhere else so that it's a uniquely defined name? Below I have showed where I defined my counters, and where the counters are used.
IDENTIFICATION DIVISION.
PROGRAM-ID. LAB3.
AUTHOR.
******************************************************************
ENVIRONMENT DIVISION.
* defines the external files - an input file and output file
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT SALES-FILE ASSIGN TO DATAIN
FILE STATUS IS EF-STATUS.
SELECT REPORT-FILE ASSIGN TO DATAOUT
FILE STATUS IS PF-STATUS.
DATA DIVISION.
* has two sections - the file section that describes the files
* and the working storage section - where output lines and
* processing variables are defined
FILE SECTION.
FD SALES-FILE.
01 SALES-RECORD.
05 EMPLOYEE-NAME-IN PIC X(24).
05 SALES-IN PIC 99999.
05 FILLER PIC X(51).
FD REPORT-FILE.
01 REPORT-RECORD PIC X(80).
WORKING-STORAGE SECTION.
01 FLAGS-AND-ACCUMLATORS.
05 LOW-COMMISSION-CTR PIC 99999 VALUE ZERO.
05 LOWMID-COMMISSION-CTR PIC 99999 VALUE ZERO.
05 HIGHMID-COMMISSION-CTR PIC 99999 VALUE ZERO.
05 HIGH-COMMISSION-CTR PIC 99999 VALUE ZERO.
05 TOTAL-SALES PIC $$$,$$9.99 VALUE ZERO.
05 TOTAL-COMMISSION PIC $$$,$$9.99 VALUE ZERO.
05 END-OF-FILE PIC XXX VALUE "NO".
05 EF-STATUS PIC 99 VALUE 0.
05 PF-STATUS PIC 99 VALUE 0.
05 COMMISSION PIC 99999V99.
01 REPORT-BLANK-LINE.
05 PIC X(80).
01 HEADING-LINE-1.
05 PIC X(30) VALUE SPACES.
05 PIC X(19) VALUE
"COMPANY OF AARON".
01 HEADING-LINE-2.
05 PIC X(30) VALUE SPACES.
05 PIC X(19) VALUE
"KEARNEY, MISSOURI".
01 HEADING-LINE-3.
05 PIC X(03) VALUE SPACES.
05 PIC X(48) VALUE
"Number of employees with up to 10,000 in sales: ".
05 LOW-COMMISSION-CTR PIC 99999.
01 HEADING-LINE-4.
05 PIC X(03) VALUE SPACES.
05 PIC X(52) VALUE
"Number of employees from 10,001 to 20,000 in sales: ".
05 LOWMID-COMMISSION-CTR PIC 99999.
01 HEADING-LINE-5.
05 PIC X(03) VALUE SPACES.
05 PIC X(52) VALUE
"Number of employees from 20,001 to 30,000 in sales: ".
05 HIGHMID-COMMISSION-CTR PIC 99999.
01 HEADING-LINE-6.
05 PIC X(03) VALUE SPACES.
05 PIC X(42) VALUE
"Number of employees over 30,000 in sales: ".
05 HIGH-COMMISSION-CTR PIC 99999.
01 HEADING-LINE-7.
05 PIC X(03) VALUE SPACES.
05 PIC X(13) VALUE
"Total Sales: ".
05 TOTAL-SALES PIC $$$,$$9.99.
01 HEADING-LINE-8.
05 PIC X(03) VALUE SPACES.
05 PIC X(18) VALUE
"TOTAL COMMISSION: ".
05 TOTAL-COMMISSION PIC $$$,$$9.99.
01 COLUMN-HEADING-1.
05 PIC X(03) VALUE SPACES.
05 PIC X(24) VALUE "SALESPERSON".
05 PIC X(15) VALUE "SALES".
05 PIC X(10) VALUE "COMMISSION".
01 COLUMN-HEADING-2.
05 PIC X(14) VALUE "SUMMARY REPORT".
01 DETAIL-LINE.
05 PIC X(03) VALUE SPACES.
05 EMPLOYEE-NAME-OUT PIC X(24).
05 SALES-OUT PIC $$$,$$9.
05 PIC X(05) VALUE SPACES.
05 COMMISSION-OUT PIC $$$,$$9.99.
PROCEDURE DIVISION.
1000-MAIN-CONTROL.
PERFORM 2000-INITIALIZE.
PERFORM UNTIL END-OF-FILE = "YES"
READ SALES-FILE
AT END
MOVE "YES" TO END-OF-FILE
NOT AT END
PERFORM 3000-PROCESS
END-PERFORM
PERFORM 4000-PROCESS.
STOP RUN.
2000-INITIALIZE.
OPEN INPUT SALES-FILE
OUTPUT REPORT-FILE.
WRITE REPORT-RECORD FROM HEADING-LINE-1.
WRITE REPORT-RECORD FROM HEADING-LINE-2.
WRITE REPORT-RECORD FROM REPORT-BLANK-LINE.
WRITE REPORT-RECORD FROM COLUMN-HEADING-1.
WRITE REPORT-RECORD FROM REPORT-BLANK-LINE.
3000-PROCESS.
IF SALES-IN < 10001
MULTIPLY SALES-IN BY .04 GIVING COMMISSION
ADD 1 TO LOW-COMMISSION-CTR
ADD COMMISSION TO TOTAL-COMMISSION
END-IF.
IF SALES-IN > 10000 AND < 20001
MULTIPLY SALES-IN BY .055 GIVING COMMISSION
ADD 1 TO LOWMID-COMMISSION-CTR
ADD COMMISSION TO TOTAL-COMMISSION
END-IF.
IF SALES-IN > 20000 AND < 30000
MULTIPLY SALES-IN BY .065 GIVING COMMISSION
ADD 1 TO HIGHMID-COMMISSION-CTR
ADD COMMISSION TO TOTAL-COMMISSION
END-IF.
IF SALES-IN > 30000
MULTIPLY SALES-IN BY .075 GIVING COMMISSION
ADD 1 TO HIGH-COMMISSION-CTR
ADD COMMISSION TO TOTAL-COMMISSION
END-IF.
MOVE EMPLOYEE-NAME-IN TO EMPLOYEE-NAME-OUT.
MOVE SALES-IN TO SALES-OUT.
MOVE COMMISSION TO COMMISSION-OUT.
WRITE REPORT-RECORD FROM DETAIL-LINE.
4000-PROCESS.
WRITE REPORT-RECORD FROM REPORT-BLANK-LINE.
WRITE REPORT-RECORD FROM COLUMN-HEADING-2.
WRITE REPORT-RECORD FROM HEADING-LINE-3.
WRITE REPORT-RECORD FROM HEADING-LINE-4.
WRITE REPORT-RECORD FROM HEADING-LINE-5.
WRITE REPORT-RECORD FROM HEADING-LINE-6.
WRITE REPORT-RECORD FROM HEADING-LINE-7.
WRITE REPORT-RECORD FROM HEADING-LINE-8.
4000-TERMINATE.
CLOSE SALES-FILE, REPORT-FILE.
Thje variable LOWMID-COMMISSION-CTR is defined twice.
once in FLAGS-AND-ACCUMLATORS
01 FLAGS-AND-ACCUMLATORS.
05 LOW-COMMISSION-CTR PIC 99999 VALUE ZERO.
05 LOWMID-COMMISSION-CTR PIC 99999 VALUE ZERO.
once in HEADING-LINE-4
01 HEADING-LINE-4.
05 PIC X(03) VALUE SPACES.
05 PIC X(52) VALUE
"Number of employees from 10,001 to 20,000 in sales: ".
05 LOWMID-COMMISSION-CTR PIC 99999.
So either
rename one of the LOWMID-COMMISSION-CTR to some thing else
01 HEADING-LINE-4.
05 PIC X(03) VALUE SPACES.
05 PIC X(52) VALUE
"Number of employees from 10,001 to 20,000 in sales: ".
05 HEADER-LOWMID-COMMISSION-CTR PIC 99999.
fully qualify the field.
Add 1
to LOWMID-COMMISSION-CTR
of FLAGS-AND-ACCUMLATORS
Same applies to other FLAGS-AND-ACCUMLATORS fields

How to skip a record in COBOL with an if statement

FD STUDENTS-FILE-IN.
01 STUDENTS-RECORD-IN.
05 SSN-IN PIC X(9).
05 STUDENT-NAME-IN PIC X(11).
05 PIC X(5).
05 GRAD-STATUS-IN PIC X.
05 CLASS-STANDING-IN PIC X.
05 MAJOR-IN PIC X(3).
05 CREDIT-HOURS-IN PIC 9(3).
05 CREDIT-POINTS-IN PIC 9(3).
FD STUDENTS-FILE-OUT.
01 STUDENTS-RECORD-OUT PIC X(80).
WORKING-STORAGE SECTION.
01 ARE-THERE-MORE-RECORDS PIC X(3) VALUE 'YES'.
01 PAGE-NUMBER PIC 99 VALUE ZERO.
01 LINE-COUNT PIC 99 VALUE ZERO.
01 SSID-BREAK.
03 FIRST-PART PIC X(3).
03 SECOND-PART PIC X(2).
03 THIRD-PART PIC X(4).
01 NAME-BREAK.
03 FIRST-LETTER PIC X(1).
03 MIDDLE-LETTER PIC X(1).
03 LAST-LETTER PIC X(10).
01 GRAD-CHECK PIC X.
01 WS-DATE.
05 RUN-YEAR PIC XX.
05 RUN-MONTH PIC XX.
05 RUN-DAY PIC XX.
01 HEADING-LINE-ONE.
05 PIC X(21) VALUE SPACES.
05 PIC X(33)
VALUE 'RHODES STATE COLLEGE GRADE REPORT'.
05 PIC X(6) VALUE SPACES.
05 HEADING-LINE-DATE.
10 MONTH-NOW PIC XX.
10 PIC X VALUE '/'.
10 DAY-NOW PIC XX.
10 PIC X VALUE '/'.
10 YEAR-NOW PIC XX.
05 PIC X(3) VALUE SPACES.
05 PIC X(4) VALUE 'PAGE'.
05 HL-1-PAGE-NUMBER PIC Z9 VALUE ZEROS.
01 HEADING-LINE-TWO.
05 PIC X(10) VALUE 'SOC SEC NO'.
05 PIC X(4) VALUE SPACES.
05 PIC X(12) VALUE 'STUDENT NAME'.
05 PIC X(3) VALUE SPACES.
05 PIC X(8) VALUE 'STANDING'.
05 PIC X(4) VALUE SPACES.
05 PIC X(5) VALUE 'MAJOR'.
05 PIC X(10) VALUE SPACES.
05 PIC X(5) VALUE 'HOURS'.
05 PIC X(2) VALUE SPACES.
05 PIC X(6) VALUE 'POINTS'.
05 PIC X(5) VALUE SPACES.
05 PIC X(3) VALUE 'GPA'.
01 DETAIL-LINE.
05 DL-SSID.
10 SSID-1 PIC X(3).
10 PIC X VALUE "-".
10 SSID-2 PIC X(2).
10 PIC X VALUE "-".
10 SSID-3 PIC X(4).
05 BLANK-B PIC X(3) VALUE SPACES.
05 DL-NAME .
10 FIRST-INI PIC X.
10 PIC X VALUE SPACES.
10 MID-INI PIC X.
10 PIC X VALUE SPACES.
10 LAST-NAME PIC X(10).
05 BLANK-C PIC X(3) VALUE SPACES.
05 YEAR-STATUS PIC X(9).
05 BLANK-D PIC X(3) VALUE SPACES.
05 STUDENT-MAJOR PIC X(13).
05 BLANK-E PIC X(5) VALUE SPACES.
05 STUDNET-HOURS PIC ZZ9.
05 BLANK-F PIC X(5) VALUE SPACES.
05 STUDENT-POINTS PIC ZZ9.
05 BLANK-G PIC X(4) VALUE SPACES.
05 STUDENT-GPA PIC 9V99.
01 TOTALS-LINE.
05 TOTALS PIC X(6) VALUE 'TOTALS'.
05 PIC X(34) VALUE SPACES.
05 HITS-TOTAL PIC ZZZ,ZZZ.
05 PIC X(9) VALUE SPACES.
05 BATS-TOTAL PIC ZZZ,ZZZ.
05 PIC X(10) VALUE SPACES.
05 AVG-TOTAL PIC .999.
PROCEDURE DIVISION.
100-MAIN.
OPEN INPUT STUDENTS-FILE-IN
OPEN OUTPUT STUDENTS-FILE-OUT
ACCEPT WS-DATE FROM DATE
MOVE RUN-MONTH TO MONTH-NOW
MOVE RUN-DAY TO DAY-NOW
MOVE RUN-YEAR TO YEAR-NOW
PERFORM 300-WRITE-HEADINGS
PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO '
READ STUDENTS-FILE-IN
AT END
MOVE 'NO ' TO ARE-THERE-MORE-RECORDS
NOT AT END
PERFORM 200-PROCESS-ONE-RECORD
END-READ
END-PERFORM
CLOSE STUDENTS-FILE-IN
CLOSE STUDENTS-FILE-OUT
STOP RUN.
200-PROCESS-ONE-RECORD.
IF LINE-COUNT >= 53
PERFORM 300-WRITE-HEADINGS
END-IF
* IF GRAD-STATUS-IN NOT = '1' AND NOT = '2'
* PERFORM 400-WRITE-TOTALS.
* END-IF
MOVE SSN-IN TO SSID-BREAK
MOVE FIRST-PART TO SSID-1
MOVE SECOND-PART TO SSID-2
MOVE THIRD-PART TO SSID-3
MOVE STUDENT-NAME-IN TO NAME-BREAK
MOVE FIRST-LETTER TO FIRST-INI
MOVE MIDDLE-LETTER TO MID-INI
MOVE LAST-LETTER TO LAST-NAME
MOVE GRAD-STATUS-IN TO GRAD-CHECK
IF GRAD-CHECK = 'Y'
END-IF
MOVE DETAIL-LINE TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINES
ADD 1 TO LINE-COUNT.
The input file looks like this
307662099KRAlexander Y2NES005017
Basically certain files won't meet the requirements and we are just suppose to just skip over them. This is an example of the file that we don't want to write to the output file and skip over. I apologize if I explained this poorly but I am really struggling with COBOL.
Your 200- paragraph needs to do something like this:
IF NOT ( <condition-for-skipping )
PERFORM PROCESS-THIS-RECORD
ELSE
PERFORM IGNORE-THIS-RECORD
END-IF
You can swap the conditions easily
IF ( <condition-for-skipping )
PERFORM IGNORE-THIS-RECORD
ELSE
PERFORM PROCESS-THIS-RECORD
END-IF
All the stuff you have in the 200- paragraph currently, you put in to a new paragrpah PROCESS-THIS-RECORD. You should have a new paragraph IGNORE-THIS-RECORD. If nothing else, it can count the records which are ignored. Then if you count the records which are processed, and count the input records, at the end you can check that everything is either processed or ignored.
You should check file-statuses. It is good to use scope-delimiters (like the END-IF) and keep full-stops/periods to a minimum.
88s are good to use for conditions. Saves lots of literals hanging about to make maintenance more complex.

Resources