View previous topic :: View next topic
|
Author |
Message |
joeempson
New User
Joined: 21 Mar 2009 Posts: 11 Location: UK
|
|
|
|
I have a 133 byte record from which i want to extract StringB. This string can appear anywhere in the record but always follows the text 'ABCDE'.
example input
aaaaaaaaaABCDE StringBcasdcccccccccccc
aaaasdABCDE StringBaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbasdbbbABCDE StringBcc
Required output
StringB
StringB
StringB
I have managed to acheive this using DFSORT like this
Code: |
OUTFIL FNAMES=OUT1,
INCLUDE=(1,133,SS,EQ,C'ABCDE'),
IFTHEN=(WHEN=(1,5,CH,EQ,C'ABCDE'),BUILD=(1:7,7)),
IFTHEN=(WHEN=(2,5,CH,EQ,C'ABCDE'),BUILD=(1:8,7)),
IFTHEN=(WHEN=(3,5,CH,EQ,C'ABCDE'),BUILD=(1:9,7)),
etc... |
This works fine but need 126 IFTHEN statements to be complete. I wondered if anyone knows a simpler/cleaner solution?
Thanks in advance for any help. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Have you looked at PARSE? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
What might be done with an output file of multiple entries of "StringB"? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Joe,
You can use a DFSORT job like the following to do what you want much more easily. I assumed you only have one instance of ABCDE StringB per record as in your original example.
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/133)
//SORTOUT DD DSN=... outut file (FB/133)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,133,SS,EQ,C'ABCDE')
INREC PARSE=(%01=(STARTAFT=C'ABCDE ',FIXLEN=7)),
BUILD=(%01)
/*
|
|
|
Back to top |
|
|
joeempson
New User
Joined: 21 Mar 2009 Posts: 11 Location: UK
|
|
|
|
I just used 'StringB' to represent a variable string. I haven't tried PARSE but I'll give it a go on Monday. Thanks for the suggestion. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Yes, I know that 'StringB' represented a string variable and my job can handle that. I assumed the maximum length for 'StringB' is 7 based on your BUILD operands. But you can change n in FIXLEN=n to the maximum length of the string variable, whatever it is. |
|
Back to top |
|
|
joeempson
New User
Joined: 21 Mar 2009 Posts: 11 Location: UK
|
|
|
|
Hi Frank,
I was replying to Dick's question re StringB. I hadn't seen you post, but now I have I think your solution will work perfectly. I'll let you know how I get on when I'm back in the office on Monday. Thanks for the help. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Joe,
So, what is wanted is whatever are the next n bytes after the literal. . .
Thanks,
d |
|
Back to top |
|
|
joeempson
New User
Joined: 21 Mar 2009 Posts: 11 Location: UK
|
|
|
|
Hi Frank,
your PARSE solution worked perfectly. Thanks again for the help.
Hi Dick
Quote: |
So, what is wanted is whatever are the next n bytes after the literal. . .
|
Yes that's correct. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Joe,
Thanks for the follow up - sometimes i'm a bit less than quick. . .
d |
|
Back to top |
|
|
|