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

Splitting one row into multiple Rows


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

Active User


Joined: 11 Mar 2007
Posts: 197
Location: india

PostPosted: Tue Aug 02, 2011 12:13 pm
Reply with quote

Hello,

I have a file which contains a record like :-

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
12345ABC4500012HMK9000212HBK9700019HMU9300018HMK60


Its actually occurrence of one group field WS-RECORD 100 times

Code:
WS-RECORD                      W      10   A
WS-AMT             WS-RECORD          05   N
WS-ID              WS-RECORD          03   A
WS-SD              WS-RECORD          02   N



Required Output:-

Code:
12345ABC45
00012HMK90
00212HBK97
00019HMU93
00018HMK60


How can we achieve the above output using DFSORT..

Thank You,
Rajat
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Aug 02, 2011 12:30 pm
Reply with quote

Hi,

this may assist
Code:
//SORT0001 EXEC PGM=SORT                                               
//SORTIN   DD *                                                         
12345ABC4500012HMK9000212HBK9700019HMU9300018HMK60                     
/*                                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  OUTFIL BUILD=(1,10,/,11,10,/,21,10,/,31,10,/,41,10)                   
/*                                                                     



Gerry
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 197
Location: india

PostPosted: Tue Aug 02, 2011 1:14 pm
Reply with quote

Cool.. That is exactly what i wanted .. Thank you
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 02, 2011 6:09 pm
Reply with quote

rajatbagga,
Quote:
Its actually occurrence of one group field WS-RECORD 100 times

Alternatively you can also use RESIZE operator which makes it easy to code and maintain. Based on above comment, I am assuming your input is FB/1000 and you are trying to split that into 10 byte records each.

Code:
//STEP0001 EXEC PGM=ICETOOL         
//TOOLMSG  DD  SYSOUT=*             
//DFSMSG   DD  SYSOUT=*             
//IN       DD  YOUR INPUT FB/1000   
//OUT      DD  YOUR OUTPUT FB/10     
//TOOLIN   DD  *                     
 RESIZE FROM(IN) TO(OUT) TOLEN(10)   
/*                                   

Thanks,
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 197
Location: india

PostPosted: Tue Aug 02, 2011 6:26 pm
Reply with quote

Thanks , but this field occurs 100 times from position 101 and ends at 1101, after this there few other fields. The total record length of my file is 1800/FB. Is it possible to use RESIZE in this case?

thank you,
Rajat
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 02, 2011 7:40 pm
Reply with quote

rajatbagga,
Had you mentioned this earlier, it would have been easier to test one solution only. See if below works.
Code:
//STEP0001 EXEC PGM=ICETOOL                       
//TOOLMSG  DD  SYSOUT=*                           
//DFSMSG   DD  SYSOUT=*                           
//IN       DD  DISP=SHR,DSN=your input FB/1800
//OUT      DD  YOUR OUTPUT FB/10                           
//TOOLIN   DD  *                                 
 RESIZE FROM(IN) TO(OUT) TOLEN(10)  USING(CTL1)   
/*                                               
//CTL1CNTL DD *                                   
  OUTFIL FNAMES=OUT,STARTREC=11,ENDREC=110       
/*                                               

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

Senior Member


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

PostPosted: Tue Aug 02, 2011 9:14 pm
Reply with quote

sqlcode1,

what happens if you have more than 1 record?

rajatbagga wrote:
but this field occurs 100 times from position 101 and ends at 1101, after this there few other fields. The total record length of my file is 1800/FB. Is it possible to use RESIZE in this case?


rajatbagga,

The following RESIZE operator gives you the desired results.

Code:


//STEP0100 EXEC PGM=ICETOOL                       
//TOOLMSG  DD  SYSOUT=*                           
//DFSMSG   DD  SYSOUT=*                           
//IN       DD  DSN=Your input Fb 1800 byte file,DISP=SHR
//OUT      DD  SYSOUT=*                           
//TOOLIN   DD  *                                 
  RESIZE FROM(IN) TO(OUT) TOLEN(10)  USING(CTL1)   
//CTL1CNTL DD *                                   
  INREC BUILD=(101,1000)                         
//*         
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 02, 2011 9:27 pm
Reply with quote

Skolusu,
Grrrr..on myself.. I tested with 1 record only.

Thanks,
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 197
Location: india

PostPosted: Wed Aug 03, 2011 6:52 am
Reply with quote

Thanks Skolusu,

I tried the RESIZE option its all doing good.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Aug 04, 2011 11:22 pm
Reply with quote

rajatbagga,

Since the input data is an occurs field , there is a chance that it might have spaces. You can eliminate those unwanted records in the same step itself by adding the following statement after the INREC statement. I assumed that you are validating a character field.

Code:

OUTFIL OMIT=(1,10,CH,EQ,C' ')         
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Fri Nov 18, 2011 1:32 pm
Reply with quote

Hi,

I have a similar requirement where I want to do the same thing. But my file is comma delimited. Everytime a Comma is found the row should be written to next line.

How SORT will be able to do this?
Back to top
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Fri Nov 18, 2011 2:22 pm
Reply with quote

If the values are in fixed position you can do it in one build statement. If not try PARSE feature.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Nov 18, 2011 3:19 pm
Reply with quote

And, next time, start a new topic. Different scenario, different keyword.
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 define 1 DCB parms for multiple outpu... JCL & VSAM 9
No new posts Multiple find/replace on the same dat... DFSORT/ICETOOL 4
No new posts Copy a DS Member to multiple users at... TSO/ISPF 8
This topic is locked: you cannot edit posts or make replies. How to search multiple strings in a PDS IBM Tools 3
No new posts How to search multiple members of a P... JCL & VSAM 13
Search our Forums:

Back to Top