I want to write the record with a particular word whose position and length is not known and it can appear anywhere in the record. I did this using SS in INCLUDE. Now i need to find the length and position of that word in the record. Is there any possibility in DFSORT to do this?
Infact i don't need to find the length. This requirement arises when i had an interesting discussion with my friends. what i need is the position of that word.
for ex:
file:
123456abcd
1234abcd
Here the starting position of abcd in 1st record is 7 and for the 2nd record is 5.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You could use a series of DFSORT IFTHEN clauses, but that may not be practical depending on how long the records are. For your example:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
123456abcd
1234abcd
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=(1,4,CH,EQ,C'abcd'),
BUILD=(C'Position of word is 1')),
IFTHEN=(WHEN=(2,4,CH,EQ,C'abcd'),
BUILD=(C'Position of word is 2')),
IFTHEN=(WHEN=(3,4,CH,EQ,C'abcd'),
BUILD=(C'Position of word is 3')),
IFTHEN=(WHEN=(4,4,CH,EQ,C'abcd'),
BUILD=(C'Position of word is 4')),
IFTHEN=(WHEN=(5,4,CH,EQ,C'abcd'),
BUILD=(C'Position of word is 5')),
IFTHEN=(WHEN=(6,4,CH,EQ,C'abcd'),
BUILD=(C'Position of word is 6')),
IFTHEN=(WHEN=(7,4,CH,EQ,C'abcd'),
BUILD=(C'Position of word is 7'))
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
Ya Frank. But if LRECL is large, then this will become lengthy. guess i might lose my bet.
Yes, it will. But you could use DFSORT to "generate" the IFTHEN conditions rather than hardcoding them. Would that win the bet? What exactly are the terms of the bet? What's allowed and not allowed for the solution? (You could have asked me in a private note whether it could be done before betting - or would that have been cheating? )