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

Edit macro help needed


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
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
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

Global Moderator


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

PostPosted: Fri Feb 26, 2010 9:45 pm
Reply with quote

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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Feb 26, 2010 9:48 pm
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
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

Moderator Emeritus


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

PostPosted: Fri Feb 26, 2010 9:50 pm
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

Global Moderator


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

PostPosted: Fri Feb 26, 2010 9:56 pm
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: 400
Location: Mumbai

PostPosted: Sat Feb 27, 2010 2:54 am
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Feb 27, 2010 10:59 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sun Feb 28, 2010 12:20 pm
Reply with quote

look at the picture string
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
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
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: 8797
Location: Welsh Wales

PostPosted: Tue Mar 02, 2010 3:35 pm
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
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: 8797
Location: Welsh Wales

PostPosted: Tue Mar 02, 2010 3:56 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Mar 02, 2010 4:24 pm
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

Global Moderator


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

PostPosted: Tue Mar 02, 2010 8:34 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts PRINTOUT macro PL/I & Assembler 0
No new posts Mainframe Programmer with CICS Skill... Mainframe Jobs 0
No new posts Need help to resolve a hard edit COBOL Programming 8
Search our Forums:

Back to Top