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

comma separate the records in a file using DFSORT


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

New User


Joined: 24 May 2011
Posts: 8
Location: India

PostPosted: Tue May 24, 2011 5:31 pm
Reply with quote

My input file looks like -

:20:12345
:50:
abc
cde
efg
:20:5678912345
:50:
zaq
xswcde
vfrbgtnhy

using dfsort or icetool i would like to have the output file as

12345,abc,cde,efg
5678912345,zaq,xswcde,vfrbgtnhy

Basically
1) the record starts with :20:---(values employee name)
2) the next record starts with :50: ---(values divided in 3 lines, this contains the address of employee in :20:)
3) the next again starts with :20:

the file is of lrec=80 and i want use dfsort to comma separate the values under :20: and :50: as employee,address

then the next record in output file as employee,address
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Tue May 24, 2011 5:52 pm
Reply with quote

Refer this ibmmainframes.com/viewtopic.php?t=54473

Similar to your problem
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue May 24, 2011 8:31 pm
Reply with quote

sandeep badal,

Will there be anything in the :50: line or Is it just an indicator for the address line? Will there be any other values than :20: and :50: probably to indicate other fields than employee name and address? What is the max. field size for Employee Name and Employee Address field?

Also, what is your DFSort PTF level?

Thanks,
Back to top
View user's profile Send private message
sandeep badal

New User


Joined: 24 May 2011
Posts: 8
Location: India

PostPosted: Tue May 24, 2011 10:49 pm
Reply with quote

:50: is just the indicator for address line...

The input file have

1) :20:( indicator to employee name can vary with length from 4 to max 20 char length
2) :50: ( indicator to address can very with length from 4 to 30 char ( inclusive of all spaces)
3) this address is split over 3 lines
ex :

:20: 12345678901234567890
:50:
SANDEEP BADAL
UNIT 10 2-4 4 AVEN
3RD CRSS
:20: 123456789
:50:
XYZ
4TH CROSS
ABCDEFG ZYXW
:20:

4) Each em,ployee name is followed by address
5) there will be no other values other than these 2 indicators only
6) LREC = 80,FB

OUTPUT file required as

12345678901234567890, SANDEEP BADAL, UNIT 10 2-4 4AVEN,3RD CRSS
123456789,XYZ,4TH CROSS,ABCDEFG ZYXW
..............

THE dfSORT USED is v 11.0

Any help is highly appreciated
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: Tue May 24, 2011 11:32 pm
Reply with quote

Quote:
THE dfSORT USED is v 11.0


That isn't the DFSORT level we need.

Run the following job and show the //SYSOUT messages here:

Code:

//S1    EXEC  PGM=SORT       
//SYSOUT    DD  SYSOUT=*     
//SORTIN DD *                 
RECORD                       
//SORTOUT DD DUMMY           
//SYSIN    DD    *           
    OPTION COPY               
