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
 

 

How to search and report first occurence of a string from PS
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
cartiga

New User


Joined: 27 Jan 2010
Posts: 6
Location: Chennai

PostPosted: Wed Jan 27, 2010 4:57 pm    Post subject: How to search and report first occurence of a string from PS
Reply with quote

Hi,
Can anyone of you help me to solve my following query?

I need to search for a string in a PS file(Record format : FS and Block size : 4566) and to write only the first occurence of the string in output file.
The string I am searching can be anywhere in the input PS file multiple times.
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jan 27, 2010 7:23 pm    Post subject:
Reply with quote

Hi Cartinga, Welcome..

What is SORT product you are using?

Do you want whole record to be written into output where search string is found for first time?
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: Wed Jan 27, 2010 10:55 pm    Post subject:
Reply with quote

Cariga,

Here's an example of a DFSORT job that will do what I think you asked for. I assumed your input file has RECFM=FB and LRECL=80 and the string you are looking for is 'TARGET', but the job can be changed appropriately for other LRECLs and target strings.

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCC TARGET CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEE TARGET EEEEEEEEEEEEEEEEEEE
FFFFFFFFF TARGET FFFFFFF TARGET EEEEEEEEEEEEEEEEEEE
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY,STOPAFT=1
  INCLUDE COND=(1,80,SS,EQ,C'TARGET')
