View previous topic :: View next topic
|
Author |
Message |
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
You can use below..
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 |
|
|
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
Indeed, if the following statement is added to the above jcl, the expected result can come out.
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 |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
|
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
Hi, Skolusu,
Thanks for your kind help.
The JCL you gave proved to be effective.
Thanks again. |
|
Back to top |
|
|
|
|