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

How to find the position and length of a word in a record?


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Thu Aug 30, 2007 11:18 pm
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
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 Developer


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

PostPosted: Fri Aug 31, 2007 5:06 am
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
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

Moderator Emeritus


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

PostPosted: Fri Aug 31, 2007 7:45 am
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
Reply with quote

Hello Dick,

I must use SORT.
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 Aug 31, 2007 9:31 pm
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
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
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 Developer


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

PostPosted: Tue Sep 04, 2007 8:34 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top