/*


For this example, SORTOUT would have:

Code:

CCCCCCCCCCC TARGET CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 
Back to top
View user's profile Send private message
cartiga

New User


Joined: 27 Jan 2010
Posts: 6
Location: Chennai

PostPosted: Fri Jan 29, 2010 12:24 pm    Post subject: Reply to: How to search and report first occurence of a stri
Reply with quote

Hi Frank... I got the expected output from your help. Thank you Very much!!!icon_smile.gif icon_biggrin.gif

Hi Sambhaji... Thanks for your response!
Back to top
View user's profile Send private message
milind suman
Warnings : 1

New User


Joined: 19 Aug 2009
Posts: 55
Location: Pune

PostPosted: Thu Feb 11, 2010 11:19 pm    Post subject:
Reply with quote

Hi Yaeger,

I have a similar requirement , the difference is instead of whole record , I need TO WRITE only the search string in the SORTOUT.E.g the output should be :

TARGET

how can i change this SORT to achive this ..please ?
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: Thu Feb 11, 2010 11:25 pm    Post subject:
Reply with quote

Huh? That makes no sense. Your requirement is to search for 'TARGET' and write out 'TARGET'? There must be more to it than that or you could just write one record with 'TARGET' without searching anything.

Please do a better job of explaining your real requirement.
Back to top
View user's profile Send private message
milind suman
Warnings : 1

New User


Joined: 19 Aug 2009
Posts: 55
Location: Pune

PostPosted: Thu Feb 11, 2010 11:36 pm    Post subject:
Reply with quote

oops ..I missed to mention that there might be more than one search word in INCULDE COND and I want to write that word which gets a hit in the file .
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 Feb 11, 2010 11:39 pm    Post subject:
Reply with quote

Hello,

Suggest you show some sample input including any/all situations and the output you want from that sample input. . .
Back to top
View user's profile Send private message
milind suman
Warnings : 1

New User


Joined: 19 Aug 2009
Posts: 55
Location: Pune

PostPosted: Thu Feb 11, 2010 11:45 pm    Post subject:
Reply with quote

My requirement is as follows:

I have few key words ( approx 5 ) TARGET1,TARGET2,TARGET3,TARGET4,TARGET5

I need to search these key words in a file ( PS , RECL=80) , The string (Key word) can be present anywhere in the file . ( same way as it was asked in the intial question)

If, lets say TARGET1 is present int the file , My output should have :
TARGET1

If TARGET1 is not found ..then dont write it in output.
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: Thu Feb 11, 2010 11:51 pm    Post subject:
Reply with quote

Your requirement is still not completely clear.

What output do you want if TARGET1 and TARGET2 are present in the file?

What output do you want if TARGET1 is present twice in the file and TARGET3 is present three times in the file?
Back to top
View user's profile Send private message
milind suman
Warnings : 1

New User


Joined: 19 Aug 2009
Posts: 55
Location: Pune

PostPosted: Thu Feb 11, 2010 11:59 pm    Post subject:
Reply with quote

Those string which are found should come in OUTPUT , If TARGET1 and TAGET2 both are present then output should contain :

TARGET1
TARGET2

Multiple occurence or only 1 occurence both has to treated as HIT .TARGET1 may appear 100 times in file , My requirement is to just check if TARGET1 ( and other key words) are present in file or not irrespective of their occurence .

Sorry for not being so clear in my requirement icon_cry.gif
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 Feb 12, 2010 12:43 am    Post subject:
Reply with quote

Here's one way to do what you asked for with DFSORT/ICETOOL:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG   DD  SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN   DD    *
SPLICE FROM(IN) TO(T1) ON(1,1,CH) WITHANY -
  WITH(2,7) WITH(9,7) WITH(16,7) WITH(23,7) WITH(30,7) USING(CTL1)
COPY FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
 INCLUDE COND=(1,80,SS,EQ,C'TARGET1',OR,
               1,80,SS,EQ,C'TARGET2',OR,
               1,80,SS,EQ,C'TARGET3',OR,
               1,80,SS,EQ,C'TARGET4',OR,
               1,80,SS,EQ,C'TARGET5')
 INREC IFTHEN=(WHEN=INIT,PARSE=(%01=(STARTAT=C'TARGET1',FIXLEN=7)),
     HIT=NEXT),
    IFTHEN=(WHEN=INIT,PARSE=(%02=(STARTAT=C'TARGET2',FIXLEN=7)),
     HIT=NEXT),
    IFTHEN=(WHEN=INIT,PARSE=(%03=(STARTAT=C'TARGET3',FIXLEN=7)),
     HIT=NEXT),
    IFTHEN=(WHEN=INIT,PARSE=(%04=(STARTAT=C'TARGET4',FIXLEN=7)),
     HIT=NEXT),
    IFTHEN=(WHEN=INIT,PARSE=(%05=(STARTAT=C'TARGET5',FIXLEN=7)),
   BUILD=(X,%01,%02,%03,%04,%05))
 OUTFIL FNAMES=T1,BUILD=(2,7,/,9,7,/,16,7,/,23,7,/,30,7)
/*
//CTL2CNTL DD *
  OMIT COND=(1,7,CH,EQ,C' ')
/*
Back to top
View user's profile Send private message
milind suman
Warnings : 1

New User


Joined: 19 Aug 2009
Posts: 55
Location: Pune

PostPosted: Fri Feb 12, 2010 1:04 am    Post subject:
Reply with quote

Thanks much Frank for your support and time .
A small doubt .. Can i extend the control carrd ( CTL1CNTL ) for a large number of key words (TARGET's) ( lets say more than 500) ..just wondering if there is any practical limit which could restrict my requirement for going beyond 5 key words .

Thanks a lot !
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 Feb 12, 2010 1:12 am    Post subject:
Reply with quote

The limit would be 100 keywords due to the limit of 100 %nn parse fields (%00-%99).
Back to top
View user's profile Send private message
cartiga

New User


Joined: 27 Jan 2010
Posts: 6
Location: Chennai

PostPosted: Tue Feb 23, 2010 2:16 pm    Post subject: Reply to: How to search and report first occurence of a stri
Reply with quote

Hi everybody,

Can you tell me how we can search a first occurence of a string of a file1 one by one in a file2(which is a PS as in this post) and print the string in a file3(O/P) if the string exist once in file2 and print the string in file4(O/P) if the string is not present in file2.
File1:
AIIP1120D
AIIP010I
BIIBMCTG
CIF300IA
BI300I9BC
etc...
Actually i want to know how we can pass the string in file1(I/P) one by one to a search process!!??

Can anyone of you please help!
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 Feb 23, 2010 9:34 pm    Post subject:
Reply with quote

I don't understand what you're trying to do.

Are you trying to use DFSORT to do this? If so, you need to do a better job of explaining what it is exactly you want to do.

Please show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example.
Back to top
View user's profile Send private message
cartiga

New User


Joined: 27 Jan 2010
Posts: 6
Location: Chennai

PostPosted: Wed Feb 24, 2010 9:35 am    Post subject: Reply to: How to search and report first occurence of a stri
Reply with quote

Hi Frank,

I have an inptut file(file1) which is a PS of recfm=fB, BLKSIZE=0, and LRECL=10 and it contains strings of 8 or 9 characters. There is no dupliactes in the input file(file1).

I want to search these strings of file1 in file2 which is a PS of RECFM=FS, BLKSIZE=4566, and LRECL=0 which can have the strings of file1 more than once. That is file2 in which I am searching the strings can have duplicates.

Say I am searching the first string of file1 in file2 and if it is present in the file2, I need to print the only teh first occurance of the string in output(file3) which is also a PS of recfm=fB, BLKSIZE=0, and LRECL=10.

If the string is not present, I need to print the string in output(file4) which is also a PS of recfm=fB, BLKSIZE=0, and LRECL=10.

Ex of file1 :-
AIIP1120D
AIIP010I
BIIBMCTG
,etc...

I want to take the strings in file1 one by one and search in file2.

Ex of file2:-
sjkfkfkghdfkhgkhgdjglnfr,0dfbgj98-45=bfd09ojl AIIP1120D kfhghkfb,49-jioh5y47585y AIIP1120D 9870igjgg0[tp==jouhr/.lpfldkkhkghkhfhighfighfihg[jy97jiAIIP010I87gh8t23879yg=-0-587o8ekdy8,m.lk;;.ds,jk AIIP010I iuyi7kgggggggggggggggggggggygjgjgj

Ex of File 3 and File 4 :-
File3
-----
AIIP1120D
AIIP010I

File4
-----
BIIBMCTG


Hope my requirement is clear. Please tell your thoughts and let me know if my requirement is still not clearThanks.
Back to top
View user's profile Send private message
cartiga

New User


Joined: 27 Jan 2010
Posts: 6
Location: Chennai

PostPosted: Wed Feb 24, 2010 9:38 am    Post subject: Reply to: How to search and report first occurence of a stri
Reply with quote

I am trying to develop this in DFSORT and also trying in REXX.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Feb 25, 2010 5:03 am    Post subject: Re: Reply to: How to search and report first occurence of a
Reply with quote

cartiga wrote:
Hi Frank,

I have an inptut file(file1) which is a PS of recfm=fB, BLKSIZE=0, and LRECL=10 and it contains strings of 8 or 9 characters. There is no dupliactes in the input file(file1).

I want to search these strings of file1 in file2 which is a PS of RECFM=FS, BLKSIZE=4566, and LRECL=0 which can have the strings of file1 more than once. That is file2 in which I am searching the strings can have duplicates.


Catiga,

LRECL of 0 for FS file? or was it a typo?
Back to top
View user's profile Send private message
cartiga

New User


Joined: 27 Jan 2010
Posts: 6
Location: Chennai

PostPosted: Thu Feb 25, 2010 1:14 pm    Post subject:
Reply with quote

Hi SKolusu,
I have a PS file of FS and record length 0.
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Detailed Transaction History report f... Kyle Carroll CICS 5 Tue Oct 18, 2016 12:42 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Easytrieve - Report writing - Only 1 ... Abhi Nature CA Products 2 Wed Sep 14, 2016 11:40 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm
No new posts How to insert a lengthy string havin... vidyaa DB2 7 Thu Aug 25, 2016 5:20 pm


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