Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Edit macro help needed

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> TSO/ISPF
View previous topic :: :: View next topic  
Author Message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

PostPosted: Fri Feb 26, 2010 9:39 pm    Post subject: Edit macro help needed
Reply with quote

Hi All,

Can someone please help me writing a edit macro to replace a value in a file at particular column in a line ?


If I am not clear above...

I need to put a 4 digit value in a line at particular postion in a flatfile.
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Fri Feb 26, 2010 9:45 pm    Post subject: Reply to: Edit macro help needed
Reply with quote

What have you got so far?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Fri Feb 26, 2010 9:48 pm    Post subject: Reply to: Edit macro help needed
Reply with quote

for a flat file, a better term would be PS, the best approach would be to use
Your sort product

if You search the forums You will find lots of examples on how to do it
Back to top
View user's profile Send private message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

PostPosted: Fri Feb 26, 2010 9:48 pm    Post subject:
Reply with quote

i have found a INSERT function..but that may give what i want..OVERYLAY did not help..so thought of going to macro..
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Feb 26, 2010 9:50 pm    Post subject:
Reply with quote

Hello,

If you need to put a value in the same place in some file, you might consider using your sort product rather than a macro. . .

Possibly, i misunderstand. . .
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Fri Feb 26, 2010 9:56 pm    Post subject: Reply to: Edit macro help needed
Reply with quote

A good place to start is to figure out what the EDIT command or commands are that you issue manually to do what you want. I'm thinking that you need to look at the CHANGE command ...
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Sat Feb 27, 2010 2:54 am    Post subject:
Reply with quote

Just curious... why is using SORT the "best approach"? What possible criteria could make that statement true?

The file might be small, it might be a 1 time thing, it could be that there are thousands of replacements that need an algorithm to determine (poorly defined requirements such as this one are often much more involved than the original question lets on). From the description, a single edit command (" C XXXX YYYY 5") might be all that is needed. No macro, no cryptic control cards, no programming and it would take about 0.05 seconds to run.

Sorry -- pet peeve. I know that SORT is frequently given as an answer here, but that does not make it the "best approach", only the most familiar to the posters (as edit macros are most familiar to me).
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Sat Feb 27, 2010 10:59 pm    Post subject: Reply to: Edit macro help needed
Reply with quote

Quote:
Just curious... why is using SORT the "best approach"? What possible criteria could make that statement true?


the PS organization
asking for an edit macro without telling anything more
( my assumption was for a repetitive requirement)
but I agree, depending on the requirement the alternative would be different

1) one shot and forget about it ==> sequence of ISPF commands

2) repetitive task
-- a sort approach .. because of better support and possible skill availability in the organization
-- a RYO approach ( EDIT macro in this case ) has to be written, tested, documented, deployed, mantained
-- pet peeve if somebody has chosen a tool it means that he has the competence for having
evaluated all the alternatives ( skill availabilty included ) and should not need to ask anybody on how to do it
-- too many times REXX scripts have been provided and the TS was not able to carry on without further help
-- many samples of the solution of the same problem on the sort forums

by the way I tend to use edit macros too, faster to write an edit macro than to look at the sort manuals! icon_biggrin.gif
Back to top
View user's profile Send private message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

PostPosted: Sun Feb 28, 2010 11:59 am    Post subject:
Reply with quote

MBabu wrote:
Just curious... why is using SORT the "best approach"? What possible criteria could make that statement true?

The file might be small, it might be a 1 time thing, it could be that there are thousands of replacements that need an algorithm to determine (poorly defined requirements such as this one are often much more involved than the original question lets on). From the description, a single edit command (" C XXXX YYYY 5") might be all that is needed. No macro, no cryptic control cards, no programming and it would take about 0.05 seconds to run.

Sorry -- pet peeve. I know that SORT is frequently given as an answer here, but that does not make it the "best approach", only the most familiar to the posters (as edit macros are most familiar to me).



Hi Babu,

