View previous topic :: View next topic |
Author |
Message |
vini Intermediate
Joined: 12 Jan 2004 Posts: 240 Topics: 48 Location: Maryland
|
Posted: Fri Feb 06, 2004 2:18 pm Post subject: |
|
|
SK,
kolusu maybe busy some place .. and am not sure if anyone can easily identify the logical error in your code by just seeing the piece above
It would make things faster for you and easier for us ..if you could paste the complete Procedure Division atleast .
You mentioned ....same code was working 2 days back ?!!!..but kolusu provided you with the link to his earlier post just today morning I believe ...so definitely in which case your code of today would not be same as that of couple of days back. nope ?!!!
Besides , I do not think your requirement is exactly similar to what was in the post provided for example sake by kolusu to you.
I guess that was just to give you a clear idea about how you have to handle multiple files which are open at same time or are being read simultaneously. It need not necessarily suit your requirement 100%.
Pls take time to understand the sample and then maybe apply it where appropriate to your requirements (which may need additional modifications).
Vini
Last edited by vini on Fri Feb 06, 2004 2:30 pm; edited 2 times in total |
|
Back to top |
|
 |
SK Beginner
Joined: 04 Feb 2004 Posts: 26 Topics: 3
|
Posted: Fri Feb 06, 2004 2:22 pm Post subject: |
|
|
Vini,
Since we are in the context of the code probelem I am facing, so Kolusu will understand better as to what I want to ask. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Feb 06, 2004 2:23 pm Post subject: |
|
|
sk,
You should note that I work for someone else for my lively hood. Right now I am swamped with work that I have hardly any time to look at the helpboard. I try to help as much as I can but please DO NOT depend on me entirely for solving your problems. Do you have xpediter at your shop ? If you do have then run the program thru and pin point the error. If you don't have it then try with displays.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Feb 06, 2004 2:26 pm Post subject: |
|
|
sk,
As suggested by vini, why don't you post your procedure division code ? I will take a look at it later in the evening.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
SK Beginner
Joined: 04 Feb 2004 Posts: 26 Topics: 3
|
Posted: Fri Feb 06, 2004 2:29 pm Post subject: |
|
|
Hi Kolusu,
Here is the perform part:
decleration:
Code: |
WORKING-STORAGE SECTION.
01 S-IN-NEW-FILE PIC X(01) VALUE 'N'.
01 S-IN-OLD-FILE PIC X(01) VALUE 'N'.
PERFORM 1000-PROCESS UNTIL S-IN-A-FILE = 'Y'
AND S-IN-B-FILE = 'Y'
0500-NEW-READ.
READ A-FILE INTO A-FILE-REC-WS
AT END
MOVE 'Y' TO S-IN-A-FILE
MOVE HIGH-VALUES TO A-ROW-ID * first field in my file
DISPLAY 'NEW FILE HAS ENDED'
NOT AT END
ADD 1 TO NEW-READ-CTR * a read counter
END-READ.
1000-PROCESS.
EVALUATE TRUE
WHEN N-AID = O-AID
PERFORM 1200-UPDATE
PERFORM 0500-NEW-READ
PERFORM 0800-OLD-READ
WHEN N-AID > O-AID
PERFORM 1500-XYZ
PERFORM 0500-NEW-READ
WHEN N-AID < O-AID
PERFORM 1600-PQR
PERFORM 0800-OLD-READ
END-EVALUATE.
|
This is the code which is failing becoz it tried to read even after the file has ended. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Feb 06, 2004 2:40 pm Post subject: |
|
|
Sk,
A simple look at the code shows that you are moving high-values to A-ROW-ID and in the main process you are comparing with O-AID.
Where are you moving high-values to o-aid? is this field as 05 level of a-row-id? Since you are not moving high-values of the o-aid it will try to read once again.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
SK Beginner
Joined: 04 Feb 2004 Posts: 26 Topics: 3
|
Posted: Fri Feb 06, 2004 2:46 pm Post subject: |
|
|
Sorry, it was a typo. It should be N-AID at all the places. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Feb 06, 2004 2:53 pm Post subject: |
|
|
Sk,
*sigh* How are the fields N-AID & O-AID getting populated after every read ?. Let us say N-AID corresponds to new file and O-AID corresponds to Old file. At the end of the file you need to move high values to N-AID if not move the key value to it.
post your file-declaration of both files
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
SK Beginner
Joined: 04 Feb 2004 Posts: 26 Topics: 3
|
Posted: Fri Feb 06, 2004 3:02 pm Post subject: |
|
|
Yes, they are getting populated through the file reads of old and new files(new file read code I have already posted). I am moving high-value to N-AID in the read block if the file has reched the end in the AT END condition. See the above code.
FD A-FILE
LABEL RECORDS STANDARD
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS F.
01 A-FILE-REC PIC X(500).
FD B-FILE
LABEL RECORDS STANDARD
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS F.
01 B-FILE-REC PIC X(500). |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Feb 06, 2004 3:11 pm Post subject: |
|
|
Sk,
phew ! Your read paragraph shows that you are into A-FILE-REC-WS. Is N-aid a part of the the declaration?
Dude just post the whole program. It is better to look at the whole code instead of bits and pieces.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
SK Beginner
Joined: 04 Feb 2004 Posts: 26 Topics: 3
|
Posted: Fri Feb 06, 2004 3:34 pm Post subject: |
|
|
Code: |
FD A-FILE
LABEL RECORDS STANDARD
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS F.
01 A-FILE-REC PIC X(500).
FD B-FILE
LABEL RECORDS STANDARD
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS F.
01 B-FILE-REC PIC X(500).
WORKING-STORAGE SECTION.
01 S-IN-NEW-FILE PIC X(01) VALUE 'N'.
01 S-IN-OLD-FILE PIC X(01) VALUE 'N'.
01 A-FILE-REC-WS.
05 N-AID PIC X(15).
05 N-A-FNAME PIC X(100).
05 N-A-LNAME PIC X(100).
05 N-A-ADDR PIC X(100).
05 N-A-EMAIL PIC X(100).
05 N-A-JOBT PIC X(75).
01 B-FILE-REC-WS.
05 N-BID PIC X(15).
05 N-B-FNAME PIC X(100).
05 N-B-LNAME PIC X(100).
05 N-B-ADDR PIC X(100).
05 N-B-EMAIL PIC X(100).
05 N-B-JOBT PIC X(75).
01 A-FILE-REC-WS.
05 N-OUTID PIC X(15).
05 N-OUT-FNAME PIC X(100).
05 N-OUT-LNAME PIC X(100).
05 N-OUT-ADDR PIC X(100).
05 N-OUT-EMAIL PIC X(100).
05 N-OUT-JOBT PIC X(75).
PROCEDURE DIVISION.
0000-MAINLINE.
PERFORM 0100-INIT
PERFORM 1000-PROCESS UNTIL N-AID = HIGH-VALUE AND O-AID = HIGH-VALUE
GOBACK.
OPEN INPUT A-FILE
B-FILE
OPEN OUTPUT OUT-FILE
INITIALIZE A-FILE-REC-WS
B-FILE-REC-WS
OUT-FILE-REC-WS
PERFORM 0500-NEW-READ
PERFORM 0600-OLD-READ
0500-NEW-READ.
READ A-FILE INTO A-FILE-REC-WS
AT END
MOVE 'Y' TO S-IN-A-FILE
MOVE HIGH-VALUES TO N-AID * first field in my file
DISPLAY 'NEW FILE HAS ENDED'
NOT AT END
ADD 1 TO NEW-READ-CTR * a read counter
END-READ.
0600-OLD-READ.
READ B-FILE INTO B-FILE-REC-WS
AT END
MOVE 'Y' TO S-IN-A-FILE
MOVE HIGH-VALUES TO O-AID * first field in my file
DISPLAY 'NEW FILE HAS ENDED'
NOT AT END
ADD 1 TO NEW-READ-CTR * a read counter
END-READ.
1000-PROCESS.
EVALUATE TRUE
WHEN N-AID = O-AID
PERFORM 1200-UPDATE
PERFORM 0500-NEW-READ
PERFORM 0800-OLD-READ
WHEN N-AID > O-AID
PERFORM 1500-XYZ
PERFORM 0500-NEW-READ
WHEN N-AID < O-AID
PERFORM 1600-PQR
PERFORM 0800-OLD-READ
END-EVALUATE.
|
I think this will give you the idea of my code. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Feb 06, 2004 4:06 pm Post subject: |
|
|
Sk,
A couple of errors in your pgm.
1. In 0600-OLD-READ & 0500-NEW-READ paragraphs you are moving 'y' to S-IN-A-FILE.
2. In the 1000-process when WHEN N-AID > O-AID , you are reading the 0500-NEW-READ again. Let us say you reached the end of the file in the previous read and you already have moved high values to the compare key. Now once again when you enter the 1000-process ,you will definitely fall into the when WHEN N-AID > O-AID condition as N-AID has high values and you will again go and read the same file which already reached the end of file.
your code should be as follows
Code: |
EVALUATE TRUE
WHEN N-AID = O-AID
PERFORM 1200-UPDATE
PERFORM 0500-NEW-READ
PERFORM 0800-OLD-READ
WHEN N-AID > O-AID
PERFORM 1500-XYZ
PERFORM 0800-OLD-READ
WHEN N-AID < O-AID
PERFORM 1600-PQR
PERFORM 0500-NEW-READ
END-EVALUATE
|
Hope this helps...
Cheers
kolusu
PS: Please understand the match logic posted in the other thread and start coding the program. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
SK Beginner
Joined: 04 Feb 2004 Posts: 26 Topics: 3
|
Posted: Wed Mar 03, 2004 11:02 am Post subject: |
|
|
Hi Kolusu,
You had given me link to the file comparison program in COBOL earlier which compares 2 files record by record. These files are first sorted and then are compared like 1st record from file 1 with 1st record from file 2 and so on for all of them. So if the first records from both the files are matched then that record will go to matched records file.
What happens when lets say the 1 record is deleted from file 2. Now when it tried to ge record by record even though all other records are matching except the first one still they will come as their positions are moved by one in the second file.
Could you please let me know as to how this situation is handled in your program. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Mar 03, 2004 11:49 am Post subject: |
|
|
Sk,
I am not really sure what exactly your question is. It would be better if you could explain it with examples.
Let us say this is input
FILE1 INPUT:
Code: |
RECORD 1
RECORD 2
RECORD 3
RECORD 4
RECORD 5
RECORD 6
|
FILE2 INPUT:
Code: |
RECORD 2
RECORD 3
RECORD 4
RECORD 5
RECORD 6
RECORD 7
|
If you notice that RECORD 1 does not exist in file2 input and it also has RECORD 7 which does not exist in FILE1
The following output will be produced from the pgm.
MATCH FILE
Code: |
RECORD 2
RECORD 3
RECORD 4
RECORD 5
RECORD 6
|
RECORDS PRESENT ONLY IN FILE1 BUT MISSING IN FILE2:
RECORDS PRESENT ONLY IN FILE2 BUT MISSING IN FILE1:
Now tell me what exactly you want the pgm to handle?
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
SK Beginner
Joined: 04 Feb 2004 Posts: 26 Topics: 3
|
Posted: Wed Mar 03, 2004 12:59 pm Post subject: |
|
|
Kolusu,
In my case I have two files and I compare them record by record after sorting them.I have to write all the deleted,added modified records in one output file.
Now lets say first 10 records are same in them so everything is fine till this point. But 11th record from 2nd file does not match with 11th record from 1st file and so that record comes in the output file.But since all the records after this 11th record are moved from their position to one position down after sorting, none of them match with the records in the same positions in the 1st file, so all records come in the output file even though nothing is changed in them.
1st file
record 1 - 10
record 2 - 20
record 3 - 35
record 4 - 45
2nd file
record 1 - 10
record 2 - 20
record 3 - 30
record 4 - 35
record 5 - 45
so now first 2 records are fine. 3rd is compared with 3rd in 2nd file, since they are not matching it will come in the o/p file.Now 4th also does not match as its position is changed and it also comes. I hope now this will make clear what I wanted to ask. |
|
Back to top |
|
 |
|
|