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
 

 

Sort to combine multiple rows

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sort to combine multiple rows
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    Post subject: Re: Sort to combine multiple rows
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    Post subject: sort
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: 3158
Location: Tucson AZ

PostPosted: Wed Jan 10, 2007 7:42 pm    Post subject: Re: sort
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    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jan 10, 2007 10:12 pm    Post subject:
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:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/

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    Post subject: Re: Sort to combine multiple rows
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jan 11, 2007 9:33 pm    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat Nov 13, 2010 5:30 am    Post subject:
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:

http://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    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 Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts compare 2 rows within the same file ram_vizag SYNCSORT 7 Wed Jun 14, 2017 12:34 am


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