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

Splitting a file(record number varis) into different files


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Rajendra Kumar

New User


Joined: 26 Jun 2009
Posts: 13
Location: Hyderabad

PostPosted: Tue Aug 04, 2009 6:46 pm
Reply with quote

Hi,

I am having the data in the file as

HL1.......................ABC.........XYZ
Record-1
Record-2
Record-3
HL1.......................DEF...........PQR
Record-4
Record-5
HL1......................GHI.........TUV
Record-6
Record-7
Record-8
Record-9


The Header Record always starts with HL1,I require the first header record and the below 3 records(basically upto next Header record) needs to be written to a new file and the second header record and the next 2 records(record-4,5) needs to be written into another file and finally the 3rd one also in the same way

The records after the Header record will be varying,the file is of fixed length....we can take that as 80.

I tried in many ways but I was not able to get as the record number is varying.

Can anyone please help me out doing this using sort.

Thanks,
Rajendra
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 Aug 04, 2009 9:04 pm
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//OUT1 DD DSN=...  output file1
//OUT2 DD DSN=...  output file2
//OUT3 DD DSN=...  output file3
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HL1'),
    PUSH=(81:ID=1))
  OUTFIL FNAMES=OUT1,INCLUDE=(81,1,CH,EQ,C'1'),BUILD=(1,80)
  OUTFIL FNAMES=OUT2,INCLUDE=(81,1,CH,EQ,C'2'),BUILD=(1,80)
  OUTFIL FNAMES=OUT3,INCLUDE=(81,1,CH,EQ,C'3'),BUILD=(1,80)
/*
Back to top
View user's profile Send private message
Rajendra Kumar

New User


Joined: 26 Jun 2009
Posts: 13
Location: Hyderabad

PostPosted: Wed Aug 05, 2009 1:18 pm
Reply with quote

Hi Frank,

I am getting the error as "-INREC STATEMENT : SYNTAX ERROR".

I am using SYNCSORT and not DFSORT,not sure if anything needs to be changed other than "OPTION COPY" to "SORT FIELDS=COPY".

Thanks!
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Aug 05, 2009 2:23 pm
Reply with quote

Rajendra Kumar,

The job posted above would have worked fine for you if you had the latest release of SyncSort - SyncSort for z/OS 1.3.2 which supports the WHEN=GROUP function.
Since it's throwing syntax error, I assume you are running an older version of SyncSort. Here's a SyncSort job which should work for SyncSort 1.2 or above.
Code:
//STEP1  EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN= Input file (FB/80)                               
//OUT1     DD DSN= Output file-1 (FB/80)                             
//OUT2     DD DSN= Output file-2 (FB/80)                             
//OUT3     DD DSN= Output file-3 (FB/80)                             
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),                 
        IFTHEN=(WHEN=(1,3,CH,EQ,C'HL1'),                             
        OVERLAY=(81:SEQNUM,8,ZD)),                                   
        IFTHEN=(WHEN=NONE,                                           
        OVERLAY=(89:SEQNUM,8,ZD,81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT1,INCLUDE=(81,8,ZD,EQ,1),BUILD=(1,80)             
  OUTFIL FNAMES=OUT2,INCLUDE=(81,8,ZD,EQ,2),BUILD=(1,80)             
  OUTFIL FNAMES=OUT3,INCLUDE=(81,8,ZD,EQ,3),BUILD=(1,80)
Back to top
View user's profile Send private message
Rajendra Kumar

New User


Joined: 26 Jun 2009
Posts: 13
Location: Hyderabad

PostPosted: Wed Aug 05, 2009 3:25 pm
Reply with quote

Hi,

I am getting the error as

CONVERT FEATURE CANNOT BE USED WITH OVERLAY OR IFTHEN
SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE


I am using SYNCSORT FOR Z/OS 1.2.1 version.

Also,I am not sure whether the second overlay(basically for sub records) is correct or not.

IFTHEN=(WHEN=NONE,
OVERLAY=(89:SEQNUM,8,ZD,81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))

I think this needs to be changed.

Any help is really appreciated.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Aug 05, 2009 3:32 pm
Reply with quote

Rajendra Kumar,

My shop has recently been upgraded to SyncSort 1.3.2. And above code works fine for me. But I have nt used any new functions here.

Can you post the entire SYSOUT messages here?.
Back to top
View user's profile Send private message
Rajendra Kumar

New User


Joined: 26 Jun 2009
Posts: 13
Location: Hyderabad

PostPosted: Wed Aug 05, 2009 3:45 pm
Reply with quote

Sorry Arun....The code is working fine & Thanks a lot for the HELP.

In the Forum I had mentioned the file length as 80 but actually it is of 400 and so in my real time environment there was a small mistake from my side(numbers in SYSIN card)...I had changed the same and everything is fine...


Once again Thanks for the Information.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Aug 06, 2009 4:47 am
Reply with quote

You're welcome. icon_smile.gif Anyways good to hear that you adapted the job as per your real file attributes.
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 -> JCL & VSAM

 


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