View previous topic :: View next topic |
Author |
Message |
Samuel Beginner
Joined: 12 Aug 2004 Posts: 38 Topics: 10
|
Posted: Fri Feb 11, 2005 9:33 am Post subject: EASYTRIEVE UPDATE SEQUENTIAL FILE |
|
|
I am comparing a VSAM file to a sequential SAM file. When I find a match, I want to copy a field to a second SAM file. How do I update a field in a SAM file? |
|
Back to top |
|
|
programmer1 Beginner
Joined: 18 Feb 2004 Posts: 138 Topics: 14
|
Posted: Fri Feb 11, 2005 9:46 am Post subject: |
|
|
what is a SAM file ? _________________ Regards,
Programmer |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Fri Feb 11, 2005 9:54 am Post subject: |
|
|
Quote: |
I am comparing a VSAM file to a sequential SAM file. When I find a match, I want to copy a field to a second SAM file. How do I update a field in a SAM file?
|
Samuel,
Post detailed information on what you're trying to accomplish. Do not make people guess what you mean. This will give you a much better chance of getting a good answer to your question.
As per your post, you are comparing a vsam file to a sequential file. if they match you want to write to seperate file? If that is the case then where does the update come into picture?
programmer1 SAM means a sequential file (sam - sequential access method)
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Samuel Beginner
Joined: 12 Aug 2004 Posts: 38 Topics: 10
|
|
Back to top |
|
|
Samuel Beginner
Joined: 12 Aug 2004 Posts: 38 Topics: 10
|
Posted: Fri Feb 11, 2005 10:06 am Post subject: |
|
|
I aploagize Kolosu, I was not making myself clear.
All I really want to do is comare one VSAM file to a Sam file and update one field on the SAM file when I find a match.
The key on the VSAM file is made up of three fields that are also found on the SAM file, but they are not stored in a manner that would allow me to successfully use the MATCH statement. Therefore, I created a third Sam file that allows me to use the MATCH statement. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Fri Feb 11, 2005 11:33 am Post subject: |
|
|
Samuel,
A word of caution before running this code. You are trying to update an existing sequential file. If you don't have a backup of the data and if the program abends , then you will loose all your data.
The trick to update a sequential file in easytrieve is to define the same file for both input and output.
Code: |
//STEP0100 EXEC PGM=EZTPA00
//STEPLIB DD DSN=EASYTREV.LOADLIB,
// DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSSNAP DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//INFILE DD DSN=YOUR SEQUENTIAL FILE,
// DISP=SHR
//INVSAM DD DSN=YOUR VSAM FILE,
// DISP=SHR
//OUTPUT DD DSN=YOUR SEQUENTIAL FILE,
// DISP=OLD
//*
//SYSIN DD *
FILE INFILE
IN-REC 01 080 A
IN-KEY 01 009 A
FILE INVSAM VS
VSAM-KEY 01 009 A
FILE OUTPUT FB(0 0)
OUT-REC 01 080 A
OUT-UPD 14 050 A
***********************************************************************
* MAINLINE *
***********************************************************************
JOB INPUT (INFILE KEY (IN-KEY) +
INVSAM KEY (VSAM-KEY))
IF MATCHED
OUT-REC = IN-REC
OUT-UPD = 'I AM UPDATING THIS FIELD'
PUT OUTPUT
END-IF
|
Quote: |
The key on the VSAM file is made up of three fields that are also found on the SAM file, but they are not stored in a manner that would allow me to successfully use the MATCH statement. Therefore, I created a third Sam file that allows me to use the MATCH statement.
|
You can use the 3 different fields as a key, they don't need together to use the MATCH statement in easytrieve. All you need is that the file should be sorted on the 3 key fields for the match logic to work.
for ex:
vsam file has 3 fields at position 10 , 20 , 30 bytes with lengths of 5, 3, & 2 respectively
then you can code
Code: |
FILE INVSAM VS
VSAM-KEY1 10 005 A
VSAM-KEY2 20 003 A
VSAM-KEY3 30 002 A
FILE INFILE
IN-KEY1 01 005 A
IN-KEY1 06 003 A
IN-KEY1 09 002 A
JOB INPUT (INFILE KEY (IN-KEY1 INKEY2 IN-KEY3) +
INVSAM KEY (VSAM-KEY1 VSAM-KEY2 VSAM-KEY3))
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Samuel Beginner
Joined: 12 Aug 2004 Posts: 38 Topics: 10
|
Posted: Mon Feb 14, 2005 10:57 am Post subject: |
|
|
Kosolu ,
All of your advice appears to be on the right track but I keep getting the following error:
117 *******A001 FILE OPEN ERROR - OUTPUT
117 JOB INPUT (EXTRACT KEY (SAV-KEY1 SAV-KEY2 SAV-KEY3) +
PSCRDTLR KEY (DTL-KEY1 DTL-KEY2 DTL-KEY3)) |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Feb 14, 2005 11:05 am Post subject: |
|
|
Quote: |
A001 FILE OPEN ERROR - OUTPUT
|
post your JCL
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Samuel Beginner
Joined: 12 Aug 2004 Posts: 38 Topics: 10
|
Posted: Mon Feb 14, 2005 11:33 am Post subject: |
|
|
Code: |
//STEP01 EXEC PSDSCEZP
//PSCRDTLR DD DSN=VSAM.FILE,DISP=SHR
//INFILE DD DSN=SEQUEANTIAL.FILE,DISP=SHR
//OUPUT DD DSN=SEQUENTIAL.FILE,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSSNAP DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN DD *
*
FILE PSCRDTLR VS
DTL-KEY1 01 009 A
DTL-KEY2 10 002 A
DTL-KEY3 12 002 A
%PSCRE006
*
FILE EXTRACT
EXTRACT-REC 01 102 A
SAV-SSN-EDITED 01 01 A
SAV-KEY1 02 09 A
SAV-PROG-EDITED 11 01 A
SAV-KEY2 12 02 A
SAV-SEQNO-EDITED 14 01 A
SAV-KEY3 15 02 A
SAV-NAME 17 32 A
SAV-DHRFILE 49 09 A
SAV-REASON-EDITED 58 01 A
SAV-AMOUNT-EDITED 60 01 A
SAV-WORKER-EDITED 68 01 A
SAV-XREFNUM-EDITED 78 01 A
*
FILE OUTPUT FB(0 0)
OUT-REC 01 102 A
OUT-UPD 49 009 A
**********************************************************************
* MAINLINE
**********************************************************************
JOB INPUT (EXTRACT KEY (SAV-KEY1 SAV-KEY2 SAV-KEY3) +
PSCRDTLR KEY (DTL-KEY1 DTL-KEY2 DTL-KEY3))
IF MATCHED
OUT-REC = EXTRACT-REC
OUT-UPD = CR-DTL-DHR-FILE-NO
PUT OUTPUT
END-IF
*
GOTO JOB
*
|
|
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Feb 14, 2005 12:01 pm Post subject: |
|
|
Samuel,
Remove the GOTO JOB at the end of your program. You don't need that !
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Samuel Beginner
Joined: 12 Aug 2004 Posts: 38 Topics: 10
|
Posted: Mon Feb 14, 2005 1:23 pm Post subject: |
|
|
Kolusu,
Take a look at my DD names.
Thank-you. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Feb 14, 2005 1:49 pm Post subject: |
|
|
Quote: |
//PSCRDTLR DD DSN=VSAM.FILE,DISP=SHR
//EXTRACT DD DSN=SEQUEANTIAL.FILE,DISP=SHR
//OUTPUT DD DSN=SEQUENTIAL.FILE,DISP=OLD
|
Samuel,
Make the changes higlighted in bold.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Samuel Beginner
Joined: 12 Aug 2004 Posts: 38 Topics: 10
|
Posted: Mon Feb 14, 2005 3:43 pm Post subject: |
|
|
Kolusu,
It gave me the desired results.
Sam |
|
Back to top |
|
|
|
|