IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Rewrite the existing record in a program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Mon Jun 19, 2006 3:57 pm
Reply with quote

Hi all,
I was trying to rewrite the existing record in a program. when i follow the below code i faced a logical error. when i enter the roll no as 100 and edit the field , 101 record is been rewritten. like this the record pointer is read and rewriten to the next record. How can i overcome from this error. plz help me

CODE:

Code:
FILEEDT.
           DISPLAY "ENTER THE STUDENT ROLL NO TO EDIT ".
           ACCEPT RNO.
           READ STD-FILE
              KEY IS SROLL
              INVALID KEY DISPLAY " INVALID ROLL NO .. ERROR FS : " FS
           END-READ.
           DISPLAY STD-DET.
           DISPLAY "ENTER WHICH FIELD YOU NEED TO EDIT ".
           DISPLAY "CODE : 1.ROLLNO, 2.NAME, 3.MARKS ".
           ACCEPT FLD.
           IF FLD = 1 DISPLAY "ENTER ROLLNO :" ACCEPT SROLL1
             MOVE SROLL1 TO SROLL
           ELSE IF FLD = 2 DISPLAY "ENTER NAME : " ACCEPT SNAME1
             DISPLAY "ENTER INITIAL : " ACCEPT SINIT1
             MOVE SNAME1 TO SNAME
             MOVE SINIT1 TO SINIT
           ELSE IF FLD = 3 DISPLAY "ENTER MARK1 : " ACCEPT MARK1
             DISPLAY "ENTER MARK2 : " ACCEPT MARK2
             DISPLAY "ENTER MARK3 : " ACCEPT MARK3
             COMPUTE TOTAL1 = MARK1 + MARK2 + MARK3
             MOVE MARK1 TO SMARK1
             MOVE MARK2 TO SMARK2
             MOVE MARK3 TO SMARK3
             MOVE TOTAL1 TO STOTAL
           ELSE DISPLAY "INVALID CHOICE "
           END-IF.
           DISPLAY SNAME SPACE SROLL SPACE SINIT.
           REWRITE STD-DET
             INVALID KEY DISPLAY "KEY ERROR !!!  " FS
           END-REWRITE.
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Mon Jun 19, 2006 5:55 pm
Reply with quote

Hi all,

I got the solution. Yap. The thing is i used the READ statement at the begining. So that After a read the Record pointer moves to the next record. such that if i try to rewrite it was written to the next record probably. Now once i remove the READ statement at the top the process is moving quite fine. Thanks for all.
Back to top
View user's profile Send private message
sunnybunny

New User


Joined: 29 Nov 2005
Posts: 49

PostPosted: Mon Jun 19, 2006 6:19 pm
Reply with quote

Hi,

But here one thing i didn't understand. A/C to ur solution without reading the record how can we update it? Please clarify it.

Thanks,
Sunny.
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Mon Jun 19, 2006 6:59 pm
Reply with quote

Sunny,

REWRITE Means READ & WRITE, Hope clear. icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Using API Gateway from CICS program CICS 0
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top