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

How to separeate data according to data length?


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

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Wed Jun 24, 2009 10:19 am
Reply with quote

Hi,

I want to separate data according to the length of the record.

Suppose I have the following input file:
Code:


=COLS> ----+----1----
****** **************
000001 A00001 A000   
000002 A00002   0002
000003 A00003 A0000 
000004 A00004  00004
000005 A00005 A00005
****** **************

The output will be like this:
file1 has data length of 4, from column 8 to column 14:
Code:

=COLS> ----+----1---
****** *************
000001 A00001 A000 
000002 A00002 0002 
****** *************

file2 has data length of 5, from column 8 to column 14:
Code:

=COLS> ----+----1----
****** **************
000001 A00003 A0000 
000002 A00004 00004 
****** **************

file3 has data length of 6, from column 8 to column 14:
Code:

=COLS> ----+----1----
****** **************
000001 A00005 A00005
****** **************


Would you please give me some suggestions?

Thanks in advance.[/code]
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jun 24, 2009 3:39 pm
Reply with quote

You can use below.. icon_smile.gif

Code:

//SORTIN   DD *                                                     
A00001 A000                                                         
A00002   0002                                                       
A00003 A0000                                                         
A00004  00004                                                       
A00005 A00005                                                       
/*                                                                   
//F1       DD SYSOUT=*                                               
//F2       DD SYSOUT=*                                               
//F3       DD SYSOUT=*                                               
//SYSIN    DD    *                                                   
  OPTION COPY                                                       
  INREC FIELDS=(1,7,8,7,SQZ=(SHIFT=LEFT))                           
  OUTFIL FNAMES=F1,INCLUDE=(12,3,CH,EQ,C'   ')                       
  OUTFIL FNAMES=F2,INCLUDE=(13,2,CH,EQ,C'  ',AND,12,1,CH,NE,C' ')   
  OUTFIL FNAMES=F3,SAVE                                             
/*                                                                   
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Wed Jun 24, 2009 6:55 pm
Reply with quote

Indeed, if the following statement is added to the above jcl, the expected result can come out.
Code:
//SORTOUT  DD DUMMY       


But I wonder if there is someway to count the number of data that is not blank?

In the above example, the number of data in each record that is not blank from column 8 to column 14 is:
F1: 4
F2: 5
F3: 6
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 24, 2009 8:33 pm
Reply with quote

dejunzhu,

You don't need the SORTOUT statement at all when you have OUTFIL FNAMES. You can omit it instead of dummying it out.

The following DFSORT JCL will give you the desired results counting the non blank characters and put it in col 15

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                   
A00001 A000                                                       
A00002   0002                                                     
A00003 A0000                                                       
A00004  00004                                                     
A00005 A00005                                                     
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  INREC IFOUTLEN=15,                                               
  IFTHEN=(WHEN=INIT,OVERLAY=(15:6C'1')),                           
  IFTHEN=(WHEN=(08,1,CH,EQ,C' '),OVERLAY=(15:C'0'),HIT=NEXT),     
  IFTHEN=(WHEN=(09,1,CH,EQ,C' '),OVERLAY=(16:C'0'),HIT=NEXT),     
  IFTHEN=(WHEN=(10,1,CH,EQ,C' '),OVERLAY=(17:C'0'),HIT=NEXT),     
  IFTHEN=(WHEN=(11,1,CH,EQ,C' '),OVERLAY=(18:C'0'),HIT=NEXT),     
  IFTHEN=(WHEN=(12,1,CH,EQ,C' '),OVERLAY=(19:C'0'),HIT=NEXT),     
  IFTHEN=(WHEN=(13,1,CH,EQ,C' '),OVERLAY=(20:C'0'),HIT=NEXT),     
  IFTHEN=(WHEN=(14,1,CH,EQ,C' '),OVERLAY=(21:C'0'),HIT=NEXT),     
  IFTHEN=(WHEN=ANY,OVERLAY=(15:15,1,ZD,ADD,16,1,ZD,ADD,17,1,ZD,ADD,
                   18,1,ZD,ADD,19,1,ZD,ADD,20,1,ZD,EDIT=(T)))     
/*


The output will be
Code:

A00001 A000   4
A00002   0002 4
A00003 A0000  5
A00004  00004 5
A00005 A00005 6
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Wed Jun 24, 2009 8:42 pm
Reply with quote

Hi, Skolusu,

Thanks for your kind help.
The JCL you gave proved to be effective.

Thanks again.
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 save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top