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

copying records to RRDS file from cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Wed Mar 03, 2010 10:39 pm
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: 2146
Location: At my coffee table

PostPosted: Wed Mar 03, 2010 10:53 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Mar 03, 2010 10:59 pm
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
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

Moderator Emeritus


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

PostPosted: Thu Mar 04, 2010 9:44 am
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
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

Moderator Emeritus


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

PostPosted: Thu Mar 04, 2010 10:57 am
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
Reply with quote

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

Moderator Emeritus


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

PostPosted: Thu Mar 04, 2010 8:10 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top