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
 

 

copying records to RRDS file from cobol

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

New User


Joined: 22 Feb 2010
Posts: 14
Location: Hyderabad

PostPosted: Wed Mar 03, 2010 10:29 pm    Post subject: copying records to RRDS file from cobol
Reply with quote

Hi please see the files.

Code:
PS-File:
eno ename sal
01  sach  1000.
03  bhar  2000.

RRDS-File:
eno ename sal
01  hhhh  5000.
02  jjjj  1000.
03  lkkl  3000.


Now i am trying to update the records which will matches to the RRDS file from PS file. Is it possible ?

Matching will check for the same eno in both files.

I tried but the records are not getting update.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Mar 03, 2010 10:39 pm    Post subject:
Reply with quote

Hello,

Quote:
I tried but the records are not getting update.
What did you try?

Telling us "it didn't work" provides nothing for someone to use to help you. . .
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Mar 03, 2010 10:53 pm    Post subject:
Reply with quote

azar.mhd wrote:
Now i am trying to update the records which will matches to the RRDS file from PS file. Is it possible ?
Update in place? No third file as output?
Quote:
Matching will check for the same eno in both files.
OK, but what do you expect the output to look like?
Quote:
I tried but the records are not getting update.
Like Dick asked, what did you try?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Wed Mar 03, 2010 10:59 pm    Post subject: Reply to: copying records to RRDS file from cobol
Reply with quote

RRDS ==> Relative Record Data Set

records are identified by the <record number> and they are not ordered on any record part

identifying the record to be updated is up to you

evaluate if your requirement can be better met by a KSDS dataset
Back to top
View user's profile Send private message
azar.mhd

New User


Joined: 22 Feb 2010
Posts: 14
Location: Hyderabad

PostPosted: Thu Mar 04, 2010 8:50 am    Post subject:
Reply with quote

Quote:
What did you try?


I tried to update the records using rewrite command. ok I will post exactly what i want and what i did.

Quote:
what do you expect the output to look like?


Input files are

Code:
PS-File:
eno ename sal
01  sach  1000.
03  bhar  2000.

RRDS-File:
eno ename sal
01  hhhh  5000.
02  jjjj  1000.
03  lkkl  3000.


Out file should be

Code:
RRDS-File:
eno ename sal
01  sach  1000.
02  jjjj  1000.
03 bhar  2000.


I tried with the following code

RRN is defined as record key in i-o section for RRDS. It was declared in WORKING-STORAGE SECTION with 99. For RRDS access mode is sequential. TEST is also a Temp dataitem declared in W-S Section

Code:
OPEN INPUT  PS.
PERFORM 2 TIMES
READ PS
 OPEN I-O RRDS
 MOVE 1 TO RRN
  PERFORM UNTIL TEST = 'Y'
  COMPUTE RRN = RRN + 1
   IF(PS-ENO = RRDS-ENO)
   MOVE 'Y' TO TEST
   MOVE PSENAME TO RRDSENAME
   MOVE PS-ESAL TO RRDS-ESAL
   CLOSE RRDS
   OPEN I-O RRDS
   REWRITE RRDS-REC
  END-IF
 END-PERFORM
 CLOSE RRDS
END-PERFORM.
CLOSE PSFILE.
STOP RUN.
 
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Mar 04, 2010 9:44 am    Post subject:
Reply with quote

Hello,

Why is there close/open in the middle of the process?

Suggest you speak with one of your seniors or the teacher about structuring the code in a more appropriate manner. At a minimum, the reading of the PS file should be controlledby an "at end". . .
Back to top
View user's profile Send private message
azar.mhd

New User


Joined: 22 Feb 2010
Posts: 14
Location: Hyderabad

PostPosted: Thu Mar 04, 2010 10:05 am    Post subject:
Reply with quote

Can't I use the process which i mentioned above. Just i want to stop reading PS file when the match occurs between two file. Any how there will be matching eno in two files, if not there may be a chance of getting problem.

Correct me if am wrong.

" if we want to use the file to read and write at a time, we should close the file after reading and need open it again " my senior told.

Thats why i did like that. Instead of rewriting i used display, then am getting exactly what i required(updated records which should be written to RRDS) in output. But when i used rewrite then also no errors but records are not getting update.

Can you tell me that any file opened in i-o mode, can be read and write at a time or not ?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Mar 04, 2010 10:57 am    Post subject:
Reply with quote

Hello,

Quote:
Correct me if am wrong.
In most organizations this approach would be considered "wrong".

Quote:
Just i want to stop reading PS file when the match occurs between two file. Any how there will be matching eno in two files, if not there may be a chance of getting problem.

There is no reason to open the files more than once. If there are any problems, it is because there are errors in the code. The normal way to implement this kind of requirement is to read the ps file, read the corresponding relative record, and update the relative record data with the content of the "transaction".
Back to top
View user's profile Send private message
azar.mhd

New User


Joined: 22 Feb 2010
Posts: 14
Location: Hyderabad

PostPosted: Thu Mar 04, 2010 8:04 pm    Post subject:
Reply with quote

Thank you ! I got it.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Mar 04, 2010 8:10 pm    Post subject: Reply to: copying records to RRDS file from cobol
Reply with quote

You're welcome icon_smile.gif

d
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 copying data without knowing location arunsoods DFSORT/ICETOOL 6 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


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