File status Error "46"



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

File status Error "46"

Postby kumarajv » Wed Jan 04, 2012 4:02 pm

00000-MAIN.
PERFORM 10000-INITIALIZE-PARA THRU 10000-EXIT
PERFORM 20000-PROCESS-PARA THRU 20000-EXIT
PERFORM 30000-TERMINATE-PARA THRU 30000-EXIT
GOBACK.
00000-EXIT.
GOBACK.

10000-INITIALIZE-PARA.
DISPLAY '10000-INITIALIZATION'
OPEN INPUT INFILE1
INFILE2
OPEN OUTPUT OUT-FILE
INITIALIZE OUT-RECORD.
10000-EXIT.
EXIT.

20000-PROCESS-PARA.
DISPLAY ' 20000-PROCESS-PARA'
PERFORM 21000-READ-INFILE1 THRU 21000-EXIT
UNTIL EOF-FILE1 = 'Y' .
20000-EXIT.
EXIT.

21000-READ-INFILE1.
DISPLAY '21000-READ-FILE1'
MOVE 'N' TO EOF-FILE2
READ INFILE1 AT END
MOVE 'Y' TO EOF-FILE1
END-READ
ADD 1 TO FILE1-READ.
MOVE EMP-NO TO WS-EMPNO
PERFORM 21100-READ-INFILE2 THRU 21100-EXIT
UNTIL EOF-FILE2 = 'Y'.
21000-EXIT.
EXIT.

21100-READ-INFILE2.
DISPLAY '21100-READ-FILE2'
READ INFILE2 AT END
MOVE 'Y' TO EOF-FILE2
END-READ
ADD 1 TO FILE2-READ.
MOVE EMP-ID TO WS-EMPID
PERFORM 22000-MATCH-DATA THRU 22000-EXIT.
21100-EXIT.
EXIT.

22000-MATCH-DATA.
DISPLAY '22000-MATCH-DATA'
DISPLAY 'FILE1 RECS READ = ' FILE1-READ.
DISPLAY 'FILE2 RECS READ = ' FILE2-READ.
IF WS-EMPNO = WS-EMPID
PERFORM 22100-FILES-MATCH THRU 22100-EXIT.
22000-EXIT.
EXIT.

22100-FILES-MATCH.
DISPLAY '22100-FILES-MATCH'
INITIALIZE OUT-RECORD
MOVE EMP-NO TO OUT-EMP-NO
MOVE EMP-NAME TO OUT-EMP-NAME
MOVE EMP-SAL TO OUT-EMP-SAL
MOVE EMP-DEG TO OUT-EMP-DEG
WRITE OUT-RECORD.
22100-EXIT.
EXIT.

30000-TERMINATE-PARA.
DISPLAY '30000-TERMINATE-PARA'
CLOSE OUT-FILE
INFILE1
INFILE2 .
30000-EXIT. EXIT.

Iam getting the file status code as 46:
1) The file 1 first record is reading after that file 2 is redaing until the eof
2) the file 1 second record is reading that time 2 nd file as appeared the file status code 46. Can anyone tell me how to solve this issue
kumarajv
 
Posts: 4
Joined: Wed Jan 04, 2012 3:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File status Error "46"

 

Re: How to solve File status code 46 for the below code

Postby enrico-sorichetti » Wed Jan 04, 2012 4:16 pm

learn to post using the code tags
it makes things more readable for people willing to help You!
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: How to solve File status code 46 for the below code

Postby kumarajv » Wed Jan 04, 2012 4:22 pm

Sure. i will follow that one and this is for matching the files program for unsorted files
kumarajv
 
Posts: 4
Joined: Wed Jan 04, 2012 3:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to solve File status code 46 for the below code

Postby enrico-sorichetti » Wed Jan 04, 2012 4:24 pm

You will get little help for such an illogic requirement...
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: How to solve File status code 46 for the below code

Postby BillyBoyo » Wed Jan 04, 2012 4:55 pm

If you have unsorted files, then every key on one of the files must match on the other.

Then you use the file which must only have matches as the "driver". Read a record on that file, read until you find a match on the other file. Process. Read next on driver file, etc. You can have duplicate keys, but if you do you have some other things to consider.

As enrico alludes, usually there is something which you can sequence the files on. When you haven't got anything, you have to have a match for it to work.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How to solve File status code 46 for the below code

Postby kavithathumba » Wed Jan 04, 2012 5:06 pm

The same thing is done in the above but the issue is coming i think
(i) First File first record has been taken and it is looping for the second file all the records this time it is executing.
(ii) First file second record has been taken and second file looping is not working here and it is abending with file status 46
iam not sure how to solve this one if u know plz let me know also..
:-)
kavithathumba
 
Posts: 1
Joined: Wed Jan 04, 2012 4:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to solve File status code 46 for the below code

Postby BillyBoyo » Wed Jan 04, 2012 5:11 pm

You have to stop reading the second file when you find a match on the first file. That is the point of the "match key" having to exist. If you read to end of tile 2, then, yes, you will get the 46 for the first file 2 read for the second file 1 record.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How to solve File status code 46 for the below code

Postby enrico-sorichetti » Wed Jan 04, 2012 5:14 pm

so if Your first file has 1000 records and Your second file has 1000 records
You plan to open and close the second file 1000 times and issue 1000*500 reads ( statistical average )

OMG :shock:
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: How to solve File status code 46 for the below code

Postby kumarajv » Wed Jan 04, 2012 6:19 pm

yes Kavitha ur right that's what happening here.

billy, But the first file record record 1 is not matching with the second file any records.so, it has to take first file second record and have to check with all the records in second file it is taking second record but not reading the second file records. There is no match then how to stop the second file
kumarajv
 
Posts: 4
Joined: Wed Jan 04, 2012 3:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to solve File status code 46 for the below code

Postby BillyBoyo » Wed Jan 04, 2012 6:57 pm

PERFORM 21100-READ-INFILE2 THRU 21100-EXIT
UNTIL EOF-FILE2 = 'Y'


You are not stopping when you get a match.

As I said before, if the driver file has data which does not match the other file, then it is not going to work. The data have to match, everything on at least one of the files.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post