View previous topic :: View next topic
Author
Message
prafull New User Joined: 08 Dec 2006Posts: 48
We have a file which has 10 byte aphanumeric field AT POSITION 1-10
Our requirement is to find the records which have spaces in between numbers.
e.g.
The input file has records like
(also see attached image )
Code:
*1234 *
*56 78 *
*456 567 *
*456 127*
*45 127*
*4 27*
* 4567 *
* 4567 *
* 45678910*
* 567 910*
record# 2 3 4 5 6 and 10 are having space(s) between numbers.
We have to catch these kinda records... Is it possible using DFOSRT ?
Back to top
shankar.v Active User Joined: 25 Jun 2007Posts: 196 Location: Bangalore
prafull,
Please check with the following code for your requirement.
Code:
// EXEC PGM=SORT
//SORTIN DD *
1234
56 78
456 567
456 127
45 127
4 27
4567
4567
45678910
567 910
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=(1,1,SS,EQ,C'0123456789'),OVERLAY=(81:C'1'),
HIT=NEXT),
IFTHEN=(WHEN=(1,1,CH,EQ,C' '),OVERLAY=(81:C'0'),
HIT=NEXT),
IFTHEN=(WHEN=(2,1,SS,EQ,C'0123456789'),OVERLAY=(82:C'1'),
HIT=NEXT),
IFTHEN=(WHEN=(2,1,CH,EQ,C' '),OVERLAY=(82:C'0'),
HIT=NEXT),
IFTHEN=(WHEN=(3,1,SS,EQ,C'0123456789'),OVERLAY=(83:C'1'),
HIT=NEXT),
IFTHEN=(WHEN=(3,1,CH,EQ,C' '),OVERLAY=(83:C'0'),
HIT=NEXT),
IFTHEN=(WHEN=(4,1,SS,EQ,C'0123456789'),OVERLAY=(84:C'1'),
HIT=NEXT),
IFTHEN=(WHEN=(4,1,CH,EQ,C' '),OVERLAY=(84:C'0'),
HIT=NEXT),
IFTHEN=(WHEN=(5,1,SS,EQ,C'0123456789'),OVERLAY=(85:C'1'),
HIT=NEXT),
IFTHEN=(WHEN=(5,1,CH,EQ,C' '),OVERLAY=(85:C'0'),
HIT=NEXT),
IFTHEN=(WHEN=(6,1,SS,EQ,C'0123456789'),OVERLAY=(86:C'1'),
HIT=NEXT),
IFTHEN=(WHEN=(6,1,CH,EQ,C' '),OVERLAY=(86:C'0'),
HIT=NEXT),
IFTHEN=(WHEN=(7,1,SS,EQ,C'0123456789'),OVERLAY=(87:C'1'),
HIT=NEXT),
IFTHEN=(WHEN=(7,1,CH,EQ,C' '),OVERLAY=(87:C'0'),
HIT=NEXT),
IFTHEN=(WHEN=(8,1,SS,EQ,C'0123456789'),OVERLAY=(88:C'1'),
HIT=NEXT),
IFTHEN=(WHEN=(8,1,CH,EQ,C' '),OVERLAY=(88:C'0'),
HIT=NEXT),
IFTHEN=(WHEN=(9,1,SS,EQ,C'0123456789'),OVERLAY=(89:C'1'),
HIT=NEXT),
IFTHEN=(WHEN=(9,1,CH,EQ,C' '),OVERLAY=(89:C'0'),
HIT=NEXT),
IFTHEN=(WHEN=(10,1,SS,EQ,C'0123456789'),OVERLAY=(90:C'1'),
HIT=NEXT),
IFTHEN=(WHEN=(10,1,CH,EQ,C' '),OVERLAY=(90:C'0'))
OUTFIL INCLUDE=(81,10,SS,EQ,C'101',OR,
81,10,SS,EQ,C'1001',OR,
81,10,SS,EQ,C'10001',OR,
81,10,SS,EQ,C'100001',OR,
81,10,SS,EQ,C'1000001',OR,
81,10,SS,EQ,C'10000001',OR,
81,10,SS,EQ,C'100000001',OR,
81,10,SS,EQ,C'1000000001',OR,
81,10,SS,EQ,C'10000000001',OR,
81,10,SS,EQ,C'100000000001'),
OUTREC=(1,80)
/*
//
Output:
Code:
56 78
456 567
456 127
45 127
4 27
567 910
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Prafull,
Here's a simpler way to do what you want using DFSORT's PARSE function:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1234
56 78
456 567
456 127
45 127
4 27
4567
4567
45678910
567 910
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC PARSE=(%=(STARTAT=NONBLANK,ENDBEFR=C' '),
%1=(STARTAT=NONBLANK,FIXLEN=1)),
OVERLAY=(81:%1)
OUTFIL INCLUDE=(81,1,CH,NE,C' '),
BUILD=(1,80)
/*
I assumed you only have blanks after position 10 as shown in your example. If you have nonblanks after position 10, I can show you how to adjust the job to handle that.
Back to top
prafull New User Joined: 08 Dec 2006Posts: 48
Gr8! thanks lot both of you...
Yes Frank ,actually we have non-blanks after 10 bytes
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Quote:
Yes Frank ,actually we have non-blanks after 10 bytes
In that case, you can use a DFSORT job like this:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1234 R01
56 78 R02
456 567 R03
456 127 R04
45 127 R05
4 27 R06
4567 R07
4567 R08
45678910 R09
567 910 R10
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:1,10)),
IFTHEN=(WHEN=INIT,
PARSE=(%=(ABSPOS=81,STARTAT=NONBLANK,ENDBEFR=C' '),
%1=(STARTAT=NONBLANK,FIXLEN=1)),
OVERLAY=(81:%1))
OUTFIL INCLUDE=(81,1,CH,NE,C' '),
BUILD=(1,80)
/*
Back to top
sarbamrit New User Joined: 15 Oct 2007Posts: 12 Location: Kentucky
I'm not sure whether this is possible using DFSORT
If we divide the first 10 byte by any number say 5 or 10 and if we get a numeric values that means it doesnt have any space in between else it will have a space.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Amrit,
Your suggestion doesn't really make any sense. What format (ZD, FS, ?)do you think you could use for the 10-byte field that would give a non-numeric value when divided by 5? What exactly would you expect as a non-numeric value? Think it through and try to come up with an actual workable solution based on your idea and I believe you'll find you can't.
Back to top
Please enable JavaScript!