Thanks for your help..edit command (" C XXXX YYYY 5") will help if I know what is there in the file in that position..however i donot have that data. I just need to open the file and put( replace) my data in that position.

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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Sun Feb 28, 2010 12:20 pm    Post subject: Reply to: Edit macro help needed
Reply with quote

look at the picture string
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ISPZEM61/1.3.4.1.3?SHELF=ISPZPM61&DT=20071211170344&CASE=

something as
Code:
CHANGE p'====' 'abcd" <colnum>
Back to top
View user's profile Send private message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

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

Thanks enrico,

This served my purpose. Thanks a lot.

regards
Back to top
View user's profile Send private message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

PostPosted: Tue Mar 02, 2010 3:31 pm    Post subject:
Reply with quote

I am facing another hurdle in edit macro..dont know i can continue with the last topic.

Here is my macro..

/* REXX */
ADDRESS ISPEXEC
"VGET (XXX) PROFILE"
ADDRESS ISREDIT
"MACRO"
"CHANGE P'====' '"XXX"' 4 7"
"SAVE"
"END"
"SET XXX = XXX + 1"
EXIT


I need to increment the value of XXX variable everytime at the end of the macro. XXX value is captured from a panel initially. I used SET command which I know. however I am getting error message " MAC1 MACRO ERROR".

Please someone throw some light on this.

Thanks in advance
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Mar 02, 2010 3:35 pm    Post subject:
Reply with quote

XXX = XXX + 1

XXX = 0

XXX = 'a literal string'
Back to top
View user's profile Send private message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

PostPosted: Tue Mar 02, 2010 3:42 pm    Post subject:
Reply with quote

expat, I am really sorry i could not understand your suggestion. are you asking me to try xxx = xxx + 1 ? I have tried that..but no luck. I got a the same error..

please explain how I can use XXX = 0 and XXX = 'a literal string' for my requirement
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Mar 02, 2010 3:56 pm    Post subject:
Reply with quote

Have you run the macro using trace to see what is happening.
Use TRACE I to get the maximum details.
Back to top
View user's profile Send private message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

PostPosted: Tue Mar 02, 2010 4:19 pm    Post subject:
Reply with quote

expat, I used TRACE I ..

It opened my file in edit mode, CHANGE command is executed and it stopped there. " SAVE" and " END" is not executed and when use PF3 to close the file, the next step executes.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Tue Mar 02, 2010 4:24 pm    Post subject: Reply to: Edit macro help needed
Reply with quote

/good mood on!

here is a macro I wrote some time ago ,
I called if XRENUM ( eXtended RENUMber )

the invocation format is ...
Code:
XRENUM <string>  / <the usual find replace parms>
XRENUM <string> <from>/ <the usual find replace parms>
XRENUM <string> <from> <incr> / <the usual find replace parms>


here ids the shebang
Code:
/*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                                                                   */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
Trace "O"

Parse Source _system _called _commnd .

parse upper arg zparms

_parms   = 1
_endms   = 1
_ispex   = 1
_macro   = 1
_inner   = 0

_errmsg  = ""

zretc    = 0
zerrsm   = ""
zerrlm   = ""
zerralrm = "YES"
zerrhm   = "ISR2MACR"

call $init

parse upper var zparms tokn from incr "/" zparms
if incr = "" then ,
   incr = 1
if from = "" then ,
   from = 1

leng = length(tokn)
from = right(from,leng,"0")

if ( 0 /= $isred("SEEK '"tokn"' FIRST " zparms ) ) then do
   zerrsm = "- Not Found"
   zerrlm = left(_commnd,8)"- No Occurrences of '"tokn"' Found"
   zretc  = 4
   call $term
   exit 1
end

coun = 0
do while ( 0 = $isred("CHANGE '"tokn"' '"from"' NEXT " zparms ) )
   from = from + incr
   from = right(from,leng,"0")
   coun = coun + 1
end

zerrsm = "Renum("coun") "
zerrlm = left(_commnd,8)"- "coun "Occurrences of '"mask"' Changed"
zretc  = 0

call $term

Exit

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Standard %Include Start                                           */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

