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

Need macro command to find a line having given string.


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Rambhupalchowdary

New User


Joined: 19 Aug 2010
Posts: 47
Location: Hyderabad

PostPosted: Wed Apr 20, 2011 6:17 pm
Reply with quote

Hi,

I need some help in doing below thing.

I want to find a line having given string. then i want to replace that particular line with the given data.

suppose.. :-

Code:


I/p :-

//Temp Job
//
//JOBLIB   DD  DSN=Prod.lib,DISP=SHR

O/p:-

//Temp Job
//
//JOBLIB   DD  DSN=test.lib,DISP=SHR
//             DD  DSN=prod.lib,DISP=SHR



please help me in doing this.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Apr 20, 2011 6:40 pm
Reply with quote

Many examples on the forum.

Search for rcx rcy with author expat and you will find
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Wed Apr 20, 2011 6:45 pm
Reply with quote

Use the FIND, CHANGE, and LINE_AFTER macro instructions.
Back to top
View user's profile Send private message
Rambhupalchowdary

New User


Joined: 19 Aug 2010
Posts: 47
Location: Hyderabad

PostPosted: Wed Apr 20, 2011 7:10 pm
Reply with quote

Hi,

I have looked into many examples, however am able to find how to replace strings.

Here i need to replace an entire line and insert 2 new lines as mentioned in my above code.

i am able to insert new lines at first line using below code.
ISREDIT LINE_BEFORE .ZFIRST = (LINE2),
but i need to insert 2 new lines where this string found, and delete the line having this string.

Please let me know your thoughts
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Apr 20, 2011 7:25 pm
Reply with quote

You actually are changing one line and inserting one new line.

Use the commands Pedro suggested.

You are almost there.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Wed Apr 20, 2011 8:30 pm
Reply with quote

Rambhupalchowdary wrote:
Please let me know your thoughts

They would be censored.
Back to top
View user's profile Send private message
Rambhupalchowdary

New User


Joined: 19 Aug 2010
Posts: 47
Location: Hyderabad

PostPosted: Wed Apr 20, 2011 9:52 pm
Reply with quote

Hi Daveporcelan,

I have tried those line commands.

I am able to insert the lines at first or second line in my jcl. But i am unable to insert the line at line number, having the given string.

EG:- for your ref. please find the sample output which i am expecting in my previous post.

Thanks,
Ram.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Apr 20, 2011 9:54 pm
Reply with quote

Why not post your entire macro?

That would provide the best possible information to work with.
Back to top
View user's profile Send private message
Peter Nancollis

New User


Joined: 15 Mar 2011
Posts: 47
Location: UK

PostPosted: Thu Apr 21, 2011 7:01 am
Reply with quote

"Use the FIND, CHANGE, and LINE_AFTER macro instructions. " ...and they dont work [ and I must say they would have been the first things I would try ] ... why/how not?.......or do you just want the macro coding?
Back to top
View user's profile Send private message
Rambhupalchowdary

New User


Joined: 19 Aug 2010
Posts: 47
Location: Hyderabad

PostPosted: Thu Apr 21, 2011 11:09 am
Reply with quote

Hi Daveporcelan,

Could you please find the below code for my requirement.

<Code>
ADDRESS ISREDIT
"ISREDIT MACRO (MEM) NOPROCESS"
ISREDIT CHANGE 'Prod.lib' 'Test.lib' ALL
<\Code>

With the above code am able to acheive as below mentioned output

I/p :-

//Temp Job
//
//JOBLIB DD DSN=Prod.lib,DISP=SHR

O/p:-

//Temp Job
//
//JOBLIB DD DSN=test.lib,DISP=SHR

I want to get the output like below .
O/p:-

//Temp Job
//
//JOBLIB DD DSN=test.lib,DISP=SHR
// DD DSN=prod.lib,DISP=SHR

How to acheive this, i tried to insert new line at starting.but how to insert that new line immediately after the joblib.

Thanks,
Ram.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Apr 21, 2011 11:58 am
Reply with quote

Maybe you could finally RTFM?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Apr 21, 2011 12:18 pm
Reply with quote

Rambhupalchowdary,

