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
 

 

comma separate the records in a file using DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: comma separate the records in a file using DFSORT
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    Post subject:
Reply with quote

Refer this http://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: 578
Location: USA

PostPosted: Tue May 24, 2011 8:31 pm    Post subject:
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    Post subject: Reply to: comma separate the records in a file using DFSORT
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 Moderator


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

PostPosted: Tue May 24, 2011 11:32 pm    Post subject:
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    Post subject: Reply to: comma separate the records in a file using DFSORT
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    Post subject: Reply to: comma separate the records in a file using DFSORT
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    Post subject: Reply to: comma separate the records in a file using DFSORT
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 Moderator


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

PostPosted: Wed May 25, 2011 11:48 pm    Post subject:
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    Post subject: Reply to: comma separate the records in a file using DFSORT
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    Post subject:
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:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
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: Fri May 27, 2011 9:15 pm    Post subject:
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    Post subject: Reply to: comma separate the records in a file using DFSORT
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    Post subject: Reply to: comma separate the records in a file using DFSORT
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 Moderator


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

PostPosted: Tue May 31, 2011 11:06 pm    Post subject:
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: 578
Location: USA

PostPosted: Wed Jun 01, 2011 2:14 am    Post subject:
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    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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
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
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


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