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
 
How to find the position and length of a word in a record?

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

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Wed Aug 29, 2007 7:14 pm    Post subject: How to find the position and length of a word in a record?
Reply with quote

Hi,

I want to write the record with a particular word whose position and length is not known and it can appear anywhere in the record. I did this using SS in INCLUDE. Now i need to find the length and position of that word in the record. Is there any possibility in DFSORT to do this?
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: Thu Aug 30, 2007 11:18 pm    Post subject:
Reply with quote

Hello,

Quote:
a particular word whose position and length is not known and it can appear anywhere in the record. I did this using SS in INCLUDE
How did you find the "word" without specifying the length (if you used quotes, the i believe area between the quotes would be the length)?

Please post your jcl, control statements, and some sample data.
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Fri Aug 31, 2007 4:45 am    Post subject: Reply to: How to find the position and length of a word in a
Reply with quote

Hi,

Infact i don't need to find the length. This requirement arises when i had an interesting discussion with my friends. what i need is the position of that word.

for ex:

file:

123456abcd
1234abcd

Here the starting position of abcd in 1st record is 7 and for the 2nd record is 5.

any idea how to do this?
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 Aug 31, 2007 5:06 am    Post subject:
Reply with quote

You could use a series of DFSORT IFTHEN clauses, but that may not be practical depending on how long the records are. For your example:

Code:

//S1    EXEC  PGM=ICEMAN                                   
//SYSOUT    DD  SYSOUT=*                                   
//SORTIN DD *                                             
123456abcd                                                 
1234abcd                                                   
//SORTOUT DD SYSOUT=*                                     
//SYSIN    DD    *                                         
  OPTION COPY                                             
  INREC IFTHEN=(WHEN=(1,4,CH,EQ,C'abcd'),                 
    BUILD=(C'Position of word is 1')),                     
  IFTHEN=(WHEN=(2,4,CH,EQ,C'abcd'),                       
    BUILD=(C'Position of word is 2')),                     
  IFTHEN=(WHEN=(3,4,CH,EQ,C'abcd'),                       
    BUILD=(C'Position of word is 3')),                     
  IFTHEN=(WHEN=(4,4,CH,EQ,C'abcd'),                       
    BUILD=(C'Position of word is 4')),                     
  IFTHEN=(WHEN=(5,4,CH,EQ,C'abcd'),                       
    BUILD=(C'Position of word is 5')),                     
  IFTHEN=(WHEN=(6,4,CH,EQ,C'abcd'),                       
    BUILD=(C'Position of word is 6')),                     
  IFTHEN=(WHEN=(7,4,CH,EQ,C'abcd'),                       
    BUILD=(C'Position of word is 7'))                     
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Fri Aug 31, 2007 7:01 am    Post subject: Reply to: How to find the position and length of a word in a
Reply with quote

Ya Frank. But if LRECL is large, then this will become lengthy. guess i might lose my bet.
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: Fri Aug 31, 2007 7:45 am    Post subject:
Reply with quote

Hello,

What was the bet?

Must you use sort or is any solution a "win"?
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Fri Aug 31, 2007 7:25 pm    Post subject: Reply to: How to find the position and length of a word in a
Reply with quote

Hello Dick,

I must use SORT.
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 Aug 31, 2007 9:31 pm    Post subject:
Reply with quote

Quote:
Ya Frank. But if LRECL is large, then this will become lengthy. guess i might lose my bet.


Yes, it will. But you could use DFSORT to "generate" the IFTHEN conditions rather than hardcoding them. Would that win the bet? What exactly are the terms of the bet? What's allowed and not allowed for the solution? (You could have asked me in a private note whether it could be done before betting - or would that have been cheating? icon_lol.gif )
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Tue Sep 04, 2007 9:30 am    Post subject: Reply to: How to find the position and length of a word in a
Reply with quote

Quote:

But you could use DFSORT to "generate" the IFTHEN conditions rather than hardcoding them



How to generate this Frank? could you explain me.
I have to use only DFSORT to do this.
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Tue Sep 04, 2007 9:31 am    Post subject: Reply to: How to find the position and length of a word in a
Reply with quote

I mean, the terms of the bet is I have to use only DFSORT to do this.
sorry for not mentioning clearly in the previous post
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: Tue Sep 04, 2007 8:34 pm    Post subject:
Reply with quote

Here's a DFSORT job that will do what you want for an input LRECL of 100. You can change it appropriately for other LRECLs.

Does that win your bet? icon_wink.gif

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//ONE DD *
RECORD
/*
//IN DD DSN=...  input file (FB/100)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/100)
//TOOLIN   DD    *
COPY FROM(ONE) USING(CTL1)
COPY FROM(IN) USING(CTL2)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=T1,REPEAT=97,
    BUILD=(C' IFTHEN=(WHEN=(',SEQNUM,3,ZD,C',4,CH,EQ,C''abcd''),',
      C'BUILD=(C''Position is ',SEQNUM,3,ZD,C''')),',80:X)
/*
//CTL2CNTL DD *
  OPTION COPY
  OUTFIL FNAMES=OUT,
/*
//    DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD *
   IFOUTLEN=80
/*
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
This topic is locked: you cannot edit posts or make replies. Selecting two copybooks of different ... Vignesh Sid COBOL Programming 8 Tue Sep 05, 2017 7:28 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Command to find TMEMBER name for a TPIPE Siva NKK Kothamasu IMS DB/DC 0 Wed Aug 16, 2017 6:08 pm

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