the char used in BBcode is [ and not <.

globally changing prod.lib to test.lib precludes your finding the point at which to insert the extra dd statement.

if you would loop
Code:

SET RC = 0
DO WHILE RC = 0
   'CHG NEXT "PROD.LIB" "TEST.LIB"
    IF RC= 0 THEN
        (insert prod.lib dd after .zcsr)
        IF RC<>0 THEN
            DO
                SAY 'insert not ok at last chg'
                LEAVE
            END
END


you could find the places to insert the extra dd statement.
Back to top
View user's profile Send private message
Rambhupalchowdary

New User


Joined: 19 Aug 2010
Posts: 47
Location: Hyderabad

PostPosted: Thu Apr 21, 2011 12:18 pm
Reply with quote

Hi Prino,

What is RTFM? I searched for this term i could not able to find.

Please let me know.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Apr 21, 2011 12:33 pm
Reply with quote

Rambhupalchowdary wrote:
What is RTFM? I searched for this term i could not able to find.
What do you do in IT?

Maybe use Google? Or you also don't know what Google is?

It the returns this website as the third result.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 21, 2011 12:35 pm
Reply with quote

I thought can't be true, and lo, first result from google, wikipedia. If you are looking for help, don't jerk people around.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Apr 21, 2011 12:53 pm
Reply with quote

RTFM = Read The Fine (or orther words starting with F) Manual

Did you read the topic I suggested you read, even gave you a link to it. It does exactly what it says it does on the tin. It inserts a line / member after a given point within the data.

Now either go read that thread or something similar or RTFM icon_rolleyes.gif
Back to top
View user's profile Send private message
Rambhupalchowdary

New User


Joined: 19 Aug 2010
Posts: 47
Location: Hyderabad

PostPosted: Thu Apr 21, 2011 1:04 pm
Reply with quote

Thanks DbzTHEdinosauer,

I tried few of the commands mentioned in your above code. EG:-ZCSR

Now i got the output what i was expecting.

ISREDIT CHANGE 'DSN=S00P.BT.PGMLIB,' 'DSN=BDLE.BT.PGMLIB,'
IF RC=0 THEN
DO
LINE1 = "// DD DSN=S00P.BT.PGMLIB,DISP=SHR"
"ISREDIT LINE_AFTER .ZCSR = (LINE1)"
END

Thanks all for your inputs.. icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Apr 21, 2011 1:21 pm
Reply with quote

Rambhupalchowdary,

I am happy to see you were able to implement my suggestion and solve your problem.

BUT
I noticed that you do not check the return-code from the service call.

to write professional code/scripts, one should always insure that a call to a service,
whether it be an ISPF/SQL/File I-O/Language Environment,
be followed by a check of the return-code of that service.
Without doing so, you have no idea if the requested function/service performed as expected/wanted.

The difference between writing good code and BSing with the boys,
is being exact.

most good professionals that I know,
have private libraries of JCL/code/Scripts that they carry with them
(zipped and transferred via email)
from site to site,
which contain professionally written examples that can be easily and quickly copied and pasted.

with the innovation of CUT&PASTE (mainframe clipboard) professionally coding in ISPF has become very easy.
Back to top
View user's profile Send private message
Peter Nancollis

New User


Joined: 15 Mar 2011
Posts: 47
Location: UK

PostPosted: Fri Apr 22, 2011 1:49 am
Reply with quote

Quote:
have private libraries of JCL/code/Scripts that they carry with them

XMIT the PDS, drop the file to PC/Memory stick/whatever + use the wonderful XmitManager
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Apr 22, 2011 2:57 am
Reply with quote

Quote:
PC/Memory stick/whatever


i mentioned the email because that is about the only way I can get things from the outside to my pc at work, where ever that happens to be on a particular day.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Apr 22, 2011 3:17 am
Reply with quote

Peter Nancollis wrote:
Quote:
have private libraries of JCL/code/Scripts that they carry with them

XMIT the PDS, drop the file to PC/Memory stick/whatever + use the wonderful XmitManager

XmitManager is good, but for straight run-of-the-mill extractions RECV390 is much better (strips sequence numbers and trailing blanks) and using it with the "-dsattr -write" options writes out the PDS directory, which, with a little reformatting, can be used to set the dates of the extracted members to the ones in the original PDS, using e.g. Touch32. (Sadly RECV390 cannot handle PS data sets icon_sad.gif) And at less than 40K RECV390 is about one-twenty-fifth of the size of of XmitManager.
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 -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top