How to check for specific string in the file



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

How to check for specific string in the file

Postby Irene Ioujanina » Mon Aug 13, 2012 9:08 pm

Hi,

May I please ask for assistance.
I have a file which could contain 1 or many records. In one of the records could be a specific 'key' string (in any record, in any position) lets say 'THIS IS A KEY'. I hope there is a way to check if it's present in the file, and create a new file with just one this record, with the 'KEY' string' .

For instance, the file has the following records:
header 11111111     text    key
4 jfjfjfjf   9 9 9 9 99
4gjgjgjgj                  900d0d0d
  8888     THIS IS a KEY
   8888 00s0s0s0s0

After the program run, it will create a file with just one record:
8888 THIS IS a KEY

If there is NO 'KEY string' in the first file - the resulting file will be created empty, or has 0(zero) records.
Hope it is possible.
Thanks so much in advance,
Irene
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to check for specific string in the file

 

Re: How to check for specific string in the file

Postby dick scherrer » Mon Aug 13, 2012 9:55 pm

Hello,

Your data may or may not be "Code'd" as you want. Suggest when posting code or data or jcl etc, you use the Code tag and the Preview function so you can see your post as it will appear to the forum (rathe than how it appears in the Reply editor).

What should happen if there are more than one of the "key" is found in the file?

You should be able to do what you want using INCLUDE and specifying SS (substring) for the key. There are examples in the forum.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: How to check for specific string in the file

Postby Irene Ioujanina » Tue Aug 14, 2012 2:20 am

Thanks.

It is always one, like a 'TOTAL' by the end of the file. The purpose is just to identify if its present in the file at all. As soon as we found just one, it is good enought for me.
Could you please provide a link to examples you mentioned?

Thank you.
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to check for specific string in the file

Postby NicC » Tue Aug 14, 2012 8:03 am

Links to Sort manuals are at the top of the DFSORT section of the forum - which is where they have always been. Links to the IBM Manuals in general are now provided at the top and bottom of every page.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: How to check for specific string in the file

Postby dick scherrer » Tue Aug 14, 2012 8:30 am

Hello,

One of the first things to do is Search in this part of the forum for similar topics. There are many topics that demonstrate using INCLUDE. There are some showing SS and this is not a good search value as it is too short (only 2 characters).

For complete info about substring (SS), refer to the manuals mentioned by Nic.

If you find smething that is not clear, post what you found and your doubt. Someone will be able to clarify.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: How to check for specific string in the file

Postby skolusu » Tue Aug 14, 2012 9:00 pm

You can use SS format like shown below to get the desired results. I assumed that your LRECL is 80 Bytes

//STEP0100 EXEC PGM=SORT                   
//SYSOUT   DD SYSOUT=*                     
//SORTIN   DD *                             
HEADER 11111111     TEXT    KEY             
4 JFJFJFJF   9 9 9 9 99                     
4GJGJGJGJ                  900D0D0D         
  8888     THIS IS A KEY                   
   8888 00S0S0S0S0                         
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                             
  SORT FIELDS=COPY                         
  INCLUDE COND=(1,80,SS,EQ,C'THIS IS A KEY')
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: How to check for specific string in the file

Postby Irene Ioujanina » Tue Aug 14, 2012 9:32 pm

Thank you!
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post