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

ISPF edit macro - Spacing out a variable issue


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

New User


Joined: 29 May 2006
Posts: 59
Location: India

PostPosted: Mon Aug 25, 2008 11:02 pm
Reply with quote

My reqt is to space out the MGMTCLAS=R2 in the PROC using ISPF edit macro
The MGMTCLAS=R2 comes in the PROC in the below 3 cases.

First case
//SORTOUT DD DSN=UNV.TST.FILE,DISP=(,CATLG,DELETE),
// UNIT=DISK,MGMTCLAS=R2,
// DCB=(RECFM=FB,LRECL=10,BLKSIZE=0),
// SPACE=(TRK,(10,10),RLSE)

Second case
//SORTOUT DD DSN=UNV.TST.FILE,DISP=(,CATLG,DELETE),
// UNIT=DISK,
// MGMTCLAS=R2,
// DCB=(RECFM=FB,LRECL=10,BLKSIZE=0),
// SPACE=(TRK,(10,10),RLSE)

Third case
//TSTXXXX PROC CONDA='0,NE',MGMTCLAS='MGMTCLAS=R2',

The below code spaces out MGMTCLAS=R2 for the first and third case.

Code:
"ISREDIT C ',MGMTCLAS=R2'  '' ALL"
"ISREDIT C 'MGMTCLAS=R2,'  '' ALL"


But I am not sure how to deal the second case as it comes like this

//SORTOUT DD DSN=UNV.TST.FILE,DISP=(,CATLG,DELETE),
// UNIT=DISK,
//
// DCB=(RECFM=FB,LRECL=10,BLKSIZE=0),
// SPACE=(TRK,(10,10),RLSE)

I am thinking of the option to read the MGMTCLAS=R2 line (if exists) and then check whether the byte just before 'M' is having spaces or comma. If comma means the above code will work out. If spaces means, we need to check whether the byte after 'R2' is having spaces or comma. If spaces means then put comment for the same line.

I think there might be some other better way to handle this.
Please help

Thanks
Chidam
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: Mon Aug 25, 2008 11:46 pm
Reply with quote

Hello,

As long as it will not be the last parameter on the DD, you could change "// MGMTCLAS=R2, " to "//* XXXTCLAS=R2, " and then issue the other change commands.
Back to top
View user's profile Send private message
chidams78
Currently Banned

New User


Joined: 29 May 2006
Posts: 59
Location: India

PostPosted: Mon Aug 25, 2008 11:55 pm
Reply with quote

It can be the last parameter or with some other parameter in the same line. So we won't be able to comment out the line.

Any idea how to solve this issue

Thanks
Chidam
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Aug 26, 2008 12:07 am
Reply with quote

I guess You might need to build a jcl parser, to isolate keywords and relative parameters,

take a look at ...

http://ibmmainframes.com/viewtopic.php?t=32494&highlight=parser

and use the drop_tabl variable to list the jcl keywords You want to drop from Your jcl

the sample posted works on a pc win/linux/mac osx with regina rexx

should be straightforward to change the I/O linein/lineout logic with the
"ISREDIT (DATA) = LINE ..."
"ISREDITE LINE AFTER ... = DATA" logic
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: Tue Aug 26, 2008 12:22 am
Reply with quote

Hello,

My suggestion was for when it is the only parameter on the line. Then it should be ok to make the line a comment. This also requires that this not be the very last parameter on the DD statement.

Your examples show that the SPACE parameter is the last DD parameter.

If that rule will not always be true, then you are looking at some kind of parser as Enrico suggests.
Back to top
View user's profile Send private message
chidams78
Currently Banned

New User


Joined: 29 May 2006
Posts: 59
Location: India

PostPosted: Tue Aug 26, 2008 1:23 am
Reply with quote

I think we understood it wrongly...

I mean by "Spacing out" as not the parameter SPACE used in DD statement. I mean that after conversion, i don't want to have the parameter MGMTCLAS=R2 in the DD statement.

The code that I have mentioned will take care of case 1 and 3 but case 2 will have problem as I had mentioned.

Please let me know whether this my reqt is clear.
I am looking to solve this issue in REXX macro
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Tue Aug 26, 2008 1:58 am
Reply with quote

A clearer term is 'blank out' or 'null out'.

I think you should code it in phases. I mean, handle all of the second case before working on the first or third case.

1. Find where it is last in list (blank before and after):
Code:
Address ISREDIT
"F ' MGMTCLAS=R2'  "

Then back up and remove comma from previous line.
Delete the line you found.

2. Find where it is middle of list (blank before and comma and blank after):
Code:
Address ISREDIT
"F ' MGMTCLAS=R2', "

Delete the line you found.


