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
 

 

Parsing a comma separated file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
sthirumalai

New User


Joined: 14 Aug 2007
Posts: 14
Location: Chennai

PostPosted: Wed Jul 20, 2011 8:38 pm    Post subject: Parsing a comma separated file
Reply with quote

Hi,

I have a comma separated flat file of length 100 Bytes FB.


Code:
1675356400,660474102,201004,IP,30,C,020,594320.00,30APR2010:00:00:00   
8143931500,6670187100,201006,FG,32,P,010,376161.00,04JUN2010:00:00:00 
1260272500,706768100,201105,FG,43,P,020,852888.00,11MAY2011:00:00:00   
1260272500,706768100,201102,FG,40,P,020,852888.00,28FEB2011:00:00:00   
1260272500,706768100,201105,FG,43,C,020,852888.00,26MAY2011:00:00:00   
1260272500,706768100,201102,FG,40,P,020,852888.00,24FEB2011:00:00:00   
1540449400,3183366100,200910,IP,24,C,020,2237554.00,03OCT2009:00:00:00
1540449400,3183366100,201101,IP,39,C,020,2237554.00,21JAN2011:00:00:00
1540449400,3183366100,201010,IP,36,C,020,2237554.00,19OCT2010:00:00:00
1540449400,3183366100,201007,IP,33,C,020,2237554.00,12JUL2010:00:00:00
1540449400,3183366100,201001,IP,27,C,020,2237554.00,19JAN2010:00:00:00
1540449400,3183366100,200904,IP,18,C,020,2237554.00,04APR2009:00:00:00
1540449400,3183366100,200903,FG,17,C,020,2237554.00,25MAR2009:00:00:00
1540449400,3183366100,200907,IP,21,C,020,2237554.00,18JUL2009:00:00:00
1540449400,3183366100,201004,IP,30,C,020,2237554.00,30APR2010:00:00:00
5482856400,7530474101,201008,FG,34,C,030,1260101.00,09AUG2010:00:00:00
5482856400,7530474101,201010,FG,36,C,030,1260101.00,04OCT2010:00:00:00
7614698000,2823064003,200602,FG,-20,C,030,1403717.00,13FEB2006:00:00:00

I have to parse the above file in the following layout.

01 REC1.
05 FIELD-1 PIC X(15).
05 FIELD-1-N REDEFINES FIELD-1 PIC 9(15).
05 FIELD2 PIC X(14).
05 FIELD3 PIC X(06).
05 FIELD4 PIC X(02).
05 FIELD5 PIC S9(02).
05 FIELD6 PIC X(01).
05 FIELD7 PIC X(03).
05 FIELD8 PIC S9(9)V9(2) COMP-3.
05 FIELD9 PIC X(20).
05 FILLER PIC X(81).

Is this possible using DFsort?

Thanks & Regards
Santhosh
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jul 20, 2011 9:33 pm    Post subject:
Reply with quote

This looks very straight forward using DFSORT, Please have look at DFSORT parse function.

If you are already trying, Where are you stuck?
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 Jul 20, 2011 11:26 pm    Post subject:
Reply with quote

Santhosh,

It's not completely clear from your description what you want the output records to look like. It would have helped if you'd shown the corresponding expected output for your input example. At any rate, you could use a DFSORT job something like this - adjust as needed to get the output you want.

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  OPTION COPY
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=15),
               %02=(ENDBEFR=C',',FIXLEN=14),
               %03=(ENDBEFR=C',',FIXLEN=6),
               %04=(ENDBEFR=C',',FIXLEN=2),
               %05=(ENDBEFR=C',',FIXLEN=3),
               %06=(ENDBEFR=C',',FIXLEN=1),
               %07=(ENDBEFR=C',',FIXLEN=3),
               %08=(ENDBEFR=C',',FIXLEN=12),
               %09=(FIXLEN=20)),
  BUILD=(%01,UFF,TO=ZD,LENGTH=15,
    %02,%03,%04,%05,%06,%07,
    %08,SFF,TO=PD,LENGTH=6,
    %09,81X)
/*


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
sthirumalai

New User


Joined: 14 Aug 2007
Posts: 14
Location: Chennai

PostPosted: Thu Jul 21, 2011 2:40 am    Post subject: Reply to: Parsing a comma separated file
Reply with quote

Hi Frank/Escapa,

Thanks for your help

I used the following sortcard to meet my requirement

Code:

SORT FIELDS=COPY                                   
OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=15),       
              %02=(ENDBEFR=C',',FIXLEN=14),       
              %03=(ENDBEFR=C',',FIXLEN=06),       
              %04=(ENDBEFR=C',',FIXLEN=02),       
              %05=(ENDBEFR=C',',FIXLEN=03),       
              %06=(ENDBEFR=C',',FIXLEN=01),       
              %07=(ENDBEFR=C',',FIXLEN=03),       
              %08=(ENDBEFR=C',',FIXLEN=13),       
              %09=(ENDBEFR=C',',FIXLEN=20)),       
   BUILD=(1:%01,16:%02,30:%03,36:%04,             
   38:%05,SFF,TO=FS,LENGTH=2,                     
   40:%06,41:%07,44:%08,SFF,TO=PD,LENGTH=6,50:%09,
   70:+0,TO=PD,LENGTH=5,76X)                       



The field5 which is a signed decimal, after conversion the sign is not present.

Rest of the fields were parsed perfectly.
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 Jul 21, 2011 2:54 am    Post subject:
Reply with quote

Quote:
The field5 which is a signed decimal, after conversion the sign is not present.


Because you only allowed 2 output characters for it by using LENGTH=2 instead of LENGTH=3. It should be:

Code:

38:%05,SFF,TO=FS,LENGTH=3, 


(I missed that it was 3 characters, not 2.)
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am
No new posts Occurrence of various strings within ... TS70363 JCL & VSAM 1 Thu Apr 27, 2017 8:18 pm


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