VSAM files comparision and updation through JCL

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
m16lakshmi
Member
Posts: 1
Joined: Thu Aug 14, 2014 6:10 pm

VSAM files comparision and updation through JCL

Post by m16lakshmi » Thu Aug 14, 2014 6:25 pm

Please help in below requirement.

I have two VSAM files .Both having key on 1 to 14 bytes (three fields).
VSAM file looks like below
Key and Data

model1,year1 ,asset1 Data1-> Model1 +year1 +asset1 is key.
model1,year1,asset2 data1
Model1,year2 asset1 Data2
..
..
Similarly VSAM file2 have same key but data part is diffrent.

I have to compare both files if the key is same then i have to update VSAM file1 data part when VSAM file2 data is > spaces.

Can it be done through JCL? if so please advise me.

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Sun Aug 17, 2014 2:02 pm

No - it cannot be done by JCL although JCL may well be needed to execute the program that you require.
Please not the topics covered in the JCL part of the forum:
JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3
and look at the other sections of the forum whre you may have made a more appropriate post.

You can possibly do this via your sort product but I will leave that up to the sort experts.
Regards
Nic

User avatar
Vamsi99
Active Member
Posts: 183
Joined: Wed Nov 05, 2008 11:20 am

Post by Vamsi99 » Sat Aug 23, 2014 3:38 pm

I suggest to use EASYTRIEVE/COBOL for this work. it is very easy to do this work.
search EASYTRIEVE forum for MATCHED keyword.


------------------------------------------------------



If you want to use only JCL, You may try using DFSORT.


Sample Requirement
------------------------
If any of the records from the input1 dataset (start pos 14 for 20) match ANY of the records from the input2 dataset (start pos 61 for 20) then I want to output from start pos 1 for 33 from the input1 dataset record and start pos 82 for 80 from the input2 dataset record to an output dataset called 'matched' (a single output record, not two output records).

Any unmatched/unpaired records from the input1 dataset (start pos 14 for 20) need to be output from start pos 1 for 33 from the input1 dataset record to an output dataset called 'nomatch1'

Any unmatched/unpaired records from the input2 dataset (start pos 61 for 20) need to be output from start pos 82 for 80 from the input2 dataset record to an output dataset called 'nomatch2'


Code: Select all

//S1  EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/266)
//IN2 DD DSN=...  input file2 (FB/266)
//MATCHED DD DSN=...  output file1 (FB/266)
//NOMATCH1 DD DSN=...  output file2 (FB/266)
//NOMATCH2 DD DSN=...  output file3 (FB/266)
//SYSIN    DD    *
  JOINKEYS F1=IN1,FIELDS=(14,20,A)
  JOINKEYS F2=IN2,FIELDS=(61,20,A)
  JOIN UNPAIRED,F1,F2
  REFORMAT FIELDS=(F1:1,33,F2:82,80,?)
  OPTION COPY
  OUTFIL FNAMES=MATCHED,INCLUDE=(114,1,CH,EQ,C'B'),
    BUILD=(1,114,266:X)
  OUTFIL FNAMES=NOMATCH1,INCLUDE=(114,1,CH,EQ,C'1'),
    BUILD=(1,33,266:X)
  OUTFIL FNAMES=NOMATCH2,INCLUDE=(114,1,CH,EQ,C'2'),
    BUILD=(34,80,266:X)
/*



other discussion topics in this forum....

http://www.mainframegurukul.com/ibmmain ... t6020.html

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Sat Aug 23, 2014 3:52 pm

Unless I've misunderstood, it is a simple keyed read with the file 2 key: if present, update file 1 from the file 2 data. This is rather than using MATCHED (you can't use a VSAM file in UPDATE mode with MATCHED).

To get it with SORT would require output to a PS, and then copy the PS (IDCAMS REPRO) back to the KSDS, as SORT does not do keyed reads and updates, or matches and updates-in-place.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others