Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Extract String from record based on position of other String

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
joeempson

New User


Joined: 21 Mar 2009
Posts: 11
Location: UK

PostPosted: Sat Mar 21, 2009 7:55 pm    Post subject: Extract String from record based on position of other String
Reply with quote

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
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat Mar 21, 2009 8:17 pm    Post subject:
Reply with quote

Have you looked at PARSE?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Mar 21, 2009 10:36 pm    Post subject:
Reply with quote

Hello,

What might be done with an output file of multiple entries of "StringB"?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat Mar 21, 2009 11:11 pm    Post subject:
Reply with quote

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
View user's profile Send private message
joeempson

New User


Joined: 21 Mar 2009
Posts: 11
Location: UK

PostPosted: Sat Mar 21, 2009 11:14 pm    Post subject: Reply to: Extract String from record based on position of ot
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat Mar 21, 2009 11:38 pm    Post subject:
Reply with quote

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
View user's profile Send private message
joeempson

New User


Joined: 21 Mar 2009
Posts: 11
Location: UK

PostPosted: Sun Mar 22, 2009 12:56 am    Post subject: Reply to: Extract String from record based on position of ot
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Mar 22, 2009 2:24 am    Post subject: Reply to: Extract String from record based on position of ot
Reply with quote

Hi Joe,

So, what is wanted is whatever are the next n bytes after the literal. . .

Thanks,

d
Back to top
View user's profile Send private message
joeempson

New User


Joined: 21 Mar 2009
Posts: 11
Location: UK

PostPosted: Tue Mar 24, 2009 1:47 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 24, 2009 1:53 am    Post subject: Reply to: Extract String from record based on position of ot
Reply with quote

Hi Joe,

Thanks for the follow up - sometimes i'm a bit less than quick. . . icon_redface.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts How to change a string containing the... chong.zhou TSO/ISPF 6 Tue Aug 29, 2017 4:54 pm

Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us