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 Usergroups Profile Log in to check your private messages Log in
 

 

To extract the last word from a text

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: To extract the last word from a text
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 Moderator


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

PostPosted: Fri Jun 29, 2007 8:06 pm    Post subject:
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    Post subject: Re: To extract the last word from a text
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    Post subject:
Reply with quote

... and RECFM is FB.
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 Jun 30, 2007 5:23 am    Post subject:
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 Moderator


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

PostPosted: Sat Jun 30, 2007 5:39 am    Post subject:
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    Post subject:
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    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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm


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