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

Include condition value in dataset


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rakesh1155

New User


Joined: 21 Jan 2009
Posts: 84
Location: India

PostPosted: Tue Mar 30, 2010 5:37 pm
Reply with quote

I have a dataset:

TEST.GROUPS (FB,LRECL=8)
AAAAAAAA
BBBBBBBB
CCCCCCC
HHHHHHHH


IN.DATASET (FB.LRECL=80) contains :

AAAAAAAA DATA1A........
AAAAAAAA DATA1B........
AAAAAAAA DATA1C........
BBBBBBBB DATA2A........
BBBBBBBB DATA2A........
CCCCCCC DATA3A........
DDDDDDD DATA4A........
EEEEEEEEE DATA5A........
EEEEEEEEE DATA5B........
EEEEEEEEE DATA5C........
FFFFFFFFFF DATA6A........
GGGGGGG DATA7A........
HHHHHHHH DATA8A........
HHHHHHHH DATA8B........
HHHHHHHH DATA8C........


The output should compare the two datasets for the 1st 8 bytes and give a third datset with all the matching records from the IN.DATASET

In this case, the OUT.DATSET(FB,LRECL=80) should contain

AAAAAAAA DATA1A........
AAAAAAAA DATA1B........
AAAAAAAA DATA1C........
BBBBBBBB DATA2A........
BBBBBBBB DATA2A........
CCCCCCC DATA3A........
HHHHHHHH DATA8A........
HHHHHHHH DATA8B........
HHHHHHHH DATA8C........

Because 8 As , 8Bs, 8 Cs and 8 Hs are existing in TEST.GROUPS.

Can we achieve it through SORT INCLUDE COND?

Can the INCLUDE COND be extended to other datasets ?

Thanking in advance,
Rakesh.
Back to top
View user's profile Send private message
Bala1

New User


Joined: 18 Mar 2010
Posts: 6
Location: london

PostPosted: Tue Mar 30, 2010 5:42 pm
Reply with quote

Rakesh,
Please have a look in the below link..

section Cartesian join

ftp.software.ibm.com/storage/dfsort/mvs/sorttrck.pdf
Back to top
View user's profile Send private message
rakesh1155

New User


Joined: 21 Jan 2009
Posts: 84
Location: India

PostPosted: Tue Mar 30, 2010 6:07 pm
Reply with quote

Thanks Bala!

The Cartesian Join will merge records from both the files.

But in my requirement, the output file should contain records from IN.DATSET (File2) with a match in TEST.GROUPS(File1).

The output should not contain records from TEST.GROUPS (File1).

Will the Cartesian Join Help ?
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: Tue Mar 30, 2010 8:34 pm
Reply with quote

Hello,

Quote:
Will the Cartesian Join Help ?
No. I don't know why this was suggested. . .

Unless i completely misunderstand what you are looking for, you want a 2-file match on a key (not a Cartesian product). . .

There are many examples of matching 2 files in the forum. . . Suggest you use one of these as a guide.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Mar 30, 2010 10:11 pm
Reply with quote

rakesh1155,

The following DFSORT JCL will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=your 8 byte input file,DISP=SHR
//SORTOUT  DD DSN=&&TM80,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)           
//HDR      DD DSN=&&HDR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)             
//OUT      DD SYSOUT=*                                                 
//SYSIN    DD    *                                                     
  SORT FIELDS=COPY                                                     
  OUTREC OVERLAY=(80:X)                                                 
  OUTFIL FNAMES=HDR,ENDREC=1,BUILD=(C'$$$',80:X)                       
//*                                                                     
//STEP0200 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.HDR                 
//         DD DSN=&&TM80,DISP=SHR                                       
//         DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.HDR                 
//         DD DSN=your input 80 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(81:ID=1))     
  SORT FIELDS=(1,8,CH,A),EQUALS                                         
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,8,ZD,RESTART=(1,8))),     
  IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(82:81,1))               
                                                                       
  OUTFIL INCLUDE=(81,2,ZD,EQ,21,AND,1,3,CH,NE,C'$$$'),BUILD=(1,80)     
//*
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: Tue Mar 30, 2010 11:41 pm
Reply with quote

Hello,

I probably made a bad assumption that both files were already in key sequence.

If the files are in sequence, would this not be a candidate for JOINing. . .?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Mar 30, 2010 11:55 pm
Reply with quote

dick scherrer wrote:
Hello,

I probably made a bad assumption that both files were already in key sequence.

If the files are in sequence, would this not be a candidate for JOINing. . .?



Dick scherrer,

Sorted or unsorted it is an ideal candidate for joinkeys function. However I wasn't sure if OP had the latest PTF. If has the Latest PTF then he can use this job


Code:

//STEP0100 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//SORTJNF1 DD DSN=your input FB 80 byte file,DISP=SHR
//SORTJNF2 DD DSN=your input FB 8 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                   
  JOINKEYS FILES=F1,FIELDS=(1,8,A),SORTED,NOSEQCK
  JOINKEYS FILES=F2,FIELDS=(1,8,A),SORTED,NOSEQCK
  REFORMAT FIELDS=(F1:1,80)                       
  SORT FIELDS=COPY                               
//*
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Mar 31, 2010 12:04 am
Reply with quote

Note: Make sure you only use NOSEQCK if you KNOW that your records are already in sorted order. With SORTED and without NOSEQCK, DFSORT will check for out of order records and issue a message if it finds one. With SORTED and NOSEQCK, DFSORT does NOT check for out of order records (which can improve performance), so you must be sure that the records are already in order.
Back to top
View user's profile Send private message
rakesh1155

New User


Joined: 21 Jan 2009
Posts: 84
Location: India

PostPosted: Wed Mar 31, 2010 1:26 pm
Reply with quote

Thanks all you guys for your help.

I was able to achieve the desired results using the JOINKEYS. Yes, the files will be in sorted order.

I was a bit uncomfortable to understand the IFTHEN solution mentioned above. Skolusu, If you dont mind, please elaborate that solution.

-Thanks again,
Rakesh.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Allocated cylinders of a dataset DB2 12
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top