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

How to update a particular column in REXX?


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Sat May 24, 2008 1:11 am
Reply with quote

Rexx Gurus,

As per my requirement i would get the column no and the data as inputs and i should update the record with the data in that particular column.

say for example the input data that i get is

column - 15
data - Aaru

then i should update all the records with "Aaru" starting from column no 15. Is there any function in REXX to do this?
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Sat May 24, 2008 2:23 am
Reply with quote

POS ought to work.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Sat May 24, 2008 3:21 am
Reply with quote

I think there is a possibility that data in other columns will make POS difficult to use.

For example, say the search was for aaru in column 15 and data was:
Code:

----+----1----+----2---
 aaru  aaru   aaru     


if POS('aaru', whole_line) = 15 ...

would give false results.

perhaps:
Code:

column =15
serch = 'aaru'
If  substr(whole_line, column, length(serch) =  serch then...
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: Sat May 24, 2008 4:40 am
Reply with quote

Hello,

I may misunderstand the requirement, but my understanding is that the user will provide a starting position and a "fill" value. The code should fill all of the records with specified value at the starting position.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Sat May 24, 2008 5:50 am
Reply with quote

Kevin,

Quote:
POS ought to work.


I have used POS before, and to my knowledge it can be used for finding the starting position of the string.

dick,

Quote:

I may misunderstand the requirement, but my understanding is that the user will provide a starting position and a "fill" value. The code should fill all of the records with specified value at the starting position.


Exactly. You are correct and that is what my requirement is.
Back to top
View user's profile Send private message
charanmsrit

New User


Joined: 25 Oct 2007
Posts: 81
Location: Australia

PostPosted: Tue May 27, 2008 1:11 am
Reply with quote

Hi,

even i have got an almost similar requirement. i have to update accounting information on job card for all the 3000 jcl's in each test region of total 20 test regions to the below shown format. each jcl have different accounting information with different length. well, i know i can capture both open and closing brackets column position. is there a way to use these column positions and update the accounting information to below format ?? Please advise

JOB (1111,XXXX,XXXXXXXX),

Thanks,
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue May 27, 2008 5:46 pm
Reply with quote

charan,

First of all your requirement is different from mine and it is doable.

Quote:
know i can capture both open and closing brackets column position. is there a way to use these column positions and update the accounting information to below format


Use POS u can get the column no/position where the accounting info starts[by checking for "("] and based on that u can edit the data.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue May 27, 2008 6:59 pm
Reply with quote

here is a snippet that will parse a job card for accounting data
get rid of the old account info,
rebuild the same card with the new account info

Code:

jobcard = " //jobname JOB (sccnt,wwww,qqq),class=a, "
jobcard = " //jobname JOB acct,class=b,  "
jobcard = " //jobname JOB (sccnt,wwww,qqq),class=a, "

jobcard = strip(jobcard)

p = pos("JOB",jobcard)

jhead = strip(substr(jobcard,1,p-1))

if p = 0 then do
   say "not a JOB stmt :" jobcard
   exit
end

data = strip(substr(jobcard,p+4))
say "data    " data

if  substr(data,1,1) = "(" then do
   p = Pos(")",data)
   acctinfo = substr(data,2, p-2)
   jtail = substr(data,p+1)
end
else do
   p = pos(",",data)
   acctinfo = substr(data,1,p-1)
   jtail = substr(data,p)
end

say "jhead   " jhead
say "jtail   " jtail

say "acctinfo" acctinfo

parse var acctinfo acct1 "," acct2 "," acct3 "," acct4 "," .

say "acct1   " acct1
say "acct2   " acct2
say "acct3   " acct3
say "acct4   " acct4


newacct= "(new,acct.info)"
jobcnew = jhead || " JOB " || newacct || jtail

say "jobcnew " jobcnew

Back to top
View user's profile Send private message
Ganesh.Deokar

New User


Joined: 30 Sep 2005
Posts: 26
Location: Buffalo,NY

PostPosted: Tue May 27, 2008 8:44 pm
Reply with quote

Did you try OVERLAY function.

e.g.
OVERLAY(' ','abcdef',3) -> 'ab def'
OVERLAY('.','abcdef',3,2) -> 'ab. ef'
OVERLAY('qq','abcd') -> 'qqcd'
OVERLAY('qq','abcd',4) -> 'abcqq'
OVERLAY('123','abc',5,6,'+') -> 'abc+123+++'

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/IKJ4A350/4.3.43?DT=20040623084642


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

Global Moderator


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

PostPosted: Tue May 27, 2008 9:56 pm
Reply with quote

regarding Aaru's original requirement:
> i should update all the records with "Aaru" starting from column no 15

A. I understood it to describe a filter:
i should update all the records THAT HAVE "Aaru" starting from column no 15

B. whereas, Dick understood it to mean:
i should update all the records AND REPLACE ANY TEXT IN COLUMN 15 WITH "Aaru"

If it really is B, then I do not understand how POS can help.
Back to top
View user's profile Send private message
charanmsrit

New User


Joined: 25 Oct 2007
Posts: 81
Location: Australia

PostPosted: Wed May 28, 2008 12:55 am
Reply with quote

Thanks a ton enrico. It's really amazing
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed May 28, 2008 4:21 am
Reply with quote

pedro,

Quote:
If it really is B, then I do not understand how POS can help.


You are correct and POS cannot be used for the same. This has already been said in the previous post.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed May 28, 2008 4:22 am
Reply with quote

Ganesh,

Quote:
Did you try OVERLAY function.



I shall try and let u know if it is working.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Wed May 28, 2008 11:23 am
Reply with quote

What about an ISPF edit macro

C 'abc' '999' 15
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu May 29, 2008 10:41 pm
Reply with quote

expat,

Quote:
What about an ISPF edit macro


Basically my requirement is to get few column no's/data from the user and update that particular column in a PS/VSAM files with the data.

first i want it to implement for PS/alphanumeric/numeric fields and then extend it to VSAM/COMP/COMP-3 fields and all

i have not written any macro's and have to dig a bit to see if i can use it. I shall give it a try.

Thanks for your valuable suggestions.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Thu May 29, 2008 10:56 pm
Reply with quote

> first ... PS/alphanumeric/numeric fields and then extend it to VSAM/COMP/COMP-3...

I doubt that you will be able to use similar methods to update both PS and VSAM files.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri May 30, 2008 12:07 am
Reply with quote

Pedro,

Quote:
I doubt that you will be able to use similar methods to update both PS and VSAM files.


Hmm even i doubt. My first task is to make it work for a normal sequential dataset and then should try for VSAM.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri May 30, 2008 12:09 am
Reply with quote

Quote:
Did you try OVERLAY function.


Yep, tried and it worked. Thanks for letting me know this.
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
Search our Forums:

Back to Top