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 one row into multiple Rows

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 188
Location: india

PostPosted: Tue Aug 02, 2011 12:13 pm    Post subject: Splitting one row into multiple Rows
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: 1703
Location: Australia

PostPosted: Tue Aug 02, 2011 12:30 pm    Post subject:
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: 188
Location: india

PostPosted: Tue Aug 02, 2011 1:14 pm    Post subject:
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: 578
Location: USA

PostPosted: Tue Aug 02, 2011 6:09 pm    Post subject:
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: 188
Location: india

PostPosted: Tue Aug 02, 2011 6:26 pm    Post subject:
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: 578
Location: USA

PostPosted: Tue Aug 02, 2011 7:40 pm    Post subject:
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    Post subject: Reply to: Splitting one row into multiple Rows
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: 578
Location: USA

PostPosted: Tue Aug 02, 2011 9:27 pm    Post subject:
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: 188
Location: india

PostPosted: Wed Aug 03, 2011 6:52 am    Post subject: Reply to: Splitting one row into multiple Rows
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    Post subject:
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    Post subject:
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    Post subject:
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: 1715
Location: UK

PostPosted: Fri Nov 18, 2011 3:19 pm    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts Converting multiple VB files to FB fi... Viswanath Reddy JCL & VSAM 6 Mon Aug 08, 2016 11:49 pm
No new posts Can we use OPTIMIZE FOR 1 ROWS for fe... cvijay784 DB2 1 Fri Aug 05, 2016 11:56 am
No new posts Execute multiple DB2 Load commands in... faizm DB2 4 Wed Aug 03, 2016 12:53 pm


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