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

show the merged value when duplicated on key


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

New User


Joined: 23 Mar 2008
Posts: 13
Location: china

PostPosted: Wed Feb 11, 2009 8:07 pm
Reply with quote

urgent: show the merged value when duplicated on key

1-6 are the key field. if there are duplicated on the key field, then need to merge 12-14, and then show the merged value in all duplicated records.



input:

AAABBB 111 1 A1
AAABBB 222 0 A2
AAABBB 333 1 A3
AAABBB 444 1 A4
CCCDDD 555 1 A5
EEEFFF 666 1 A6

output:

AAABBB 111 011 A1
AAABBB 222 011 A2
AAABBB 333 011 A3
AAABBB 444 011 A4
CCCDDD 555 1 A5
EEEFFF 666 1 A6


thanks for you all help
Back to top
View user's profile Send private message
liangl

New User


Joined: 23 Mar 2008
Posts: 13
Location: china

PostPosted: Wed Feb 11, 2009 8:19 pm
Reply with quote

Sorry, I need to fix my post:
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 Feb 11, 2009 10:44 pm
Reply with quote

You can use a DFSORT/ICETOOL job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes. You'll need z/OS DFSORT PTF UK90013 (July, 2008) to use the WITHANY function. If you don't have this PTF, ask your System Programmer to install it.

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD *
AAABBB 111   1     A1
AAABBB 222 0       A2
AAABBB 333     1   A3
AAABBB 444     1   A4
CCCDDD 555 1       A5
EEEFFF 666   1     A6
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
SPLICE FROM(IN) TO(T1) ON(1,6,CH) KEEPNODUPS -
  WITHANY WITH(12,1) WITH(14,1) WITH(16,1)
COPY FROM(IN) TO(T1)
SPLICE FROM(T1) TO(OUT) ON(1,6,CH) WITHALL -
  WITH(1,11) WITH(17,64)
/*


In the future, please post inline text rather than GIF files.
Back to top
View user's profile Send private message
liangl

New User


Joined: 23 Mar 2008
Posts: 13
Location: china

PostPosted: Wed Feb 11, 2009 10:55 pm
Reply with quote

Thank to reply me, but it is true our system doesn't support WITHANY function, has any other way to solve it?
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 Feb 11, 2009 11:17 pm
Reply with quote

Run this job and show me the //SYSOUT messages:

Code:

//S1    EXEC  PGM=SORT                                           
//SYSOUT    DD  SYSOUT=*                                 
//SORTDIAG DD DUMMY       
//SORTIN DD *                                                   
RECORD 1                                                                                           
//SORTOUT DD DUMMY 
//SYSIN    DD    *                                               
  OPTION COPY       
/*                                             
Back to top
View user's profile Send private message
liangl

New User


Joined: 23 Mar 2008
Posts: 13
Location: china

PostPosted: Wed Feb 11, 2009 11:37 pm
Reply with quote

I think you want to the current version of my system, right?

this is part of message:

BLOCKSET TECHNIQUE IN CONTROL
RECORD TYPE IS F - DATA STARTS IN POSITION 1
C5-K26318 C6-K90007 C7-K90000 C8-K23476 E9-K90007 C9-BASE E5-K31980
BLOCKSET COPY TECHNIQUE SELECTED
VISIT www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES A
- CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 13:05 ON WED FE
OPTION 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: Thu Feb 12, 2009 12:18 am
Reply with quote

I believe this DFSORT/ICETOOL job will work with your level of DFSORT:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD *
AAABBB 111   1     A1
AAABBB 222 0       A2
AAABBB 333     1   A3
AAABBB 444     1   A4
CCCDDD 555 1       A5
EEEFFF 666   1     A6
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
SPLICE FROM(IN) TO(T1) ON(1,6,CH) KEEPNODUPS -
  WITHEACH WITH(14,1) WITH(16,1) USING(CTL1)
COPY FROM(IN) TO(T1)
SPLICE FROM(T1) TO(OUT) ON(1,6,CH) WITHALL -
  WITH(1,11) WITH(17,64)
/*
//CTL1CNTL DD *
  SORT FIELDS=(1,6,CH,A,12,1,CH,D,14,1,CH,D,16,1,CH,D)
/*
Back to top
View user's profile Send private message
liangl

New User


Joined: 23 Mar 2008
Posts: 13
Location: china

PostPosted: Thu Feb 12, 2009 12:47 am
Reply with quote

wo, it really works, thank you so much
Back to top
View user's profile Send private message
liangl

New User


Joined: 23 Mar 2008
Posts: 13
Location: china

PostPosted: Thu Feb 12, 2009 1:04 am
Reply with quote

one more question:

if I change input second line from AAABBB 222 0 A2 to AAABBB 222 A2, which means replace '0' as blank, then this JCL doesn't work, can you tell me why?
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: Thu Feb 12, 2009 1:54 am
Reply with quote

With the WITHANY solution, the output would be:

Code:

AAABBB 111   1 1   A1     
AAABBB 222   1 1   A2     
AAABBB 333   1 1   A3     
AAABBB 444   1 1   A4     
CCCDDD 555 1       A5     
EEEFFF 666   1     A6     


With the WITHEACH solution, the output would be:

Code:

AAABBB 111     1   A1     
AAABBB 222     1   A2     
AAABBB 333     1   A3     
AAABBB 444     1   A4     
CCCDDD 555 1       A5     
EEEFFF 666   1     A6     


WITHANY takes the values in 12, 14 and 16 no matter where they are in any of the duplicate records so it does what you want.

WITHEACH takes the value in 14 from the second duplicate record and the value in 16 from the third duplicate record. With a blank in 14 of every duplicate, you get a blank for the second value. We would have to do more coding to ensure that if 14 has all blanks, 16 is the second record.

WITHANY is much better for this kind of thing (that's why I added it to DFSORT). Ask your System Programmer to install z/OS DFSORT V1R5 PTF UK90013 (July, 2008) so you can use WITHANY. The PTF is free.
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 Sort counter to show records combination JCL & VSAM 2
No new posts how to show listing in physical locat... PL/I & Assembler 2
This topic is locked: you cannot edit posts or make replies. how to show the class of an ims trans... CLIST & REXX 11
No new posts Joinkeys with duplicated keys SYNCSORT 19
No new posts How to show message using batch jobs TSO/ISPF 7
Search our Forums:

Back to Top