Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Multiple records into single column based on common field.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
rz061m

New User


Joined: 03 Mar 2006
Posts: 48
Location: Chennai

PostPosted: Wed Jan 28, 2009 9:59 am    Post subject: Multiple records into single column based on common field.
Reply with quote

Hi,

I have a requirement where i have multiple records with common field and i have to put selected fields into a single column. Please refer the example below.

INPUT FILES

FileA: Record length 80
00000A 000001 ....
00000B 000001 ....
00000C 000001 ....
00000D 000002 ....
00000E 000002 ....
00000F 000003 ....

FileB: Record length 80
Note:The number of occurence for a particular number in this file will be max upto 9.

000001 AAA ...
000001 BBB ....
000001 CCC ....
000002 DDD ....
000002 EEE ....
000003 FFF ....

OUTPUT FILE
00000A 000001 AAA BBB CCC
00000B 000001 AAA BBB CCC
00000C 000001 AAA BBB CCC
00000D 000002 DDD EEE
00000E 000002 DDD EEE
00000F 000003 FFF

If there is a match based on the numbers (000001/2/3...) then all the alphabets aganist that particular number has to come in a single row. The number of occurence for a particular number in FileB can be max upto 9.

Thanks,
Karthik. P
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Thu Jan 29, 2009 1:42 am    Post subject:
Reply with quote

rz061m,

I assumed that your occurances fileB are each 4 bytes and it starts from pos 7 in fileb.

The first step takes fileb and using when=group we club all the data into a single record using the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008). If you don't have the July, 2008 PTF installed, ask your System Programmer to install it (it's free).

For complete details on the new WHEN=GROUP and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/

The output of step0100 is as follows

Code:

       000001 AAA BBB CCC 
       000002 DDD EEE     
       000003 FFF         


The second step takes concatenates the above created to your file A and splices based on the key giving the desired results.

Code:

//STEP0100 EXEC PGM=ICEMAN                                             
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
000001 AAA ....                                                         
000001 BBB ....                                                         
000001 CCC ....                                                         
000002 DDD ....                                                         
000002 EEE ....                                                         
000003 FFF ....                                                         
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)             
//SYSIN    DD *                                                         
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,                                             
  OVERLAY=(1,6,101:1,10,SEQNUM,8,ZD,RESTART=(1,6))),                   
  IFTHEN=(WHEN=GROUP,BEGIN=(111,8,ZD,EQ,1),RECORDS=9,PUSH=(07:101,10)),
  IFTHEN=(WHEN=GROUP,BEGIN=(111,8,ZD,EQ,2),RECORDS=8,PUSH=(17:101,10)),
  IFTHEN=(WHEN=GROUP,BEGIN=(111,8,ZD,EQ,3),RECORDS=7,PUSH=(27:101,10)),
  IFTHEN=(WHEN=GROUP,BEGIN=(111,8,ZD,EQ,4),RECORDS=6,PUSH=(37:101,10)),
  IFTHEN=(WHEN=GROUP,BEGIN=(111,8,ZD,EQ,5),RECORDS=5,PUSH=(47:101,10)),
  IFTHEN=(WHEN=GROUP,BEGIN=(111,8,ZD,EQ,6),RECORDS=4,PUSH=(57:101,10)),
  IFTHEN=(WHEN=GROUP,BEGIN=(111,8,ZD,EQ,7),RECORDS=3,PUSH=(67:101,10)),
  IFTHEN=(WHEN=GROUP,BEGIN=(111,8,ZD,EQ,8),RECORDS=2,PUSH=(77:101,10)),
  IFTHEN=(WHEN=GROUP,BEGIN=(111,8,ZD,EQ,9),RECORDS=1,PUSH=(87:101,10)) 
                                                                       
  OUTREC IFTHEN=(WHEN=(17,6,CH,NE,1,6,CH),BUILD=(1,16,100:X)),         
  IFTHEN=(WHEN=(27,6,CH,NE,1,6,CH),BUILD=(1,26,100:X)),                 
  IFTHEN=(WHEN=(37,6,CH,NE,1,6,CH),BUILD=(1,36,100:X)),                 
  IFTHEN=(WHEN=(47,6,CH,NE,1,6,CH),BUILD=(1,46,100:X)),                 
  IFTHEN=(WHEN=(57,6,CH,NE,1,6,CH),BUILD=(1,56,100:X)),                 
  IFTHEN=(WHEN=(67,6,CH,NE,1,6,CH),BUILD=(1,66,100:X)),                 
  IFTHEN=(WHEN=(77,6,CH,NE,1,6,CH),BUILD=(1,76,100:X)),                 
  IFTHEN=(WHEN=(87,6,CH,NE,1,6,CH),BUILD=(1,86,100:X))                 
                                                                       
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                                 
  SECTIONS=(1,6,                                                       
  TRAILER3=(8:1,6,13,4,23,4,33,4,43,4,53,4,63,4,73,4,83,4,80:X))       
/*                                                                     
//STEP0200 EXEC PGM=ICETOOL                           
//DFSMSG   DD SYSOUT=*                               
//TOOLMSG  DD SYSOUT=*                               
//IN       DD DSN=&&T1,DISP=SHR                       
//         DD *                                       
00000A 000001 ....                                   
00000B 000001 ....                                   
00000C 000001 ....                                   
00000D 000002 ....                                   
00000E 000002 ....                                   
00000F 000003 ....                                   
//OUT      DD SYSOUT=*                               
//TOOLIN   DD *                                       
  SPLICE FROM(IN) TO(OUT) ON(8,6,CH) WITH(1,7) WITHALL
/*   
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us