Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm
No new posts pre-compiler for program in an HFS Pedro DB2 0 Fri Jun 23, 2017 11:13 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us