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

Hoe to divide a file into 4 files based on some condition


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

New User


Joined: 17 May 2007
Posts: 24
Location: India

PostPosted: Tue Jul 03, 2007 9:25 pm
Reply with quote

Hi all,
My requirement is like

Input file

********first-type**********
aaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaa

********Second-type*******
bbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbb
********Third-type**********
cccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccc
********End of Input file****



Outfile1-
aaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaa

Outfile2 -
bbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbb

Outfile3 -
cccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccc



Is it possible to do . can somebody help me with this
Back to top
View user's profile Send private message
teethu thomas

New User


Joined: 17 May 2007
Posts: 24
Location: India

PostPosted: Tue Jul 03, 2007 9:58 pm
Reply with quote

Input file is of size 133

Output files are also of size 133
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 Jul 03, 2007 10:15 pm
Reply with quote

It's not clear what you're trying to do. Are the header records

********first-type**********

etc actually in the file and do you want to divide the records according to those header records?

Or are the headers records really not in the file and do you want to divide the records by something in the records? If so, what?

Please explain more clearly what you want to do.

And why does your Subject say you want 4 files whereas your example only shows 3 files?
Back to top
View user's profile Send private message
teethu thomas

New User


Joined: 17 May 2007
Posts: 24
Location: India

PostPosted: Tue Jul 03, 2007 10:36 pm
Reply with quote

Ya the header records are there in the file . i want to divide the records based on the header records
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jul 04, 2007 12:43 am
Reply with quote

Hello,

Will there always and only be 3 headers?

What should happen if 17 headers are present in a single run?
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 Jul 04, 2007 12:54 am
Reply with quote

teethu,

You can use a DFSORT/ICETOOL job like this:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file (FB/133)
//OUT1 DD DSN=...   output file1 (FB/133)
//OUT2 DD DSN=...   output file2 (FB/133)
//OUT3 DD DSN=...   output file3 (FB/133)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(134:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,5,CH,EQ,C'*****'),
                OVERLAY=(134:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(142:SEQNUM,8,ZD,
                         134:134,8,ZD,SUB,142,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT1,
    INCLUDE=(134,8,ZD,EQ,+1,AND,1,5,CH,NE,C'*****'),
    BUILD=(1,133)
  OUTFIL FNAMES=OUT2,
    INCLUDE=(134,8,ZD,EQ,+2,AND,1,5,CH,NE,C'*****'),
    BUILD=(1,133)
  OUTFIL FNAMES=OUT3,
    INCLUDE=(134,8,ZD,EQ,+3,AND,1,5,CH,NE,C'*****'),
    BUILD=(1,133)
/*
Back to top
View user's profile Send private message
teethu thomas

New User


Joined: 17 May 2007
Posts: 24
Location: India

PostPosted: Wed Jul 04, 2007 11:03 am
Reply with quote

Can you explain me the meaning of these statement

Code:

  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(134:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,5,CH,EQ,C'*****'),
                OVERLAY=(134:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(142:SEQNUM,8,ZD,
                         134:134,8,ZD,SUB,142,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT1,
    INCLUDE=(134,8,ZD,EQ,+1,AND,1,5,CH,NE,C'*****'),
    BUILD=(1,133)
  OUTFIL FNAMES=OUT2,
    INCLUDE=(134,8,ZD,EQ,+2,AND,1,5,CH,NE,C'*****'),
    BUILD=(1,133)
  OUTFIL FNAMES=OUT3,
    INCLUDE=(134,8,ZD,EQ,+3,AND,1,5,CH,NE,C'*****'),
    BUILD=(1,133)
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 Jul 04, 2007 9:05 pm
Reply with quote

The INREC IFTHEN statements are the "group" trick explained in the "Include or omit groups of records" and "Sort groups of records" Smart DFSORT Tricks at:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/

They assign a group number to each group of records that starts with '*****' (your type headers).

The first OUTFIL statement writes the records from group 1 (except for the header) in OUT1.

The second OUTFIL statement writes the records from group 2 (except for the header) in OUT2.

The third OUTFIL statement writes the records from group 3 (except for the header) in OUT3.

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:

Use [URL] BBCode for External Links
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 and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
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
Search our Forums:

Back to Top