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

Splitting of files based on a condition, update trailer cnt


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Suraj.Nair

New User


Joined: 07 Jun 2011
Posts: 17
Location: Canada

PostPosted: Tue Jun 07, 2011 11:32 pm
Reply with quote

Hi

I have an input file which has some records. It has a header and trailer. I would like to split the file based on two consecutive characters present in the detail records. The characters can be either 'AB' or 'AC'. The two files hence generated should have header copied from the original file. After splitting the trailer has to be updated to the new files with the new count. The trailer also has some text at the beginning and at the end of the trailer record the count has to be updated( count being of 8 character length). Kindly help

Thanks Suraj
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 Jun 07, 2011 11:52 pm
Reply with quote

Your description is too vague.

Please show an example of the records in your input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input file.

Tell or show us what identifies the header and trailer.

Also, run this job and show the //SYSOUT messages you receive, so I can see what level you're at:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
RECORD
//SORTOUT DD DUMMY
//SYSIN    DD    *
    OPTION COPY
/*
Back to top
View user's profile Send private message
Suraj.Nair

New User


Joined: 07 Jun 2011
Posts: 17
Location: Canada

PostPosted: Wed Jun 08, 2011 12:22 am
Reply with quote

Input file layout:

000 20110606165432
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000004

The starting position of the field is 20, length is 2 and the type is character

The output files

File1:

000 20110606165432
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
999999999999999999900000004

File2:

000 20110606165432
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000004
Back to top
View user's profile Send private message
Suraj.Nair

New User


Joined: 07 Jun 2011
Posts: 17
Location: Canada

PostPosted: Wed Jun 08, 2011 12:23 am
Reply with quote

Sorry... the output files should have the new count

Input file layout:

000 20110606165432
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000004

The starting position of the field is 20, length is 2 and the type is character

The output files

File1:

000 20110606165432
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
999999999999999999900000002

File2:

000 20110606165432
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000002
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 08, 2011 12:47 am
Reply with quote

Suraj.Nair,

Assuming your input is FB recfm and LRECL =80, the following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                               
000 20110606165432 COPY                                       
0011134567860123456AB E 145190273033344                       
0011222333344445555AB E 145190273033344                       
0011139567890123456AC E 145190273033344                       
0011222333244445555AC E 145190273033344                       
999999999999999999900000004                                   
//ABOUT    DD SYSOUT=*                                       
//ACOUT    DD SYSOUT=*                                       
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                           
                                                             
  OUTFIL FNAMES=ABOUT,IFOUTLEN=80,                           
  INCLUDE=(1,3,SS,EQ,C'000,999',OR,20,2,CH,EQ,C'AB'),         
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),               
  IFTHEN=(WHEN=(1,3,CH,EQ,C'999'),                           
  OVERLAY=(20:81,8,ZD,SUB,+2,M11,LENGTH=8))                   
                                                             
  OUTFIL FNAMES=ACOUT,IFOUTLEN=80,                           
  INCLUDE=(1,3,SS,EQ,C'000,999',OR,20,2,CH,EQ,C'AC'),         
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),               
  IFTHEN=(WHEN=(1,3,CH,EQ,C'999'),                           
  OVERLAY=(20:81,8,ZD,SUB,+2,M11,LENGTH=8))                   
//*
Back to top
View user's profile Send private message
Suraj.Nair

New User


Joined: 07 Jun 2011
Posts: 17
Location: Canada

PostPosted: Wed Jun 08, 2011 1:16 am
Reply with quote

Thanks Kolusu for the help...
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 Jun 08, 2011 1:56 am
Reply with quote

Alternatively, you can do it with the new IFTRAIL function of DFSORT like this:

Code:

//S1 EXEC PGM=SORT                                         
//SYSOUT DD SYSOUT=*                                       
//SORTIN DD *                                             
000 20110606165432                                         
0011134567860123456AB E 145190273033344                   
0011222333344445555AB E 145190273033344                   
0011139567890123456AC E 145190273033344                   
0011222333244445555AC E 145190273033344                   
999999999999999999900000004                               
//OUT1 DD SYSOUT=*                                         
//OUT2 DD SYSOUT=*                                         
//SYSIN DD *                                               
  OPTION COPY                                             
  OUTFIL FNAMES=OUT1,INCLUDE=(20,2,CH,EQ,C'AB'),           
    IFTRAIL=(HD=YES,TRLID=(1,3,CH,EQ,C'999'),             
      TRLUPD=(20:COUNT=(M11,LENGTH=8)))                   
  OUTFIL FNAMES=OUT2,INCLUDE=(20,2,CH,EQ,C'AC'),           
    IFTRAIL=(HD=YES,TRLID=(1,3,CH,EQ,C'999'),             
      TRLUPD=(20:COUNT=(M11,LENGTH=8)))                   
/*


For more information on IFTRAIL, see:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
Back to top
View user's profile Send private message
Suraj.Nair

New User


Joined: 07 Jun 2011
Posts: 17
Location: Canada

PostPosted: Wed Jun 08, 2011 8:24 pm
Reply with quote

Thanks Frank...
Back to top
View user's profile Send private message
Suraj.Nair

New User


Joined: 07 Jun 2011
Posts: 17
Location: Canada

PostPosted: Wed Jun 22, 2011 11:14 pm
Reply with quote

Hi

A small update to the above question.

Can we update the output files header with the type of accounts that are present, meaning, if the type is AB it should be present in the 19 position of the header.

Thanks in advance
Suraj
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: Thu Jun 23, 2011 1:12 am
Reply with quote

You can replace my DFSORT control statements with the following to make that change:

Code:

  OPTION COPY                                                         
  OUTFIL FNAMES=OUT1,INCLUDE=(1,3,CH,EQ,C'000',OR,20,2,CH,EQ,C'AB'), 
    IFTHEN=(WHEN=(1,3,CH,EQ,C'000'),OVERLAY=(19:C'AB')),             
    IFTRAIL=(TRLID=(1,3,CH,EQ,C'999'),                               
      TRLUPD=(20:COUNT-1=(M11,LENGTH=8)))                             
  OUTFIL FNAMES=OUT2,INCLUDE=(1,3,CH,EQ,C'000',OR,20,2,CH,EQ,C'AC'), 
    IFTHEN=(WHEN=(1,3,CH,EQ,C'000'),OVERLAY=(19:C'AC')),             
    IFTRAIL=(TRLID=(1,3,CH,EQ,C'999'),                               
      TRLUPD=(20:COUNT-1=(M11,LENGTH=8)))                                             
Back to top
View user's profile Send private message
Suraj.Nair

New User


Joined: 07 Jun 2011
Posts: 17
Location: Canada

PostPosted: Mon Jul 25, 2011 9:43 pm
Reply with quote

Hi

In the above count of records if I want to add the count of header and trailer as well, what would be needed to be done. Kindly help.

Thanks Suraj
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jul 25, 2011 9:47 pm
Reply with quote

Suraj.Nair wrote:
Hi

In the above count of records if I want to add the count of header and trailer as well, what would be needed to be done. Kindly help.

Thanks Suraj


Change Count-1 to Count+1 to add the count of header and trailer.
Back to top
View user's profile Send private message
Suraj.Nair

New User


Joined: 07 Jun 2011
Posts: 17
Location: Canada

PostPosted: Mon Jul 25, 2011 9:51 pm
Reply with quote

Hi

I tried that....it doesnt work....


Thanks Suraj
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jul 25, 2011 9:55 pm
Reply with quote

Suraj.Nair wrote:
Hi

I tried that....it doesnt work....


Thanks Suraj


What do you mean it doesn't work? I ran this job

Code:

//STEP0400 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
000 20110606165432                                                     
0011134567860123456AB E 145190273033344                               
0011222333344445555AB E 145190273033344                               
0011139567890123456AC E 145190273033344                               
0011222333244445555AC E 145190273033344                               
999999999999999999900000004                                           
//OUT1     DD SYSOUT=*                                                 
//OUT2     DD SYSOUT=*                                                 
//SYSIN DD *                                                           
    OPTION COPY                                                       
    OUTFIL FNAMES=OUT1,INCLUDE=(1,3,CH,EQ,C'000',OR,20,2,CH,EQ,C'AB'),
      IFTHEN=(WHEN=(1,3,CH,EQ,C'000'),OVERLAY=(19:C'AB')),             
      IFTRAIL=(TRLID=(1,3,CH,EQ,C'999'),                               
        TRLUPD=(20:COUNT+1=(M11,LENGTH=8)))                           
    OUTFIL FNAMES=OUT2,INCLUDE=(1,3,CH,EQ,C'000',OR,20,2,CH,EQ,C'AC'),
      IFTHEN=(WHEN=(1,3,CH,EQ,C'000'),OVERLAY=(19:C'AC')),             
      IFTRAIL=(TRLID=(1,3,CH,EQ,C'999'),                               
        TRLUPD=(20:COUNT+1=(M11,LENGTH=8)))                           
//*


and I got
Code:

000 20110606165432AB                     
0011134567860123456AB E 145190273033344   
0011222333344445555AB E 145190273033344   
999999999999999999900000004               


The count is 4 records . You need to show me what you did.
Back to top
View user's profile Send private message
Suraj.Nair

New User


Joined: 07 Jun 2011
Posts: 17
Location: Canada

PostPosted: Mon Jul 25, 2011 10:47 pm
Reply with quote

Hi SKolusu,

You are right. I hadn't changed the TRLUPD for the first output so didnt get the updated count. Sorry for the inconvenience.


Thanks Suraj
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top