MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Updating a VSAM file using a flat file as input with an EZT
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Apr 18, 2007 2:02 am    Post subject: Updating a VSAM file using a flat file as input with an EZT Reply with quote

Hi,

I have two files. One is VSAM KSDS and the other is flat file. I wanna update a filed in the VSAM file by comparing an another filed in both the files.

Pls look at the below code, I wanna update the filed VSAM2 by taking the value from FLAT2, if the fileds VSAM1 and FLAT1 are equal.

Code:
FILE VSAM VS UPDATE
VSAM1            1     17  N
VSAM2            20    3   A
*
FILE FLAT
FLAT1              1     17  N
FLAT2              20    3   A
*
JOB INPUT FLAT

 READ VSAM KEY VSAM1 STATUS
*
   IF FILE-STATUS EQ 0
           IF VSAM1 = FLAT1
                 VSAM2 = FLAT2
                 WRITE VSAM UPDATE
           END-IF
   END-IF


The job ended with RC=0 but no records are updated in the VSAM file.

Could anyone pls let me know the reason as to why my VSAM file was not updated.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Apr 18, 2007 4:58 am    Post subject: Reply with quote

vkphani,

Try this


Code:

JOB INPUT FLAT

 READ VSAM KEY VSAM1 STATUS

 IF FILE-STATUS EQ 0
    IF VSAM1 = FLAT1
       VSAM2 = FLAT2
       WRITE VSAM UPDATE STATUS
       IF FILE-STATUS EQ 0
          DISPLAY 'SUCCESSFUL UPDATE'
       ELSE
          DISPLAY 'UPDATE FAILED WITH STATUS : ' FILE-STATUS
          STOP
       END-IF     
    END-IF
 ELSE
    DISPLAY 'READ FAILED WITH STATUS : ' FILE-STATUS
    STOP
 END-IF


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Apr 18, 2007 5:08 am    Post subject: Reply with quote

Kolusu,

I made the changes per your code but no records are updated.
Code:

READ FAILED WITH STATUS :            16
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Apr 18, 2007 5:23 am    Post subject: Reply with quote

Quote:

READ FAILED WITH STATUS : 16

vkphani,

A status code of 16 is caused by Record not found during READ operation. So check if you defined your vsam file correctly.

1. Is it a variable blocked/fixed block vsam cluster
2. Is the key in the vsam cluster 17 bytes and is it numeric?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Apr 18, 2007 5:25 am    Post subject: Reply with quote

Kolusu,


Quote:
1. Is it a variable blocked/fixed block vsam cluster

It is fixed block VSAM cluster.
Quote:
2. Is the key in the vsam cluster 17 bytes and is it numeric?

Yes it is 17 bytes and Numeric.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Apr 18, 2007 5:30 am    Post subject: Reply with quote

vkphani,

show us the sample of input from both flat file and the vsam cluster
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Apr 18, 2007 5:38 am    Post subject: Reply with quote

kolusu wrote:
vkphani,

show us the sample of input from both flat file and the vsam cluster


VSAM file data:
Code:

000001
000002 09600000000000000000
000003 09600100200002346195
000004 09600100200002357903
000005 09600100200002375699


Flat file data:
Code:
000001 09600100207401742577
000002 09600100207401795153
000003 09600100207401866335
000004 09600100207401882100
000005 09600100207401978502
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Apr 18, 2007 5:47 am    Post subject: Reply with quote

vkphani,

ok unless my eyes are messing with me in the morning, I do NOT see 1 single key which matches in both the files. The first 6 bytes are line numbers and then next 17 bytes is the key and I do NOT see a match.

So why did you expect that you will update the file?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Apr 18, 2007 5:52 am    Post subject: Reply with quote

Kolusu,

All the records in the flat file are present in the VSAM file but not viceversa. The first record in the flat file may present in say 120th record in the VSAM file and so on. So, the records from flat file should be searched in VSAM file and if a match is found then the other field should be updated.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Apr 18, 2007 6:08 am    Post subject: Reply with quote

vkphani,

Just remove the STOP after the display of the 'READ FAILED WITH STATUS :' and re-run your job.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Apr 18, 2007 6:14 am    Post subject: Reply with quote

Kolusu,

I did remove the STOP after the display of the 'READ FAILED WITH STATUS :' and re-ran the job. But no use. No records are updated in VSAM file.

VSAM 0 UPDATE
FLAT 215,224 INPUT
Back to top
View user's profile Send private message Send e-mail
DaPlaze
Beginner


Joined: 29 Mar 2007
Posts: 9
Topics: 2

PostPosted: Wed Apr 18, 2007 7:18 am    Post subject: Reply with quote

vkphani wrote:
Kolusu,

All the records in the flat file are present in the VSAM file but not viceversa. The first record in the flat file may present in say 120th record in the VSAM file and so on. So, the records from flat file should be searched in VSAM file and if a match is found then the other field should be updated.


Ok I'm not super hot on this type of coding.. is it Easytrieve? But I do think the problem is that the files aren't sorted and not in the same record.. As you write up here record 1 in the flat file, might be in the 120th record on the vsam file... As I see you program you are comparing record 1 with record 1 and so on.. you would need to do some kind of loop where it runs through the file..
Or have a sort before the program gets the file..

At least that is what I think, but again, i'm not that good..
Back to top
View user's profile Send private message
expat
Intermediate


Joined: 01 Mar 2007
Posts: 475
Topics: 9
Location: Welsh Wales

PostPosted: Wed Apr 18, 2007 7:28 am    Post subject: Reply with quote

Quote:
READ VSAM KEY VSAM1 STATUS

Should you not use
Quote:
READ VSAM KEY FLAT1 STATUS

To call the VSAM record with the key matching that of the flatfile record.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Apr 18, 2007 8:01 am    Post subject: Reply with quote

expat wrote:
Quote:
READ VSAM KEY VSAM1 STATUS

Should you not use
Quote:
READ VSAM KEY FLAT1 STATUS

To call the VSAM record with the key matching that of the flatfile record.


expat,

You are right on the money. I overlooked the read statement .

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
expat
Intermediate


Joined: 01 Mar 2007
Posts: 475
Topics: 9
Location: Welsh Wales

PostPosted: Wed Apr 18, 2007 8:05 am    Post subject: Reply with quote

Isn't it always the case where the easiest errors to fix are the hardest ones to find.
_________________
If it's true that we are here to help others,
then what exactly are the others here for ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group