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
 

 

String replacement with DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
oskisalgado

New User


Joined: 03 Apr 2006
Posts: 3
Location: Madrid

PostPosted: Mon Apr 03, 2006 7:54 pm    Post subject: String replacement with DFSORT
Reply with quote

I don?t know if it is possible. I have several files, all them with VB format, with different LRECLs. I need to make some substitutions of strings and characters within the records. I?d like to build only one JCL which can do it but have several problems:

1) OUTREC with ALTSEQ can be useful with character substitutions, but what about strings?

2) If they were only characters, I suppose I can deal with different LRECLs passing it as a parameter and building the sysin for DFSORT on-the-fly, would it be right?.

Thank you in advance.
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Apr 03, 2006 9:46 pm    Post subject:
Reply with quote

I don't know what it is exactly you're trying to do. You need to supply more details. Please show an example of the records in your input file and what you want for output. What is the RECFM and LRECL of each input file? What is the starting position, length and format of each relevant field (remember that for VB records, the RDW is in bytes 1-4 and the first data byte starts at position 5).

Note that DFSORT does allow you to concatenate VB data sets with different LRECLs for input, and to use OVERLAY or IFTHEN/WHEN/OVERLAY to substitute strings within records.
Back to top
View user's profile Send private message
oskisalgado

New User


Joined: 03 Apr 2006
Posts: 3
Location: Madrid

PostPosted: Tue Apr 04, 2006 1:54 pm    Post subject: Re: String replacement with DFSORT
Reply with quote

Hello Frank:

Happy to talk with you again, I?ve been almost two years "repairing my body" after an accident which almost kills me (but the devil said "stay there, I?ve no place for you... by now icon_smile.gif ", and I?m here again bothering with my questions.

I?ll try to explain the situation:

We have more than a hundred files which are extracted from the backups of an equal number of tables, having them different LRECLs. The fact that they are VB formatted is irrelevant.

In order to export them to a Unix machine we need to apply several minor changes, for example:

"-24.0" must be converted to "-00.0"
"0D25"x must be converted to " " (double space)
"0"x must be converted to " "
"3F"x must be converted to " "

It?s a trivial task to be made with a very simple REXX program. It can also be made with a COBOL program. But.... people in my company doesn?t like to use REXX within a Production environment, and I prefer DFSORT, if it is possible, rather than COBOL.

I'd like to build ONE parametrized job to make all the conversions over all the files, calling it once for each file to convert.

The two single caracter conversions are trivial, I only need to use

OUTREC(1,rl,TRAN=ALTSEQ)
ALTSEQ CODE(0040,3F40)

passing rl as a parameter, it works fine.

The problem, or my lack of knowledge, starts with the multicharacter conversions, "-24.0" to "-00.0" and "0D25"x to " ". Can it be achieved with DFSORT? How?

Thank you again

Regards
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Apr 04, 2006 8:35 pm    Post subject:
Reply with quote

Oscar,

Sorry to hear about your accident. I'm glad you're still here to ask questions.

I guess what you're asking for is to find and replace a string anywhere in a record. Sorry, but DFSORT doesn't have any built-in functions for that.
Back to top
View user's profile Send private message
oskisalgado

New User


Joined: 03 Apr 2006
Posts: 3
Location: Madrid

PostPosted: Tue Apr 04, 2006 8:43 pm    Post subject: Re: String replacement with DFSORT
Reply with quote

Hello Frank:

Well, it?s a pity!

I?ll need to fight against some people in order to make it with REXX.

Thank you again, see you with next question one of these days.
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 287
Location: Basel, Switzerland

PostPosted: Tue Apr 04, 2006 8:54 pm    Post subject:
Reply with quote

hy oskisalgado,

if the people at your company don't like rexx,
it can only be about performance aspects,
because rexx is a interpreter, not compiled.
but if this is the only reason, tell them to use
CREX which also compiles the rexx as executables.
rexx is probably one of the most compact script
languages, where it is possible to invoke all possible
system services in online or batch.

of course i wouldn't use it for applications, but for such
kind of solutions, it is sometimes the most comfortable way...
you could do this also with cobol, which wouldn't be more
complicated, but you will have to write some more lines,
than how you are used to do with rexx.

martin9
Back to top
View user's profile Send private message
windozer

New User


Joined: 12 Feb 2006
Posts: 8

PostPosted: Fri Jan 05, 2007 7:42 pm    Post subject: Re: String replacement with DFSORT
Reply with quote

HI,

Instead of using REXX for changing all those stuff may be you can use the ISREXEX EDIT (**DSN**) (***MACRO) fuctions. The macro can contain the standard ISPF edit command. This can avoid the preformnce delays.... I know i sound confused but i will reply more clearly if u r interested....
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 287
Location: Basel, Switzerland

PostPosted: Fri Jan 05, 2007 8:02 pm    Post subject: Re: String replacement with DFSORT
Reply with quote

hy windozer,

yes this also is a possibility,
just think in which lanuage you write
yout edit-macro... probably in Rexx oder
CList...

martin9
Back to top
View user's profile Send private message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Fri Feb 16, 2007 5:11 pm    Post subject: port sed?
Reply with quote

Back in my DOS days, I wrote a simple COBOL program for just this purpose. I didn't know about the great Unix string editor, sed.

Anyway, I brought it to the mainframe when I worked at a place that had tons and tons of control cards just to do things like replace 'PROD' with 'TEST'. The old salts laughed at me when I proposed the idea but it works very well.

My program isn't sed and it's pretty simple. You just give it a paramater like
Code:

(',string_to_find,replacement_sting')


The first byte in the parm is the delimiter of the parm. So
Code:

(',{PROD},TESTA')


Would replace all occurrances of {PROD} with TESTA. I use the braces by convention since the likelihood of a brace being valid syntax isn't likely. But you can use anything you like.

There are lots of ways to achieve this. Now that I'm a *nix guy, I think porting sed would be the way to go. I'm sure that's already been done somewhere.

The disadvantage some places have with rexx is that lots of times there aren't enough people who know it.

Anyway, my program isn't that big and I'll share it if there is interest.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Sep 04, 2008 2:32 am    Post subject:
Reply with quote

Quote:
I guess what you're asking for is to find and replace a string anywhere in a record. Sorry, but DFSORT doesn't have any built-in functions for that.


DFSORT now has a find and replace function (FINDREP). It's available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008). For the example in your first post:

"-24.0" must be converted to "-00.0"
"0D25"x must be converted to " " (double space)
"0"x must be converted to " "
"3F"x must be converted to " "

You can use these DFSORT control statements:

Code:

   OPTION COPY
   INREC FINDREP=(INOUT=(C'-24.0',C'-00.0',X'0D25',C'  ',
     X'00',C' ',X'3F',C' '))


For complete details on the new FINDREP function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am


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