I think you need to worry about &MGMTCLAS within the proc.
Back to top
View user's profile Send private message
chidams78
Currently Banned

New User


Joined: 29 May 2006
Posts: 59
Location: India

PostPosted: Tue Aug 26, 2008 2:22 am
Reply with quote

Pedro,

Thanks for the logic.

If we are issuing a FIND command for MGMTCLAS=R2 with spaces before and after the variable, the Return Code will just tell whether this is present in the PROC or not.
But how can we find whether MGMTCLAS=R2 comes in the last of the list
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: Tue Aug 26, 2008 2:46 am
Reply with quote

Hello,

Quote:
The code that I have mentioned will take care of case 1 and 3 but case 2 will have problem as I had mentioned.
Is your case2 described exactly? If your posted case is exactly what will be in the jcl, then i believe you can use the change i mentioned - from "// MGMTCLAS=R2, " to "//* XXXTCLAS=R2, ".

After the change, your jcl would look like:

Code:
//SORTOUT DD DSN=UNV.TST.FILE,DISP=(,CATLG,DELETE),
// UNIT=DISK,
//* XXXTCLAS=R2,
// DCB=(RECFM=FB,LRECL=10,BLKSIZE=0),
// SPACE=(TRK,(10,10),RLSE)


You would issue this "longer" change before any others. The XXX prevents a hit on some other change.

If you believe this will not work, please clarify.
Back to top
View user's profile Send private message
chidams78
Currently Banned

New User


Joined: 29 May 2006
Posts: 59
Location: India

PostPosted: Tue Aug 26, 2008 3:02 am
Reply with quote

D sch,

Thanks for the reply. I think the code that you had mentioned as
Code:
ISREDIT C  '   MGMTCLAS=R2,   '      '//*  XXXTCLAS=R2, '


will take care of case 2 only.
And the below code takes care of case 1 and 3
Code:
"ISREDIT C ',MGMTCLAS=R2'  '' ALL"
"ISREDIT C 'MGMTCLAS=R2,'  '' ALL"

Am i right....

Sorry, I didnt understand this statement
"The XXX prevents a hit on some other change. "

Note: You mean itz a normal comment statement, right
Back to top
View user's profile Send private message
chidams78
Currently Banned

New User


Joined: 29 May 2006
Posts: 59
Location: India

PostPosted: Tue Aug 26, 2008 3:07 am
Reply with quote

Now I got it..Thanks...
We need to issue the code in this order

Code:
ISREDIT C  '   MGMTCLAS=R2,   '      '//*     XXXTCLAS=R2,  ' ALL
ISREDIT C ',MGMTCLAS=R2'  '' ALL
ISREDIT C 'MGMTCLAS=R2,'  '' ALL


The first one will take care of case 2 and the remaining others will take care of case 1 and 3. Since the forst command changes MGMT to XXXT, the second and third line of code wont impact that, right
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: Tue Aug 26, 2008 3:13 am
Reply with quote

Hello,

Quote:
Now I got it..Thanks...
We need to issue the code in this order
You're welcome icon_smile.gif

Yes, i believe you're quite close. . . .
Code:
ISREDIT C  '   MGMTCLAS=R2,   '      '//*     XXXTCLAS=R2,  ' ALL
needs the //'s
Code:
ISREDIT C  '//   MGMTCLAS=R2,   '      '//*     XXXTCLAS=R2,  ' ALL


Good luck and someone will be here if there are questions.
Back to top
View user's profile Send private message
chidams78
Currently Banned

New User


Joined: 29 May 2006
Posts: 59
Location: India

PostPosted: Tue Aug 26, 2008 3:49 am
Reply with quote

The only problem with that is, the code will solve the case 2, only if the blank spaces between // and MGMTCLAS=R2 is same in the PROC and in our code. Otherwise it won't consider that. Am i right
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: Tue Aug 26, 2008 4:33 am
Reply with quote

Hello,

Yes, they would need to exactly match.

That is why i asked if your case2 was exact. . .
Back to top
View user's profile Send private message
chidams78
Currently Banned

New User


Joined: 29 May 2006
Posts: 59
Location: India

PostPosted: Tue Aug 26, 2008 8:07 pm
Reply with quote

We can't be sure that all the procs are like case 2. The blank spaces between // and MGMTCLAS may differ from one PROC to another
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Aug 26, 2008 8:16 pm
Reply with quote

just repeat as many times as needed

Code:
             1234567890123456
