MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

String search using JCL
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
nin_Ta
Beginner


Joined: 02 Mar 2004
Posts: 6
Topics: 3

PostPosted: Tue Mar 02, 2004 7:09 am    Post subject: String search using JCL Reply with quote

Hi,

Here is the requirement.
I have to find the text that is there between two ':'. And these can be anywhere in the record. And the string length that is in between two ':' can vary. Total record length is 80. I just wanted to know whether this can be done using JCL.

Thanks,
Nin
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Mar 02, 2004 8:00 am    Post subject: Reply with quote

nin_Ta,


Can you please elaborate more on your request? what do you want to do when : is found? Please post a sample input and desired output so that we can provide a solution

Thanks,

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Tue Mar 02, 2004 8:22 am    Post subject: Reply with quote

nin_Ta,
Use batch SearchFor.
Code:

//SEARCH  EXEC PGM=ISRSUPC,PARM=(SRCHCMP,'ANYC')     
//NEWDD  DD DSN=YOUR.DSN,DISP=SHR                     
//OUTDD  DD SYSOUT=*                                 
//SYSIN  DD *                                         
SRCHFOR  ':'                                         
SRCHFORC 'SEARCH STRING',+                           
SRCHFORC ':',+                                       
/*
Back to top
View user's profile Send private message
nin_Ta
Beginner


Joined: 02 Mar 2004
Posts: 6
Topics: 3

PostPosted: Tue Mar 02, 2004 8:31 am    Post subject: Reply with quote

I have to copy the string that is there in between colons. Also we don't the string. We have to copy whatever data that is there in between.
Back to top
View user's profile Send private message
nin_Ta
Beginner


Joined: 02 Mar 2004
Posts: 6
Topics: 3

PostPosted: Tue Mar 02, 2004 8:33 am    Post subject: Reply with quote

And the sample data is:

AAAAAAAAAAAAA:MDPAB:AAAAAAAAAAAAAAAAAAAAAAAA till 80 bytes
:GHLK:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa...
Back to top
View user's profile Send private message
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Tue Mar 02, 2004 8:35 am    Post subject: Reply with quote

Do yo have file-Aid ?
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Mar 02, 2004 8:36 am    Post subject: Reply with quote

Suresh,
I must say that, this usage of SUPERC was not known to me. But, isn't it same as

Code:

//SYSIN DD *
SRCHFOR ':SEARCH STRING:'
/*


Also, note that Nin_Ta says that, the string to be searched is of variable length. So, I am not sure if your solution will work.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Mar 02, 2004 8:38 am    Post subject: Reply with quote

Yes, they are same. I just tested with the above SYSIN statements. I get the same (correct) output as above.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Tue Mar 02, 2004 8:52 am    Post subject: Reply with quote

Cogito-Ergo-Sum,
maybe the solution is simple and your method works, i will test it. What I provided was a generic process :

SRCHFOR ':' First search records have ":"
SRCHFORC 'SEARCH STRING',+ then search if the search string is anywhere after ":"
SRCHFORC ':',+ then search if there is a ":" after the previous search
In this process the search string can be floating anywhere inbetween the ::, anyway nina_ta requirement is to get all data between ::.
nina you can try
SRCHFOR ':'
SRCHFORC ':',+
this will give you all lines with :xxx:, then use a dort to remove the :: or isolate what is between the ::
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Mar 02, 2004 8:56 am    Post subject: Reply with quote

Nin_ta,

As I said please post all the details.


Input:

Code:

AAAAAAAAAAAAA:MDPAB:AAAAAAAAAAAAAAAAAAAAAAAA till 80 bytes
:GHLK:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa...



Do you want the output as follows?

Code:

MDPAB
GHLK



Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Mar 02, 2004 9:07 am    Post subject: Reply with quote

Suresh,
I am not suggesting any solution! I am saying that, what you initially posted is same as what I posted as modified SYSIN.

Frankly, I am not sure, if any utility can do this as there is no pattern available (unless, of course, too much efforts are expended). We do not know starting and/or ending column of columns. The string itself and/or its length is also not known. In such a situation, perhaps, a REXX program using PARSE instruction sounds better.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Mar 02, 2004 12:12 pm    Post subject: Reply with quote

Here is a REXX code for your purpose. I am assuming only a pair of colons per record.

This the REXX code saved as NINTA in ABC.DEF.XYZ PDS.
Code:

/*REXX*/                                                   
"execio * diskr in01 (stem input_recs. FINIS"             
i = 1 ; j = 0                                             
do while i <= input_recs.0                                 
   in_record = input_recs.i                               
   if pos(':',in_record) > 0 then                         
      do                                                   
       parse var in_record . ':' tween_colons ':' .       
       j = j + 1                                           
       out_record.j = tween_colons ;                       
      end                                                 
   i = i + 1                                               
