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

How to search and report first occurence of a string from PS


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


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

PostPosted: Wed Jan 27, 2010 10:55 pm
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
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
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 Developer


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

PostPosted: Thu Feb 11, 2010 11:25 pm
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
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

Moderator Emeritus


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

PostPosted: Thu Feb 11, 2010 11:39 pm
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
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 Developer


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

PostPosted: Thu Feb 11, 2010 11:51 pm
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
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 Developer


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

PostPosted: Fri Feb 12, 2010 12:43 am
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
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 Developer


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

PostPosted: Fri Feb 12, 2010 1:12 am
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
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 Developer


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

PostPosted: Tue Feb 23, 2010 9:34 pm
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
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
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
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
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
Frank Yaeger

DFSORT Developer


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

PostPosted: Thu Feb 25, 2010 11:49 pm
Reply with quote

Quote:
I have a PS file of FS and record length 0.


????? How can you have a record length of 0?
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 26, 2010 12:42 am
Reply with quote

Hi Frank ,

I assume the File2 Has Record length of 80 and FB . Could you suggest the solution. The record length attritube can be altered once the basic logic is understood .

Thanks !
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 Feb 26, 2010 2:11 am
Reply with quote

What is the maximum number of records you can have in file1?
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 Replace each space in cobol string wi... COBOL Programming 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Need help on formatting a report DFSORT/ICETOOL 14
Search our Forums:

Back to Top