/*                           
Back to top
View user's profile Send private message
sandeep badal

New User


Joined: 24 May 2011
Posts: 8
Location: India

PostPosted: Wed May 25, 2011 10:01 am
Reply with quote

Hi Frank,

The output of the JCL

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
RECORD
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
/*




1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R10 - 14:25 ON WED MAY 25, 20
OPTION COPY


Is this what you looking for?
Back to top
View user's profile Send private message
sandeep badal

New User


Joined: 24 May 2011
Posts: 8
Location: India

PostPosted: Wed May 25, 2011 10:06 am
Reply with quote

Hi Frank,

Just saw your sticky notes on the finding the ptf version

ICE201I G RECORD TYPE IS F
Back to top
View user's profile Send private message
sandeep badal

New User


Joined: 24 May 2011
Posts: 8
Location: India

PostPosted: Wed May 25, 2011 10:25 am
Reply with quote

Hi Frank,

Also to let you know we have installed the PTF UK90025 for z/OS DFSORT V1R10
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 May 25, 2011 11:48 pm
Reply with quote

Here's a DFSORT/ICETOOL job that will give you what I think you're asking for:

Code:
 
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(114,8,CH) WITHEACH -
  WITH(22,31) WITH(53,31) WITH(84,31) USING(CTL1)
/*
//CTL1CNTL DD *
  OMIT COND=(1,3,CH,EQ,C':50')
  INREC IFTHEN=(WHEN=GROUP,RECORDS=4,PUSH=(114:ID=8,122:SEQ=1)),
   IFTHEN=(WHEN=(122,1,ZD,EQ,1),
     BUILD=(6,20,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=21),
        114:114,8)),
   IFTHEN=(WHEN=(122,1,ZD,EQ,2),
     BUILD=(22:1,30,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=31),
        114:114,8)),
   IFTHEN=(WHEN=(122,1,ZD,EQ,3),
     BUILD=(53:1,30,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=21),
        114:114,8)),
    IFTHEN=(WHEN=(122,1,ZD,EQ,4),BUILD=(84:1,30,114:114,8))
  OUTFIL FNAMES=OUT,
    BUILD=(1,113,SQZ=(SHIFT=LEFT,MID=C' ',LENGTH=80))
/*


For your example input file, the output would be:

Code:

12345678901234567890,SANDEEP BADAL, UNIT 10 2-4 4 AVEN, 3RD CRSS 
123456789, XYZ, 4TH CROSS, ABCDEFG ZYXW                           


If that's not what you want for output, then please be more specific about what exactly you do want.
Back to top
View user's profile Send private message
sandeep badal

New User


Joined: 24 May 2011
Posts: 8
Location: India

PostPosted: Thu May 26, 2011 10:47 am
Reply with quote

WOW....Thanks much Frank...This is exactly the way i want it...

Could you please give an explanation on the steps taken in IF then clause
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu May 26, 2011 9:16 pm
Reply with quote

sandeep badal,

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
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: Fri May 27, 2011 9:15 pm
Reply with quote

Sandeep,

I'm glad to hear that's what you wanted.

I think you will learn a lot more about DFSORT if you figure out what the control statements do yourself using the references mentioned by Kolusu.

If you still can't figure it out, let me know and I'll go through it for you.
Back to top
View user's profile Send private message
sandeep badal

New User


Joined: 24 May 2011
Posts: 8
Location: India

PostPosted: Tue May 31, 2011 10:05 am
Reply with quote

Hi Frank,

Sorry to bother again...but i got fixed with the solution provided...the input file is not consistent in the example i gave

The input file have

1) :20:( indicator to employee name can vary with length from 4 to max 20 char length
2) :50: ( indicator to address can very with length from 4 to 30 char ( inclusive of all spaces)
3) this address is split over 3 lines and in some cases 4 lines of address

ex :

:20: 12345678901234567890
:50:
SANDEEP BADAL
UNIT 10 2-4 4 AVEN
3RD CRSS
:20: 123456789
:50:
XYZ
4TH CROSS
ABCDEFG ZYXW
8TH AVENUE ROAD
:20: 1234567
:50:
12XYZ
4TH CROSS
ABCDEFG ZYXW
:20:

4) Each em,ployee name is followed by address
5) there will be no other values other than these 2 indicators only
6) LREC = 80,FB


TAKING THIS RECORD AS EXAMPLE

:20: 123456789
:50:
XYZ
4TH CROSS
ABCDEFG ZYXW
8TH AVENUE ROAD

All the above records having 3 lines of address worked fine but when we have a 4th line it gets truncated when we group records = 4 ...this gets selected and populated as a new record in the next line causing the mess for the rest of the records

INREC IFTHEN=(WHEN=GROUP,RECORDS=4,PUSH=(114:ID=8,122:SEQ=1))

Is there a way we can format based on the tags ...

that is :20: indicates name
:50: indicates address

read the records till the next tag:20: is encountered and then treat it as a new line

OUTPUT file required as

12345678901234567890, SANDEEP BADAL, UNIT 10 2-4 4AVEN,3RD CRSS
123456789,XYZ,4TH CROSS,ABCDEFG ZYXW
123456789,XYZ ,4TH CROSS ,ABCDEFG ZYXW ,8TH AVENUE ROAD
Back to top
View user's profile Send private message
sandeep badal

New User


Joined: 24 May 2011
Posts: 8
Location: India

PostPosted: Tue May 31, 2011 5:29 pm
Reply with quote

Hi Frank,

i was to figure a solution for it

step 1 ) i introduced a dummy tag :70 at the end of each address

then used the begin and end condition to group the records

step 2)

//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(165,8,CH) WITHEACH -
WITH(22,36) WITH(58,36) WITH(94,36) WITH(130,36) USING(CTL1)
//CTL1CNTL DD *
OMIT COND=(1,3,CH,EQ,C':59',OR,1,3,CH,EQ,C':70')
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C':21'),
END=(1,3,CH,EQ,C':70'),PUSH=(165:ID=8,122:SEQ=1)),
IFTHEN=(WHEN=(122,1,ZD,EQ,1),
BUILD=(5,20,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=21),
165:165,8)),
IFTHEN=(WHEN=(122,1,ZD,EQ,2),
BUILD=(22:1,35,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=36),
165:165,8)),
IFTHEN=(WHEN=(122,1,ZD,EQ,3),
BUILD=(58:1,35,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=36),
165:165,8)),
IFTHEN=(WHEN=(122,1,ZD,EQ,4),
BUILD=(94:1,35,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=36),
165:165,8)),
IFTHEN=(WHEN=(122,1,ZD,EQ,5),BUILD=(130:1,35,165:165,8))
OUTFIL FNAMES=OUT,
BUILD=(1,164,SQZ=(SHIFT=LEFT,MID=C' ',LENGTH=180))
/*
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: Tue May 31, 2011 11:06 pm
Reply with quote

Garbage in, garbage out. You said each address was 3 lines so I gave you a solution based on that.

If you can have groups with varying number of lines, that requires a different solution.

Note that your solution is more complicated than it needs to be. You don't have to add a dummy :70 tag or use END. You can just use BEGIN for :20 to group the records.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Wed Jun 01, 2011 2:14 am
Reply with quote

sandeep badal,
You don't need to create dummy record but rather use :20: to mark beginning of a group of lines representing "Address". Because now you have variable address lines(2 or 3 or 4 lines per address),you need to code for maximum address lines. Below solution assumes you could have max. of 4 lines per address. However, you can change it accordingly to handle more lines. I have also increased final LRECL to be 100 bytes.

Frank had almost given you everything to handle this situation. See if below works...
Code:

//TOOLIN   DD  *                                                       
 SPLICE FROM(IN) TO(OUT) ON(146,8,CH) WITHEACH -                       
   WITH(22,31) WITH(53,31) WITH(84,31) WITH(115,30) USING(CTL1)         
/*                                                                     
//CTL1CNTL DD *                                                         
 OMIT COND=(1,3,CH,EQ,C':50')                                           
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(154:X)),                           
         IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C':20:'),                 
                 PUSH=(146:ID=8,154:SEQ=1)),                           
         IFTHEN=(WHEN=(154,1,ZD,EQ,1),                                 
                BUILD=(6,20,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=21),     
                       146:146,8)),                                     
         IFTHEN=(WHEN=(154,1,ZD,EQ,2),                                 
                BUILD=(22:1,30,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=31),   
                       146:146,8)),                                     
         IFTHEN=(WHEN=(154,1,ZD,EQ,3),                                 
                BUILD=(53:1,30,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=31),   
                       146:146,8)),                                     
         IFTHEN=(WHEN=(154,1,ZD,EQ,4),                                 
                BUILD=(84:1,30,JFY=(SHIFT=LEFT,TRAIL=C',',LENGTH=31),   
                       146:146,8)),                                     
         IFTHEN=(WHEN=(154,1,ZD,EQ,5),                                 
                BUILD=(115:1,30,146:146,8))                             
   OUTFIL FNAMES=OUT,                                                   
     BUILD=(1,145,SQZ=(SHIFT=LEFT,MID=C' ',LENGTH=100))                 
/*                                                                                                       

OUTPUT
Code:

12345678901234567890,SANDEEP BADAL, UNIT 10 2-4 4 AVEN, 3RD CRSS,
123456789, XYZ, 4TH CROSS, ABCDEFG ZYXW, 8TH AVENUE ROAD         
1234567, 12XYZ, 4TH CROSS, ABCDEFG ZYXW,                         


Apparently looks like we need RESIZE with ON fields. icon_smile.gif

Thanks,
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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 4
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top