end                                                       
out_record.0 = j                                           
"execio " out_record.0 "diskw ot01 (stem out_record. FINIS"
exit                                                       


This is the Job to execute the above.

Code:
//STEP     EXEC PGM=IKJEFT01       
//SYSEXEC  DD DSN=ABC.DEF.XYZ,     
//            DISP=SHR             
//SYSTSIN  DD *                     
%NINTA                             
/*                                 
//IN01     DD *                     
DATA DATA DATA DATA : MY DATA : DATA
:MY DATA 2:DATA DATA               
DATA DATA :MY DATA 3:               
DATA DATA DATA DATA DATA DATA       
/*                                 
//OT01     DD SYSOUT=*             
//SYSTSPRT DD SYSOUT=*             


The output is:
Code:

---+----1---
 MY DATA   
MY DATA 2   
MY DATA 3   

_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
nin_Ta
Beginner


Joined: 02 Mar 2004
Posts: 6
Topics: 3

PostPosted: Wed Mar 03, 2004 6:50 am    Post subject: Reply with quote

Kolusu,

I want the output in the format mentioned by you.

Thanks for the REXX solution. It worked.

I am just curious to know whether we can achieve the same with JCL.

Thanks,
NIN
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Wed Mar 03, 2004 8:33 am    Post subject: Reply with quote

You are welcome, NIN.

You are executing the REXX code via a job, right? So, this is the JCL way of doing. Smile

I am not aware of a quick way of doing this by a utility.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Mar 03, 2004 8:34 am    Post subject: Reply with quote

Ninta,

I am afraid that there are no utilities( sort , file-aid , IBM utilities..) which can give you the desired results.

If easytrieve is an option then the following code will give you the desired results.

Code:

//STEP0100 EXEC PGM=EZTPA00                                   
//STEPLIB  DD DSN=EASYTREV.LOADLIB,                 
//            DISP=SHR                                         
//SYSPRINT DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*                                         
//SYSSNAP  DD SYSOUT=*                                         
//SYSUDUMP DD SYSOUT=*                                         
//INFILE   DD *                                               
AAAAAAAAAAAAA:MDPAB:AAAAAAAAAAAAAAAAAAAAAAAA TILL 80 BYTES     
:GHLKMN:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...         
AAAAAAAAAAAAAAAAAAAAA:1234:BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB     
AAAAAAAAAAAAAAAA:AA:BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB           
//OUTPUT   DD SYSOUT=*,                                       
//            LRECL=80,RECFM=FB,BLKSIZE=0                     
//*                                                           
//SYSIN    DD *                                               
                                                               
  FILE INFILE                                                 
       IN-REC           01 001 A OCCURS 80 INDEX IDX           
                                                               
  FILE OUTPUT                                                 
       O-REC            01 080 A                               
       O-CHAR           01 001 A OCCURS 80 INDEX ODX           
                                                               
  W-STR-FOUND  W 01 A VALUE 'N'                               

***********************************************************************
* MAINLINE                                                            *
***********************************************************************
                                                                       
 JOB INPUT INFILE                                                     
                                                                       
   IDX   = 1                                                           
   O-REC = ' '                                                         
   W-STR-FOUND = 'N'                                                   
   DO UNTIL IDX > 80 OR W-STR-FOUND = 'Y'                             
      IF IN-REC(IDX) = ':'                                             
         IDX = IDX + 1                                                 
         ODX = 1                                                       
         DO UNTIL IN-REC(IDX) = ':'                                   
            O-CHAR(ODX)   = IN-REC(IDX)                               
            IDX = IDX + 1                                             
            ODX = ODX + 1                                             
         END-DO                                                       
         W-STR-FOUND = 'Y'                                             
      ELSE                                                             
         IDX   = IDX + 1                                               
      END-IF                                                           
   END-DO                                                             
   PUT OUTPUT                                                         
/*                                                                     


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group