jcl to merge file based on keys



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

jcl to merge file based on keys

Postby Kasikannan » Thu Apr 07, 2011 12:28 pm

Hi,

My input is

AAAA111 12
BBBB222 13
CCCC333 14
and
DDDD444 15
EEEE555 16
FFFF666 17

My output should be
AAAA111 12
BBBB222 13
CCCC333 14
DDDD444 .. 15
EEEE555 .. 16
FFFF666 .. 17

I used sort card as below
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(01,07,A)
JOINKEYS FILES=F2,FIELDS=(01,07,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,10,F2:1,12),FILL=X'FF'
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(01,10,BI,EQ,X'FF'),BUILD=(8,7))

/*

and I got the output as
AAAA111 12
BBBB222 13
CCCC333 14
.............. DDDD444 15
...............EEEE555 16
...............FFFF666 17

How can i get the expected result? Please help
Kasikannan
 
Posts: 5
Joined: Mon Apr 04, 2011 12:04 pm
Has thanked: 0 time
Been thanked: 0 time

Re: jcl to merge file based on keys

Postby enrico-sorichetti » Thu Apr 07, 2011 1:38 pm

from topic title and the sample posted a plain sort should be enough!
if it is not so ... reword everything and post more meaningful examples
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: jcl to merge file based on keys

Postby Kasikannan » Thu Apr 07, 2011 2:01 pm

Hi,

Hope this may give a clear view

input file1:
aaaa xxx
bbbb yyy
cccc zzz

input file2:
aaaa 111
dddd 222
eeee 333

required output file:
aaaa xxx 111
bbbb yyy space
cccc zzz space
dddd space 222
eeee space 333
Kasikannan
 
Posts: 5
Joined: Mon Apr 04, 2011 12:04 pm
Has thanked: 0 time
Been thanked: 0 time

Re: jcl to merge file based on keys

Postby Frank Yaeger » Thu Apr 07, 2011 8:46 pm

You can use a DFSORT job like the following to do what I think you're asking for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD *
aaaa xxx
bbbb yyy
cccc zzz
//IN2 DD *
aaaa 111
dddd 222
eeee 333
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(1,4,A)
  JOINKEYS F2=IN2,FIELDS=(1,4,A)
  JOIN UNPAIRED
  REFORMAT FIELDS=(F1:1,9,F2:6,3)
  OPTION COPY
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: jcl to merge file based on keys

Postby raulravi » Tue Jul 23, 2013 5:43 pm

Dear Frank,

I have tried your sort code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD *
aaaa xxx
bbbb yyy
cccc zzz
//IN2 DD *
aaaa 111
dddd 222
eeee 333
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(1,4,A)
  JOINKEYS F2=IN2,FIELDS=(1,4,A)
  JOIN UNPAIRED
  REFORMAT FIELDS=(F1:1,9,F2:6,3)
  OPTION COPY
/*


The output is :
************
AAAA XXX 111
BBBB YYY   
CCCC ZZZ   
         222
         333
************


But the expected out put is :
************
AAAA XXX 111
BBBB YYY   
CCCC ZZZ   
DDDD        222
EEEE         333
************


Can you please advice?

Raul
raulravi
 
Posts: 3
Joined: Thu Dec 13, 2012 4:39 pm
Has thanked: 0 time
Been thanked: 0 time

Re: jcl to merge file based on keys

Postby raulravi » Tue Jul 23, 2013 5:45 pm

Expected output is:
************
AAAA XXX 111
BBBB YYY   
CCCC ZZZ   
DDDD     222
EEEE     333
***********
raulravi
 
Posts: 3
Joined: Thu Dec 13, 2012 4:39 pm
Has thanked: 0 time
Been thanked: 0 time

Re: jcl to merge file based on keys

Postby NicC » Tue Jul 23, 2013 6:58 pm

First, you should not tailgate old topics - start a new topic with a reference to the topic you are refering to.
Second, you should not address a post to a specific person. It is fine if you do not want an answer from anyone else but you will have to be prepared to wait for ever as Frank retired some time ago and no longer contributes.
Third, what have you done to try and understand why you are getting the result you show?
Fourth, what have you tried in order to get the answer that YOU want?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: jcl to merge file based on keys

Postby dick scherrer » Tue Jul 23, 2013 9:33 pm

Hello and welcome to the forum,

For us to help, it will be best if you post the informational messages that were gnerated by the run. Include the message ids.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: jcl to merge file based on keys

Postby skolusu » Tue Jul 23, 2013 10:25 pm

raulravi,

Use the following control cards.

//SYSIN   DD *                                         
  JOINKEYS F1=IN1,FIELDS=(1,4,A)                       
  JOINKEYS F2=IN2,FIELDS=(1,4,A)                       
  JOIN UNPAIRED                                       
  REFORMAT FIELDS=(F1:1,9,F2:1,4,6,3,?)               
  INREC IFOUTLEN=12,                                   
  IFTHEN=(WHEN=(17,1,CH,EQ,C'B'),BUILD=(1,9,14,3)),   
  IFTHEN=(WHEN=(17,1,CH,EQ,C'2'),BUILD=(10,4,5X,14,3))
  OPTION COPY                                         
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post