Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Rewrite the existing record in a program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Mon Jun 19, 2006 3:57 pm    Post subject: Rewrite the existing record in a program
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: 680
Location: NJ

PostPosted: Mon Jun 19, 2006 5:55 pm    Post subject: Rewrite Error.
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    Post subject: Re: REWRITE Logic - Help
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: 680
Location: NJ

PostPosted: Mon Jun 19, 2006 6:59 pm    Post subject: Re: REWRITE Logic - Help
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us