MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Rewriting VB record in COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
SathishKrishna
Beginner


Joined: 18 Jun 2015
Posts: 3
Topics: 2

PostPosted: Sat Jun 27, 2015 4:11 pm    Post subject: Rewriting VB record in COBOL Reply with quote

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
View user's profile Send private message
t-bonham@scc.net
Supermod


Joined: 18 Oct 2012
Posts: 30
Topics: 0
Location: Minneapolis, MN

PostPosted: Sat Jun 27, 2015 9:22 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
SathishKrishna
Beginner


Joined: 18 Jun 2015
Posts: 3
Topics: 2

PostPosted: Sun Jun 28, 2015 2:32 pm    Post subject: Reply with quote

Thanks for ur reply. I just modified the read process in code and it worked fine.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group