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

Spllitting a record based on a value


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

New User


Joined: 23 Dec 2008
Posts: 69
Location: India

PostPosted: Thu Jun 14, 2012 1:40 am
Reply with quote

Hi i have a requirement as below.

Code:
aaabbbcccdddeeefffzggghhhiiijjjzkkklllmmmnnn


Whenever i reach z i must split the rest of the record to next line...
The output should be something like this.

Code:
aaabbbcccdddeeefffz
ggghhhiiijjjz
kkklllmmmnnn


Is it possible to do in sort?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Jun 14, 2012 1:59 am
Reply with quote

sijayapal,

Basic Information needed

1. LRECL and RECFM of the input file
2. Max length of the field delimited by character 'Z'
3. Max Fields that can have Z as delimiter.
4. Last but not least run this sample Job and show me the Sysout. Look for this message
Code:
ICE201I ? RECORD TYPE IS F - DATA STARTS IN POSITION 1   
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 14, 2012 2:21 am
Reply with quote

Last but not least run this sample Job
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DUMMY
//SYSIN   DD   *
  OPTION COPY
/*
Back to top
View user's profile Send private message
sijayapal

New User


Joined: 23 Dec 2008
Posts: 69
Location: India

PostPosted: Thu Jun 14, 2012 2:55 am
Reply with quote

Hmmm LRECL=80
RECFM=FB
Quote:

2.Max length of the field delimited by character 'Z'
3. Max Fields that can have Z as delimiter.
Max length of the field delimited by character 'Z'

Its unknown... it can have Z or not at all..

Quote:
Last but not least run this sample Job and show me the Sysout. Look for this message

Please paste the job so that i can try
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 14, 2012 4:10 am
Reply with quote

sijayapal,
open your eyes, shut your mouth, read my post,
I provided the 'sample job'.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Jun 14, 2012 5:21 am
Reply with quote

Sijay,

I am sorry I did not provide the JCL but dbzTHEdinosauer graciously added the step I wanted you to run. Thank you dbzTHEdinosauer.

I guess you can use RESIZE to split the records like shown below. I assumed that you can have a max of 6 fields with delimited by Z. You can expand it upto 100 fields (100 fields is max for parse). Since your LRECL is only 80 , you can only have a max of 80 fields assuming that every character in the record is Z.

Code:

//STEP0100 EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN       DD *                                                         
AAABBBCCCDDDEEEFFFZGGGHHHIIIJJJZKKKLLLMMMNNN                           
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                         
  RESIZE FROM(IN) TO(OUT) TOLEN(80) USING(CTL1)                         
//CTL1CNTL DD *                                                         
  SORT FIELDS=COPY                                                     
  INREC PARSE=(%01=(ENDAT=C'Z',FIXLEN=80),                             
               %02=(ENDAT=C'Z',FIXLEN=80),                             
               %03=(ENDAT=C'Z',FIXLEN=80),                             
               %04=(ENDAT=C'Z',FIXLEN=80),                             
               %05=(ENDAT=C'Z',FIXLEN=80),                             
               %06=(ENDAT=C'Z',FIXLEN=80)),                             
        BUILD=(%01,%02,%03,%04,%05,%06)                                 
                                                                       
  OUTFIL OMIT=(1,80,CH,EQ,C' ')                                         
//*


The output from the above job is
Code:

AAABBBCCCDDDEEEFFFZ                                                     
GGGHHHIIIJJJZ                                                           
KKKLLLMMMNNN                                                           
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Back to top
View user's profile Send private message
sijayapal

New User


Joined: 23 Dec 2008
Posts: 69
Location: India

PostPosted: Thu Jun 14, 2012 8:06 pm
Reply with quote

that's awesome... kolusu.
It really worked well

Mr.dbzTHEdinosauer i though u were kidding icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 14, 2012 8:12 pm
Reply with quote

i never kid -
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Jun 14, 2012 8:39 pm
Reply with quote

Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DUMMY
//SYSIN   DD   *
  OPTION COPY
/*


What does this step do ??
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 14, 2012 8:46 pm
Reply with quote

ibmmainframes.com/viewtopic.php?t=33389
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: Thu Jun 14, 2012 9:12 pm
Reply with quote

Hello,

Quote:
What does this step do ??
Submit it with a JOB card and look at the output. It will show the product release / ptf level.

You might also consider SORT as ICEMAN may or may not be found on the system.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Jun 14, 2012 9:16 pm
Reply with quote

Thanks to both Dick

I realised after submitting the job that I cant use RESIZE icon_sad.gif
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Jun 15, 2012 4:33 am
Reply with quote

Hi,

if RESIZE is not available you can try this
Code:
//STEP0200 EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN       DD *                                                         
AAABBBCCCDDDEEEFFFZGGGHHHIIIJJJZKKKLLLMMMNNN                           
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
//T1       DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)       
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                         
COPY FROM(IN) USING(CTL1)                                               
COPY FROM(T1) TO(OUT) USING(CTL2)                                       
//CTL1CNTL DD *                                                         
  OUTFIL FNAMES=T1,                                                     
        PARSE=(%01=(ENDAT=C'Z',FIXLEN=80),                             
               %02=(ENDAT=C'Z',FIXLEN=80),                             
               %03=(ENDAT=C'Z',FIXLEN=80),                             
               %04=(ENDAT=C'Z',FIXLEN=80),                             
               %05=(ENDAT=C'Z',FIXLEN=80),                             
               %06=(ENDAT=C'Z',FIXLEN=80)),                             
        BUILD=(%01,/,%02,/,%03,/,%04,/,%05,/,%06)                       
//CTL2CNTL DD *                                                         
  OMIT    COND=(1,80,CH,EQ,C' ')


Gerry
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jun 15, 2012 12:54 pm
Reply with quote

Thanks Gcicchet

It does work for me ..

But I was trying to understand why just till %06 PARSE What if there was more than 8 Z in a line or in other way how can we dynamically determine the parse statements?
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: Fri Jun 15, 2012 7:57 pm
Reply with quote

Hello,

I believe you have it "turned around".

The PARSE will determine where the Zs are. You would define the maximum number of Zs and use that many PARSE statements.

After PARSE(ing) the record, you might need to use different BUILD statements for different numbers of Zs. Yup, it could take a bit of code to ensure that "blank" lines were not generated in the output.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jun 15, 2012 9:46 pm
Reply with quote

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

Senior Member


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

PostPosted: Fri Jun 15, 2012 9:47 pm
Reply with quote

Pandora-Box wrote:
Thanks Gcicchet

It does work for me ..

But I was trying to understand why just till %06 PARSE What if there was more than 8 Z in a line or in other way how can we dynamically determine the parse statements?


Did you miss this statement in my post?

skolusu wrote:
I assumed that you can have a max of 6 fields with delimited by Z. You can expand it upto 100 fields (100 fields is max for parse). Since your LRECL is only 80 , you can only have a max of 80 fields assuming that every character in the record is Z.


As dick scherrer mentioned you code for the max parse fields and then eliminate the space records on OUTFIL. If you truly want a dynamic parse then you need to write an E15 or E35 exit which is similar to writing a program.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jun 15, 2012 9:55 pm
Reply with quote

Thanks and Apologies Kolusu I did miss reading that
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top