View previous topic :: View next topic
|
Author |
Message |
azar.mhd
New User
Joined: 22 Feb 2010 Posts: 14 Location: Hyderabad
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
azar.mhd
New User
Joined: 22 Feb 2010 Posts: 14 Location: Hyderabad
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
azar.mhd
New User
Joined: 22 Feb 2010 Posts: 14 Location: Hyderabad
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
azar.mhd
New User
Joined: 22 Feb 2010 Posts: 14 Location: Hyderabad
|
|
|
|
Thank you ! I got it. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome
d |
|
Back to top |
|
|
|