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: 199
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: 199
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: 199
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: 199
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
Search our Forums:

Back to Top