MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

merge alphanum fields

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
peterblaak
Beginner


Joined: 29 Mar 2005
Posts: 4
Topics: 1

PostPosted: Tue Mar 29, 2005 6:55 am    Post subject: merge alphanum fields Reply with quote

Hi all,

I have a file and want to merge records based on their keyfield and find specific data in some fields (if a B exists, take B else A)

input:
KEYFIELD DATAFIELD
11111111 A A
11111111 B A
22222222 A B
33333333 A A
33333333 A A

required output:
11111111 B A
22222222 A B
33333333 A A


I have done this using numeric field, but this time I want to try it using alphanumeric fields
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Mar 29, 2005 9:50 am    Post subject: Reply with quote

peterblaak,

Try this

Code:

//STEP0100 EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD *                                           
11111111 A A                                             
11111111 B A                                             
22222222 A B                                             
33333333 A A                                             
33333333 A A                                             
//OUT      DD SYSOUT=*                                   
//TOOLIN   DD *                                           
  SELECT FROM(IN) TO(OUT) ON(1,8,CH) USING(CTL1) FIRST   
//CTL1CNTL DD *                                           
  SORT FIELDS=(01,8,CH,A,                                 
               10,1,CH,D)                                 
/*                                                       


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
peterblaak
Beginner


Joined: 29 Mar 2005
Posts: 4
Topics: 1

PostPosted: Wed Mar 30, 2005 2:31 am    Post subject: almost Reply with quote

Hi

it works with the sample i gave you but I forgot to say there's more than 2 fields with A's or B's, so the correct input is:

Code:

KEYFIELD DATAFIELDS
11111111 A A A A
11111111 B A A A
11111111 A B A A
22222222 A B A A
33333333 A A A A
33333333 A A A A
33333333 A A B A
44444444 A A A B

required output:
11111111 B B A A
22222222 A B A A
33333333 A A B A
44444444 A A A B
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Mar 30, 2005 9:03 am    Post subject: Reply with quote

peterblaak,

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.

You just posted a sample input and desired output without any describing the criteria to pick the records.

Based on your sample input and output, I am assuming that your datafields can only have an "a" or "b". I am assuming that your input is of FB recfm and has an lrecl of 80.

try this job.

Code:

//STEP0100 EXEC PGM=SORT         
//SYSOUT   DD SYSOUT=*           
//SORTIN   DD *                 
11111111 A A A A                 
11111111 B A A A                 
11111111 A B A A                 
22222222 A B A A                 
33333333 A A A A                 
33333333 A A A A                 
33333333 A A B A                 
44444444 A A A B                 
//SORTOUT  DD SYSOUT=*           
//SYSIN    DD *                 
  INREC FIELDS=(01,9,                                       
                10,1,CHANGE=(1,C'A',C'0',                 
                               C'B',C'1'),NOMATCH=(C'0'), 
                11,1,                                     
                12,1,CHANGE=(1,C'A',C'0',                 
                               C'B',C'1'),NOMATCH=(C'0'), 
                13,1,                                     
                14,1,CHANGE=(1,C'A',C'0',                 
                               C'B',C'1'),NOMATCH=(C'0'), 
                15,1,                                     
                16,1,CHANGE=(1,C'A',C'0',                 
                               C'B',C'1'),NOMATCH=(C'0'), 
                17,64)                                     
  SORT FIELDS=(1,8,CH,A)                                   
  SUM FIELDS=(10,1,12,1,14,1,16,1),FORMAT=ZD               
  OUTREC FIELDS=(01,9,                                     
                 10,1,CHANGE=(1,C'0',C'A'),NOMATCH=(C'B'), 
                 11,1,                                     
                 12,1,CHANGE=(1,C'0',C'A'),NOMATCH=(C'B'), 
                 13,1,                                     
                 14,1,CHANGE=(1,C'0',C'A'),NOMATCH=(C'B'), 
                 15,1,                                     
                 16,1,CHANGE=(1,C'0',C'A'),NOMATCH=(C'B'), 
                 17,64)                                     
/*


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Mar 30, 2005 11:47 am    Post subject: Reply with quote

peterblaak,

If you have z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004), you can use DFSORT's new IFTHEN and OVERLAY parameters to do what you want as shown below. Since you show your records as already in order, I used MERGE and SORTIN01 (a merge is faster than a sort). If your records are not actually in order, use SORT and SORTIN instead. Note: I added a couple of data points with a B in the same column in both records to make it more interesting.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN01 DD *
11111111 A A A A
11111111 B A A A
11111111 A B A A
11111111 B B A A
22222222 A B A A
33333333 A A A A
33333333 A A A A
33333333 A A B A
33333333 A A B A
44444444 A A A B
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
* Init. 81-84 to '0000'.  Replace '0' with '1' for each 'B'.
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'0000')),
    IFTHEN=(WHEN=(10,1,CH,EQ,C'B'),OVERLAY=(81:C'1'),HIT=NEXT),
    IFTHEN=(WHEN=(12,1,CH,EQ,C'B'),OVERLAY=(82:C'1'),HIT=NEXT),
    IFTHEN=(WHEN=(14,1,CH,EQ,C'B'),OVERLAY=(83:C'1'),HIT=NEXT),
    IFTHEN=(WHEN=(16,1,CH,EQ,C'B'),OVERLAY=(84:C'1'))
  MERGE FIELDS=(1,8,CH,A)
  OPTION ZDPRINT
* Sum 81-84.  Sum for each column will be '0' if only 'A's, or
* >0 if any 'B's.
  SUM FIELDS=(81,4,ZD)
* Init. 10-16 to 'B B B B'.  Replace 'B' with 'A' for each '0'.
* Remove 81-84.
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(10:C'B B B B')),
    IFTHEN=(WHEN=(81,1,CH,EQ,C'0'),OVERLAY=(10:C'A'),HIT=NEXT),
    IFTHEN=(WHEN=(82,1,CH,EQ,C'0'),OVERLAY=(12:C'A'),HIT=NEXT),
    IFTHEN=(WHEN=(83,1,CH,EQ,C'0'),OVERLAY=(14:C'A'),HIT=NEXT),
    IFTHEN=(WHEN=(84,1,CH,EQ,C'0'),OVERLAY=(16:C'A')),
    IFOUTLEN=80
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
peterblaak
Beginner


Joined: 29 Mar 2005
Posts: 4
Topics: 1

PostPosted: Thu Mar 31, 2005 12:06 am    Post subject: GREAT Reply with quote

GREAT!

I will try both and let you know!
Back to top
View user's profile Send private message
peterblaak
Beginner


Joined: 29 Mar 2005
Posts: 4
Topics: 1

PostPosted: Thu Mar 31, 2005 7:24 am    Post subject: it works Reply with quote

Kolusu, Frank,

It works. I wasn't sure about the version we use, so I used Kolusu's job

Thanks again!!!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Mar 31, 2005 8:22 am    Post subject: Reply with quote

Quote:

. I wasn't sure about the version we use, so I used Kolusu's job

peterblaak,

You can look at the first line in your sysout to find the version of the sort product you are using.

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Mar 31, 2005 12:04 pm    Post subject: Reply with quote

Quote:
You can look at the first line in your sysout to find the version of the sort product you are using.


Kolusu,

I'm not sure if that's true for Syncsort in terms of their equivalent of PTFs (?), but it's not true for DFSORT.

For DFSORT, the ICE000I message (not the first line) tells you the release: 'Z/OS DFSORT V1R5' or 'REL 14.0'. But it doesn't tell you which PTFs are installed. Actually, PTFs only "hit" certain modules, so the current level of DFSORT will have a mix of PTFs for various modules.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group