IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To extract the last word from a text


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Fri Jun 29, 2007 1:52 pm
Reply with quote

Hi,

Can I use OUTFIL PARSE or something else to extract the last word from a text, eg. if I had:

"AA BBB CCCC" - I would want "CCCC"

I don't know the number of words in the text.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Fri Jun 29, 2007 8:06 pm
Reply with quote

Is the text actually:

"AA BBB CCCC"

or is it:

AA BBB CCCC

What is the RECFM and LRECL of the input file?

What is the maximum number of words per line?

Please show a more complete example of the records in the input file.
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Sat Jun 30, 2007 5:12 am
Reply with quote

It's without quotes. Let's say the maximum is 10 words and the LRECL is 80.
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Sat Jun 30, 2007 5:13 am
Reply with quote

... and RECFM is FB.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Jun 30, 2007 5:23 am
Reply with quote

Hello,

Will the text only be space-delimited?

What about comma's, periods, or other characters? Are they part of the "last word" on a line?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Sat Jun 30, 2007 5:39 am
Reply with quote

Here's a way to do it with DFSORT's PARSE function. I assumed a "word" has a maximum of 10 characters (any characters other than blanks), the words are separated by one of more blanks and there can be up to 10 words per record. This should give you the idea and you can change the job as needed.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=....  input file (FB/80)
//SORTOUT DD DSN=....  output file (FB/10)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
    PARSE=(%01=(ENDBEFR=BLANKS,FIXLEN=10),
           %02=(ENDBEFR=BLANKS,FIXLEN=10),
           %03=(ENDBEFR=BLANKS,FIXLEN=10),
           %04=(ENDBEFR=BLANKS,FIXLEN=10),
           %05=(ENDBEFR=BLANKS,FIXLEN=10),
           %06=(ENDBEFR=BLANKS,FIXLEN=10),
           %07=(ENDBEFR=BLANKS,FIXLEN=10),
           %08=(ENDBEFR=BLANKS,FIXLEN=10),
           %09=(ENDBEFR=BLANKS,FIXLEN=10),
           %10=(ENDBEFR=BLANKS,FIXLEN=10)),
    BUILD=(1:%01,11:%02,21:%03,31:%04,41:%05,
         51:%06,61:%07,71:%08,81:%09,91:%10)),
   IFTHEN=(WHEN=(91,10,CH,NE,C' '),BUILD=(91,10)),
   IFTHEN=(WHEN=(81,10,CH,NE,C' '),BUILD=(81,10)),
   IFTHEN=(WHEN=(71,10,CH,NE,C' '),BUILD=(71,10)),
   IFTHEN=(WHEN=(61,10,CH,NE,C' '),BUILD=(61,10)),
   IFTHEN=(WHEN=(51,10,CH,NE,C' '),BUILD=(51,10)),
   IFTHEN=(WHEN=(41,10,CH,NE,C' '),BUILD=(41,10)),
   IFTHEN=(WHEN=(31,10,CH,NE,C' '),BUILD=(31,10)),
   IFTHEN=(WHEN=(21,10,CH,NE,C' '),BUILD=(21,10)),
   IFTHEN=(WHEN=(11,10,CH,NE,C' '),BUILD=(11,10)),
   IFTHEN=(WHEN=(1,10,CH,NE,C' '),BUILD=(1,10))
/*
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Sat Jun 30, 2007 9:36 pm
Reply with quote

Yes, my requirement was only for spaces. Thanks Frank. icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top