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 

Spliting a file like a COBOL OCCURS way

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


Joined: 30 Apr 2006
Posts: 15
Topics: 4
Location: Paris - France

PostPosted: Mon Jul 21, 2008 3:06 pm    Post subject: Spliting a file like a COBOL OCCURS way Reply with quote

Bonjour de Paris ...

I want to split a file as folows :

Input file (in fact like a COBOL OCCURS file) :
Code:
AA000100020003
BB000400050006


Output file :
Code:
AA0001
AA0002
AA0003
BB0004
BB0005
BB0005


So, I tried this with the SORT utility :

Code:
//SORT EXEC=SORT
//SYSOUT DD SYSOUT=*
//SYSIN DD *
 OPTION COPY
 OUTFIL FNAMES=DD1,OUTREC=(1,2,3,4)
 OUTFIL FNAMES=DD2,OUTREC=(1,2,7,4)
 OUTFIL FNAMES=DD3,OUTREC=(1,2,11,4)
//SORTIN DD *
AA000100020003
BB000400050006
//DD1 DD ...
//DD2 DD ...
//DD3 DD ...


But, with this solution, I have 3 output files instead having only 1.
Of course, I can have a step after to merge the 3 files.

So, in your opinion, is it possible to have only one file as ouput file ?

Thank's in advance ...
_________________
I hope my english is not too bad. But it's not my mother tongue.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Jul 21, 2008 3:45 pm    Post subject: Reply with quote

You seem not to be aware of the / (new line) function of DFSORT's OUTFIL. You can do what you want using a DFSORT job like this:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
AA000100020003
BB000400050006
/*
//SORTOUT DD ...
//SYSIN    DD    *
  OPTION COPY
  OUTFIL BUILD=(1,2,3,4,/,
    1,2,7,4,/,
    1,2,11,4)
/*


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/servers/storage/support/software/sort/mvs/srtmpub.html
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Luc Orient
Beginner


Joined: 30 Apr 2006
Posts: 15
Topics: 4
Location: Paris - France

PostPosted: Mon Jul 21, 2008 4:34 pm    Post subject: Reply with quote

OK ... merci beaucoup ...

Il will try tomorow when I shall return to my office ... It's the night now in France ...
_________________
I hope my english is not too bad. But it's not my mother tongue.
Back to top
View user's profile Send private message
Luc Orient
Beginner


Joined: 30 Apr 2006
Posts: 15
Topics: 4
Location: Paris - France

PostPosted: Sun Jul 27, 2008 3:09 pm    Post subject: Reply with quote

Well ... It's still me and I have a complementary question about my example ...

I want to eliminate the records with a zero value. I am talking about records after the reformat process.

For instance :
Code:
AA0000

_________________
I hope my english is not too bad. But it's not my mother tongue.
Back to top
View user's profile Send private message
Luc Orient
Beginner


Joined: 30 Apr 2006
Posts: 15
Topics: 4
Location: Paris - France

PostPosted: Sun Jul 27, 2008 3:12 pm    Post subject: Reply with quote

... folowing :

Is it possible or should I use another step with a OMIT statement ?
_________________
I hope my english is not too bad. But it's not my mother tongue.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Jul 28, 2008 10:44 am    Post subject: Reply with quote

Well, it would be easier to use a second pass with an OMIT statement, but you could do it in one pass with a DFSORT job like this:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=...  output file (FB/6)
//SYSIN    DD    *
  OPTION COPY
  OMIT COND=(3,12,CH,EQ,C'000000000000')
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(16:3C'0')),
        IFTHEN=(WHEN=(3,4,CH,NE,C'0000'),
         OVERLAY=(16:C'1'),HIT=NEXT),
        IFTHEN=(WHEN=(7,4,CH,NE,C'0000'),
         OVERLAY=(17:C'1'),HIT=NEXT),
        IFTHEN=(WHEN=(11,4,CH,NE,C'0000'),
         OVERLAY=(18:C'1'))
  OUTFIL IFOUTLEN=6,
    IFTHEN=(WHEN=(16,3,CH,EQ,C'111'),
      BUILD=(1,2,3,4,/,1,2,7,4,/,1,2,11,4)),
    IFTHEN=(WHEN=(16,3,CH,EQ,C'110'),
      BUILD=(1,2,3,4,/,1,2,7,4)),
    IFTHEN=(WHEN=(16,3,CH,EQ,C'101'),
      BUILD=(1,2,3,4,/,1,2,11,4)),
    IFTHEN=(WHEN=(16,3,CH,EQ,C'100'),
      BUILD=(1,2,3,4)),
    IFTHEN=(WHEN=(16,3,CH,EQ,C'011'),
      BUILD=(1,2,7,4,/,1,2,11,4)),
    IFTHEN=(WHEN=(16,3,CH,EQ,C'010'),
      BUILD=(1,2,7,4)),
    IFTHEN=(WHEN=(16,3,CH,EQ,C'001'),
      BUILD=(1,2,11,4))
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Luc Orient
Beginner


Joined: 30 Apr 2006
Posts: 15
Topics: 4
Location: Paris - France

PostPosted: Mon Jul 28, 2008 1:37 pm    Post subject: Reply with quote

OK ... Thank's a lot ...

I will use a second pass with an OMIT statement ...

Merci beaucoup pour vos r
_________________
I hope my english is not too bad. But it's not my mother tongue.
Back to top
View user's profile Send private message
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