View previous topic :: View next topic |
Author |
Message |
SathishKrishna Beginner
Joined: 18 Jun 2015 Posts: 3 Topics: 2
|
Posted: Sat Jun 27, 2015 4:11 pm Post subject: Rewriting VB record in COBOL |
|
|
I have a VB file with lrecl of 32500. I would like to update 2 digit sequence no @13th position for duplicate records (first 12 bytes as key).
When i execute the program, first record is updated with Sequence no and after that below message is written in the output.
* * * I/O error detected, I/O terminated * * *
Code: |
FD SEQFILE
RECORDING MODE IS V
RECORD IS VARYING FROM 100 TO 32500 CHARACTERS
DEPENDING ON WS-REC-LEN
LABEL RECORDS ARE STANDARD
DATA RECORD IS SEQ-REC.
01 SEQ-REC.
05 SEQ-KEY PIC X(12).
05 SEQ-NO PIC 9(02).
05 DATA PIC X(32486).
PROCEDURE DIVISION.
PERFORM 1000-OPEN-FILE THRU 1000-EXIT.
PERFORM 2000-READ-SEQ-FILE THRU 2000-EXIT
UNTIL EOF-SEQ = 'Y'.
2000-READ-SEQ-FILE.
READ SEQFILE INTO WS-SEQ-REC
AT END MOVE 'Y' TO EOF-SEQ.
IF EOF-SEQ = 'N'
IF FIRST-KEY
MOVE WS-SEQ-KEY TO WS-HOLD-KEY
MOVE 'N' TO FIRST-KEY-SW
END-IF
IF WS-SEQ-KEY = WS-HOLD-KEY
ADD 01 TO SEQ-CNTR
MOVE SEQ-CNTR TO WS-SEQ-NO
ELSE
MOVE WS-SEQ-KEY TO WS-HOLD-KEY
MOVE 01 TO SEQ-CNTR
MOVE SEQ-CNTR TO WS-SEQ-NO
END-IF
REWRITE SEQ-REC FROM WS-SEQ-REC.
|
iNPUT: Code: |
D00011111111 *01*1........
D00011111111 *01*1........
D00022222222 *01*1........
|
Expected:
Code: |
D0001111111101 *01*1........
D0001111111102 *01*1........
D0002222222201 *01*1........
|
Can you pls help me on what is wrong in the above code or suggest me some other option if any. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
t-bonham@scc.net Supermod
Joined: 18 Oct 2012 Posts: 30 Topics: 0 Location: Minneapolis, MN
|
Posted: Sat Jun 27, 2015 9:22 pm Post subject: |
|
|
This kind of error is usually related to the OS detecting a problem with the length of the specific record being read. Like, for example, you are working with a data field in column 20, but you happen to have read a record that is shorter than 20 characters, and didn't check the length before trying to look in the 20th character.
I'd look into that possibility -- check out what is happening with your field WS-REC-LEN. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
SathishKrishna Beginner
Joined: 18 Jun 2015 Posts: 3 Topics: 2
|
Posted: Sun Jun 28, 2015 2:32 pm Post subject: |
|
|
Thanks for ur reply. I just modified the read process in code and it worked fine. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|
|