ISREDIT C  '// MGMTCLAS=R2, '           '//* XXXTCLAS=R2, ' ALL
ISREDIT C  '//  MGMTCLAS=R2, '          '//* XXXTCLAS=R2, ' ALL
ISREDIT C  '//   MGMTCLAS=R2, '         '//* XXXTCLAS=R2, ' ALL
ISREDIT C  '//    MGMTCLAS=R2, '        '//* XXXTCLAS=R2, ' ALL
ISREDIT C  '//     MGMTCLAS=R2, '       '//* XXXTCLAS=R2, ' ALL
ISREDIT C  '//      MGMTCLAS=R2, '      '//* XXXTCLAS=R2, ' ALL
and so on
[/quote]
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: Tue Aug 26, 2008 9:24 pm
Reply with quote

Yup, that should do it icon_smile.gif

d
Back to top
View user's profile Send private message
chidams78
Currently Banned

New User


Joined: 29 May 2006
Posts: 59
Location: India

PostPosted: Wed Aug 27, 2008 12:32 am
Reply with quote

That is great...
Thanks Enrico.

I also thought of the logic (as told by Pedro) i.e., finding the MGMTCLAS=R2 by puting spaces on either sides and then deleting the entry from the PROC.

Code:
MGMTRC = 0                                     
DO WHILE (MGMTRC = 0)                         
    ISREDIT F '  MGMTCLAS=R2, ' "
    MGMTRC = RC                                 
    IF MGMTRC = 0 THEN                         
        DO                                       
            ISREDIT (LINE) = LINENUM .ZCSR
            ISREDIT DELETE  .ZCSR
        END                                     
   ELSE DO                                     
               ISREDIT (LINE) = LINENUM .ZCSR
           END                                   
END                                           


The logic mentioned by Enrico also holds good in this case.
But both the logic fails if MGMTCLAS=R2 falls as the last parameter of DD STEP.

Thanks
Chidam
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: Wed Aug 27, 2008 1:16 am
Reply with quote

Hello,

I believe you can make use of the "lack of" the trailing comma. If this is the last parameter of the DD, there will be no comma after the "R2".

While it would be less than elegant, you could use the lack of a comma following the R2 and pass the pds once to identify (what would hopefully be) the few members with the R2 at the end of the DD. These few could be changed manually and then your process should be good to go.

Like i mentioned - less than elegant, but would forego the need to write an entire parser just to do this one task.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Wed Aug 27, 2008 2:04 am
Reply with quote

Actually, I had said to find the one where it is last in the list (but I did not write it correctly in my sample code):

1. Find where it is last in list (blank before and after):
Code:
Address ISREDIT
"F ' MGMTCLAS=R2 '  "


Then back up and remove comma from previous line.
Delete the line you found.

Code:
 "(line,col) =CURSOR"           
"LABEL "line -1 "= .q 0"       
"LABEL "line    "= .r 0"       
"CHANGE  ', ' '  ' first .q .q"
"DELETE  .r"



NOTE: One of the examples used unquoted strings, such as
Code:
ISREDIT (LINE) = LINENUM .ZCSR

Instead of:
Code:
Address ISREDIT
"(LINE) = LINENUM .ZCSR"

The rexx processor will try to resolve all of the text as variables. Someday you may actually have a 'linenum' variable and the macro will not work as you intended.

And even though they may function the same, they are not. Rexx looks for a variable called ISREDIT, looks for a variable called LINE, and looks for a variable called LINENUM. It will not find it the first time, so creates a variable and sets the value to its name (in uppercase). Finally, it resolves the whole command and sends it to ISREDIT. For a few variables, this extra processing is minuscule, but when many such commands are used, it adds up. Now that you know, please add quotes around your host commands.
Back to top
View user's profile Send private message
Ramya A

Active User


Joined: 26 Jul 2004
Posts: 104

PostPosted: Wed Aug 27, 2008 2:19 am
Reply with quote

You can do

Code:
DO i=1 to n
     ISREDIT C  ' MGMTCLAS=R2,   '      'MGMTCLAS=R2,   ' ALL
END


where n would be the maximum number of spaces you would expect between '//' and 'MGMTCLAS' in any of your JCL. This way, at end of this loop there will only be //MGMTCLAS and no spaces in between.
Back to top
View user's profile Send private message
Ramya A

Active User


Joined: 26 Jul 2004
Posts: 104

PostPosted: Wed Aug 27, 2008 2:26 am
Reply with quote

Oops! Sorry, didn't see the second page of replies.. icon_sad.gif
Back to top
View user's profile Send private message
chidams78
Currently Banned

New User


Joined: 29 May 2006
Posts: 59
Location: India

PostPosted: Wed Aug 27, 2008 2:31 am
Reply with quote

Thanks to all for this ISPF macro piece.
It worked. Now whichever way the MGMTCLAS=R2 is coded in the existing PROC, our ISPF macro finds it and cleans it off...:-)
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Looking for a little history of ISPF ... TSO/ISPF 5
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
No new posts Query on edit primary command CLIST & REXX 5
Search our Forums:

Back to Top