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

Sort to combine multiple rows


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

New User


Joined: 09 Oct 2006
Posts: 31
Location: Bangalore

PostPosted: Wed Jan 10, 2007 2:51 pm
Reply with quote

Hi

I have a INPUT file which is having below record (always it has 3 row and max charater 7)

INPUT
-------
123
12345
1234567

Using sort card I need to have a output file like below

123 12345 1234567

Please help me, how can I get this using the sort

Thanks
Arun
Back to top
View user's profile Send private message
subhasis_50

Moderator


Joined: 09 Mar 2005
Posts: 363
Location: Earth

PostPosted: Wed Jan 10, 2007 5:38 pm
Reply with quote

Hi,

I assume that your input datset is with record length 80.

Here is the Solution you asked for

Code:

//STEP0100 EXEC PGM=ICETOOL                             
//*                                                     
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD *                                         
123                                                     
12345                                                   
1234567                                                 
/*                                                       
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T3       DD DSN=&T3,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON      DD DSN=&T1,DISP=OLD,VOL=REF=*.T1             
//         DD DSN=&T2,DISP=OLD,VOL=REF=*.T2             
//         DD DSN=&T3,DISP=OLD,VOL=REF=*.T3             
//OUT      DD SYSOUT=*                                   
//TOOLIN   DD *                                         
  COPY FROM(IN)  USING(CTL1)                                 
  SPLICE FROM(CON) TO(OUT) ON(81,8,ZD) KEEPNODUPS  WITHEACH -
  WITH(4,5) WITH(9,7) USING(CTL2)                             
/*                                                           
//CTL1CNTL DD *                                               
  OUTFIL FNAMES=T1,STARTREC=1,SAMPLE=(3,1),                   
  OUTREC=(1,3,77X,81:SEQNUM,8,ZD)                             
  OUTFIL FNAMES=T2,STARTREC=2,SAMPLE=(3,1),                   
  OUTREC=(3X,4:1,5,72X,81:SEQNUM,8,ZD)                       
  OUTFIL FNAMES=T3,STARTREC=3,SAMPLE=(3,1),                   
  OUTREC=(8X,9:1,7,65X,81:SEQNUM,8,ZD)                       
//CTL2CNTL DD *                                               
  OUTFIL FNAMES=OUT,OUTREC=(1,3,X,4,5,X,9,7,80:X)             
/*             


Hope it helps!
Back to top
View user's profile Send private message
lal_arun_272

New User


Joined: 09 Oct 2006
Posts: 31
Location: Bangalore

PostPosted: Wed Jan 10, 2007 7:27 pm
Reply with quote

Thanks subhasis

My inupt file consits of 3 records earch with one field of 5 chars lenght. Each record is of lengh 80.

Just for example i gave the records as
1
123
12345

but it can have any values in these three records.


Regards,
Arun
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jan 10, 2007 7:42 pm
Reply with quote

lal_arun_272 wrote:
My inupt file consits of 3 records earch with one field of 5 chars lenght. Each record is of lengh 80.

Just for example i gave the records as
1
123
12345

but it can have any values in these three records.subhasis
Was subhasis's solution successful?
Back to top
View user's profile Send private message
lal_arun_272

New User


Joined: 09 Oct 2006
Posts: 31
Location: Bangalore

PostPosted: Wed Jan 10, 2007 7:52 pm
Reply with quote

Yes its working fine.

i give the directly the dataset name also its working fine, thanks a lot Subhasis.

Regards,
Arun
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 Jan 10, 2007 10:12 pm
Reply with quote

There are several problems with Subhasis's solution:
1) It assumes that the first record has 3 characters, the second record has 5 characters and the third record has 7 characters. This is obviously not the case given Arun's second example. It won't work correctly for other cases. For example, if the input was:

Code:

1234567
ABCD   
E         


The output would be:

Code:

123 ABCD  E


Note that characters have been truncated.

2) It doesn't put just one space between each field which is what I believe Arun wants. Note that there are two spaces between D and E in the example above.

3) It uses referback in concatenation which can cause problems due to a system restriction.

Here's a better, simpler and more efficient DFSORT job that will handle 1 to 7 characters in any record and only put one space between the resulting fields. You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's SQZ and INREC with SPLICE functions. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

Use [URL] BBCode for External Links

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN       DD DSN=...  input file (FB/7)
//OUT      DD DSN=...  output file (FB/23)
//TOOLIN   DD *
SPLICE FROM(IN) TO(OUT) ON(8,1,CH) -
  WITHEACH WITH(9,7) WITH(17,7) USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFOUTLEN=23,
    IFTHEN=(WHEN=INIT,OVERLAY=(24:SEQNUM,1,ZD)),
    IFTHEN=(WHEN=(24,1,ZD,EQ,+2),BUILD=(9:1,7)),
    IFTHEN=(WHEN=(24,1,ZD,EQ,+3),BUILD=(17:1,7))
  OUTFIL FNAMES=OUT,BUILD=(1,23,SQZ=(SHIFT=LEFT,MID=C' '))
/*
Back to top
View user's profile Send private message
lal_arun_272

New User


Joined: 09 Oct 2006
Posts: 31
Location: Bangalore

PostPosted: Thu Jan 11, 2007 6:52 am
Reply with quote

Hi,

i want to pass a file name as perameter to this sort, which should come as first field in the out put .

How can i do that.

example:

input:

123
12345
123456

output:
filename 123 12345 123456

Thanks,
Arun.







[/b]
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 Jan 11, 2007 9:33 pm
Reply with quote

You can pass the filename as a DFSORT Symbol like this (put the filename between the apostrophes for the name symbol):

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//SYMNAMES DD *
name,'filename'
/*
//IN       DD DSN=...  input file (FB/7)
//OUT      DD DSN=...  output file (FB/32)
//TOOLIN   DD *
SPLICE FROM(IN) TO(OUT) ON(8,1,CH) -
  WITHEACH WITH(9,7) WITH(17,7) USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFOUTLEN=23,
    IFTHEN=(WHEN=INIT,OVERLAY=(24:SEQNUM,1,ZD)),
    IFTHEN=(WHEN=(24,1,ZD,EQ,+2),BUILD=(9:1,7)),
    IFTHEN=(WHEN=(24,1,ZD,EQ,+3),BUILD=(17:1,7))
  OUTFIL FNAMES=OUT,BUILD=(name,X,
      1,23,SQZ=(SHIFT=LEFT,MID=C' '))
/*
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: Sat Nov 13, 2010 5:30 am
Reply with quote

With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct,2010), you can now use the new RESIZE operator of DFSORT's ICETOOL to do this more easily like this:

Code:

//NEW EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//SYMNAMES DD *
name,'filename'
/*
//IN       DD DSN=...  input file (FB/7)
//OUT      DD DSN=...  output file (FB/32)
//TOOLIN   DD *
RESIZE FROM(IN) TO(OUT) TOLEN(24) USING(CTL1)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(8:X)
  OUTFIL FNAMES=OUT,BUILD=(name,X,
    1,24,SQZ=(SHIFT=LEFT,MID=C' ',LENGTH=23))
/*


For complete details on the new functions for DFSORT and DFSORT's ICETOOL available with the Oct, 2010 PTF, see:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top