/*%incdone $init                                                     */
/*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                                                                   */
$init:
   trace "O"
   if _macro then ,
      _ispex = 1
   if _ispex then do
      If Sysvar(SYSISPF) /= "ACTIVE" Then Do
         Say left(_commnd,8)"- Ispf is not active"
         Exit 4
      End
      call $ispex "CONTROL ERRORS RETURN"
      if $isred("MACRO (ZPARMS) NOPROCESS ") = 0 then do
         if _inner then ,
            call $ispex "VGET (ZPARMS) "
         zparms = translate(strip(zparms))
         _macro = 1
      end
      else do
         if _macro then do
            zerrsm = left(_commnd,8)"- Invocation ERROR"
            zerrlm = left(_commnd,8)"- Must be invoked as edit macro"
            call   $ispex "SETMSG MSG(ISRZ002) "
            Exit 1
         end
      end
      zparms = strip(zparms)
      If _parms      & ,
         zparms = "" Then do
         zerrsm = left(_commnd,8)"- Missing Parameter"
         zerrlm = left(_commnd,8)"- 'H' For Help, Or .........."
         call   $ispex "SETMSG MSG(ISRZ002) "
         Exit 1
      end
      if zparms = "?" | ,
         zparms = "H" | zparms = "HELP"  Then do
         z_rc = $ispex("DISPLAY PANEL("zerrhm") ")
         exit 1
      end
   end
   return
/*%incdone $term                                                     */
/*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                                                                   */
$term:
   trace "O"
   if zretc /= 0 then do
      zerralrm = "YES"
      if zerrsm = "" then ,
         zerrsm = left(_commnd,8)"- Rc("zretc")"
      if zerrlm = "" then ,
         zerrlm = left(_commnd,8)"- Rc("zretc") :" || _errmsg
      call   $ispex "SETMSG MSG(ISRZ002) "
   end
   else do
      if _inner then do
         call $isred "SAVE "
         call $isred "END "
      end
      if _endms then do
         zerralrm = "NO"
         if zerrsm = "" then ,
            zerrsm   = left(_commnd,8)"- Ended"
         if zerrlm = "" then ,
            zerrlm   = left(_commnd,8)"- Ended With Rc("zretc") "
         call   $ispex "SETMSG MSG(ISRZ002) "
      end
   end
   return
/*%incdone $tsoex                                                    */
$tsoex:
   trace "O"
   Address TSO arg(1)
   tso_0rc = rc
   return tso_0rc

/*%incdone $ispex                                                    */
$ispex:
   trace "O"
   Address ISPEXEC arg(1)
   isp_0rc = rc
   return isp_0rc

/*%incdone $isred                                                    */
$isred:
   trace "O"
   Address ISREDIT arg(1)
   isr_0rc = rc
   return isr_0rc

/*%incdone $$end                                                     */

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Standard %Include end                                             */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

Back to top
View user's profile Send private message
Pedro

Senior Member


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

PostPosted: Tue Mar 02, 2010 8:34 pm    Post subject: Reply to: Edit macro help needed
Reply with quote

Quote:
I need to increment the value of XXX variable everytime at the end of the macro.


You use VGET, which is good. But your SET instruction is not valid. It is a rexx instruction, not an editor instruction. Do not use quotes. and use VPUT to save it for next time.

Code:
xxx= xxx+1
Address ISPEXEC "VPUT (xxx) PROFILE"
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> TSO/ISPF All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Help Needed with View Direct shailesh_do CA Products 2 Wed Jul 13, 2016 10:39 am
No new posts PCOMM macro to call another PCOMM macro boyti ko All Other Mainframe Topics 4 Tue Jul 12, 2016 4:30 pm
No new posts Send parameter for macro STIMERM from... Daniel Teolotitla PL/I & Assembler 13 Tue Jul 05, 2016 9:23 pm
No new posts Use of Edit & FTOV migusd SYNCSORT 3 Wed Jun 08, 2016 1:49 am
No new posts RACF Easytrieve Plus macro Susan Jackson CA Products 0 Fri Jun 03, 2016 8:25 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us