Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
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
 
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 Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts Extract Record using range of Data scorp_rahul23 DFSORT/ICETOOL 3 Wed Nov 15, 2017 11:54 pm
No new posts How to Extract BMS Marco Source from ... Howard Hinman CICS 5 Tue Oct 31, 2017 11:13 pm
No new posts Spool Extract for Z /os 1.04 version Khadhar Basha CLIST & REXX 3 Thu Sep 28, 2017 3:14 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

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us