MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Flat file from a comma delimited file.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
batu544
Beginner


Joined: 02 Aug 2005
Posts: 75
Topics: 27

PostPosted: Thu Feb 18, 2010 7:11 am    Post subject: Flat file from a comma delimited file. Reply with quote

Hi,
I have a small requirement to convert the one input comma delimited by to a flat file so that the file can be used in other programs.

Here is input record layout
Code:

12345678,1,batu,10/12/2009,,,,,
28282828,5,xxxx,10/12/2009,,,,
83782823,200,yyyy,04/02/2010,,,,


and my output file will be like..

Code:

1234567800001batu 10/12/2009
2828282800005xxxxx10/12/2009
8378282300200yyyy 04/02/2010


Please note the 2nd fields are numeric fields so, the in output file it needs to be converted to a 5 digit field ( e.g. 00001) and other will be some fixed length ( e.g in 'batu ' 1 blank spaces added ).


This can be done by a COBOL program.. but I think it can be done in a simple way by using Syncsort..

Is it possible by using SYNCSORT ?


Thanks
_________________
Regards,
batu
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Brian Wood
Beginner


Joined: 14 Jan 2009
Posts: 37
Topics: 0
Location: USA

PostPosted: Thu Feb 18, 2010 11:10 am    Post subject: Reply with quote

batu544:
I used the following SyncSort control statements:
Code:

//STEP01 EXEC PGM=SORT
//SORTOUT  DD  SYSOUT=*                                                 
//SORTIN   DD *                                                         
12345678,1,BATU,10/12/2009,,,,,                                         
28282828,5,XXXX,10/12/2009,,,,                                         
83782823,200,YYYY,04/02/2010,,,,                                       
/*                                                                     
//SYSOUT DD SYSOUT=*                                                   
//SYSIN  DD *                                                           
  SORT FIELDS=COPY                                                     
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=08),                           
               %02=(ENDBEFR=C',',FIXLEN=05),                           
               %03=(ENDBEFR=C',',FIXLEN=05),                           
               %04=(ENDBEFR=C',',FIXLEN=10)),                           
        BUILD=(01:%01,                                                 
               09:%02,JFY=(SHIFT=RIGHT,LEAD=X'F0F0F0F0F0',             
                           LENGTH=05),                                 
               14:%03,19:%04)                                           

To produce the following results:
Code:

1234567800001BATU 10/12/2009
2828282800005XXXX 10/12/2009
8378282300200YYYY 04/02/2010

Hope this helps!
_________________
Brian Wood
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
batu544
Beginner


Joined: 02 Aug 2005
Posts: 75
Topics: 27

PostPosted: Fri Feb 19, 2010 12:32 am    Post subject: Reply with quote

Brian Wood,
Thanks for your help.. but I am using a very old syncsort product ( v3.7ER TPF4 ) and its not supporting PARSE keyword.. Sad

Is there any other way ??
_________________
Regards,
batu
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Brian Wood
Beginner


Joined: 14 Jan 2009
Posts: 37
Topics: 0
Location: USA

PostPosted: Fri Feb 19, 2010 9:12 am    Post subject: Reply with quote

PARSE is not supported in a product as old as SyncSort MVS 3.7 (TPF4). There is no mechanism in SyncSort MVS 3.7 (TPF4) to accompish what you ask.
_________________
Brian Wood
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Fri Feb 19, 2010 11:29 am    Post subject: Reply with quote

Failing that, this should be a very straightforward Rexx exec (alloc files, loop with read, parse, reformat write, then free everything). Shouldn't be more than 20 lines or so. If your data is real CSV format though, you also have to account for items that are in quotes in case any fields contain commas. That would add a few lines as a loop since Parse alone will not do that.
_________________
New members are encouraged to read the How To Ask Questions The Smart Way FAQ at http://www.catb.org/~esr/faqs/smart-questions.html.
Back to top
View user's profile Send private message Visit poster's website
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Fri Feb 19, 2010 3:07 pm    Post subject: Reply with quote

How many records are in the file?

If the volume is high, rexx would not be a good choice (unless this is a one-time shot).
_________________
All the best,

di
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Fri Feb 19, 2010 9:26 pm    Post subject: Reply with quote

Its less a question of how big the file is than how often this needs to be done if there are many records. Even if you have a couple million records, this relatively trivial process will finish in a few tens of seconds to a few minutes, but if this runs often, that can be unacceptable.
_________________
New members are encouraged to read the How To Ask Questions The Smart Way FAQ at http://www.catb.org/~esr/faqs/smart-questions.html.
Back to top
View user's profile Send private message Visit poster's website
batu544
Beginner


Joined: 02 Aug 2005
Posts: 75
Topics: 27

PostPosted: Wed Feb 24, 2010 12:44 pm    Post subject: Reply with quote

HI All,
Thanks for all your comments.. I just mixed this formatting part in my COBOL program by using UNSTRING.. ( For the time being I felt its easier for me )..

Thanks
batu544
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group