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

Multiple records into single column based on common field.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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:

Use [URL] BBCode for External Links

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 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 Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts How to load to DB2 with column level ... DB2 6
Search our Forums:

Back to Top