Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Splitting of files based on a condition, update trailer cnt

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Splitting of files based on a condition, update trailer cnt
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Jun 07, 2011 11:52 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
Reply with quote

Thanks Kolusu for the help...
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jun 08, 2011 1:56 am    Post subject:
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:

http://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    Post subject:
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    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jun 23, 2011 1:12 am    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us