View previous topic :: View next topic |
Author |
Message |
arunkantony Beginner
Joined: 28 Feb 2006 Posts: 6 Topics: 2 Location: India
|
Posted: Mon Mar 20, 2006 7:33 am Post subject: Find and replace character using Insync |
|
|
I need some help in using the INSYNC utility.
I have an MVS flat file (FB) in which the records can have variable lengths. The beginning and end of each record has a character '~'. But in some records '~' comes in the middle of the record as well. I need to replace the '~' both at the beginning and at the end of each record with a Doube quotes ("). The '~' that comes in the middle should not be replaced.
Quote: |
Eg:
~abc efg ijk~
~sdfsf saf saf afasf afa~
~fsfg c~ 'klk~
~gsf faasdfasfafaf~
|
For record 3 you could see that '~' came in between, I would like to keep this '~' as it is and the '~' at the first and last position needs to be changed to quotes("). The challenge is in finding the location of the last '~'.
I would prefer to do this using INSYNC utility rather than SORT.
Could anyone help me to solve this issue? |
|
Back to top |
|
 |
ash_sudp Beginner
Joined: 17 May 2006 Posts: 12 Topics: 0
|
Posted: Tue Nov 20, 2007 5:51 am Post subject: |
|
|
This could be done in a lot of ways. I find the below option a good one:
Get the total occurance or the number of "~" in onw record. This could be done using a COBOL function. Once you have the count, you find and replace the one needed. This will consume less CPU.
Option 2: Normal array processing. store it in an array and process the same. But this will take more CPR time and since this is a BYTE by BYTE operation i will not prefer this. |
|
Back to top |
|
 |
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Tue Nov 20, 2007 12:08 pm Post subject: |
|
|
Quote: | I would prefer to do this using INSYNC utility rather than SORT. |
Well, for those who don't have this restriction, here's a DFSORT job that will do this quite easily:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
~abc efg ijk~
~sdfsf saf saf afasf afa~
~fsfg c~ 'klk~
~gsf faasdfasfafaf~
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,80,JFY=(SHIFT=LEFT,PREBLANK=C'~',
LEAD=C'"',TRAIL=C'"'))
/*
|
SORTOUT would have:
Code: |
"abc efg ijk"
"sdfsf saf saf afasf afa"
"fsfg c~ 'klk"
"gsf faasdfasfafaf"
|
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
 |
callanand Beginner

Joined: 12 Jun 2007 Posts: 23 Topics: 2
|
Posted: Thu Nov 22, 2007 6:31 am Post subject: |
|
|
Hi Frank,
If we had to convert all occurances of ~ to ", then what is the iceman command.
Thanks,
Anand |
|
Back to top |
|
 |
vivek1983 Intermediate

Joined: 20 Apr 2006 Posts: 222 Topics: 24
|
Posted: Thu Nov 22, 2007 6:52 am Post subject: |
|
|
callanand,
Change the control card as below:
Code: |
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,80,SQZ=(SHIFT=LEFT,PREBLANK=C'~'))
/*
|
Check this link to replace characters using fileaid.
http://www.mvsforums.com/helpboards/viewtopic.php?t=5691&highlight=replace+character _________________ Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay) |
|
Back to top |
|
 |
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Thu Nov 22, 2007 12:23 pm Post subject: |
|
|
Vivek wrote:
Quote: | INREC BUILD=(1,80,SQZ=(SHIFT=LEFT,PREBLANK=C'~')) |
No. That will actually remove all of the blank and ~ characters. You might want to try out your "solutions" before you post them.
Anand,
Here's a DFSORT job to replace each ~ with ".
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
~abc efg ijk~
~sdfsf saf saf afasf afa~
~fsfg c~ 'klk~
~gsf faasdfasfafaf~
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
ALTSEQ CODE=(A17F)
INREC BUILD=(1,80,TRAN=ALTSEQ)
/*
|
SORTOUT would have:
Code: |
"abc efg ijk"
"sdfsf saf saf afasf afa"
"fsfg c" 'klk"
"gsf faasdfasfafaf"
|
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
 |
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Thu Nov 22, 2007 3:34 pm Post subject: |
|
|
Another way is using USS services:
Code: | //USS EXEC PGM=BPXBATCH
//STDIN DD PATH='/u/user1/tilde',PATHOPTS=(ORDONLY)
//STDOUT DD PATH='/u/user1/stdout.out',PATHOPTS=(OWRONLY,OCREAT),
// PATHMODE=SIRWXU
//STDERR DD PATH='/u/user1/stderr.out',PATHOPTS=(OWRONLY,OCREAT),
// PATHMODE=SIRWXU
/* | where /u/user1/tilde is
Code: | #/bin/sh
[ -f /tmp/foo ] && rm /tmp/foo
[ -f /tmp/f2 ] && rm /tmp/f2
umask 177
cp "//'user1.foo'" /tmp/foo
sed -e 's/~/"/' -e 's/~$/"/' /tmp/foo > /tmp/f2
cp /tmp/f2 "//'user1.f2'"
rm /tmp/f2 /tmp/foo |
output is Code: | "abc efg ijk"
"sdfsf saf saf afasf afa"
"fsfg c~ 'klk"
"gsf faasdfasfafaf" |
input is from 'user1.foo', output is to 'user1.f2'. I added some security and cleanup code above, but the basic transformation is the sed command. Of course, error checking would add a couple of lines to the script. This may be overkill here (and not very efficient) but sometimes the Unix commands can be very useful for data manipulation.
I could not get the first regular expression exactly right though because I couldn't get the circumflex to be recognized (eg: 's/^~/"/g'). Anyone know how to do that from a shell script? I did try the cent sign on my US keyboard. _________________ New members are encouraged to read the How To Ask Questions The Smart Way FAQ at http://www.catb.org/~esr/faqs/smart-questions.html. |
|
Back to top |
|
 |
sivafdms Intermediate
Joined: 29 May 2007 Posts: 165 Topics: 77
|
Posted: Wed Nov 28, 2007 2:34 am Post subject: |
|
|
Hi Frank
when i tried this code Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
~abc efg ijk~
~sdfsf saf saf afasf afa~
~fsfg c~ 'klk~
~gsf faasdfasfafaf~
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,80,JFY=(SHIFT=LEFT,PREBLANK=C'~',
LEAD=C'"',TRAIL=C'"'))
/* |
it says that parameter "JFY" is not found...
could u please help me .
Thanks,
Siva |
|
Back to top |
|
 |
vivek1983 Intermediate

Joined: 20 Apr 2006 Posts: 222 Topics: 24
|
Posted: Wed Nov 28, 2007 7:36 am Post subject: |
|
|
sivafdms,
Check your version of DFSORT.
You need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) to use DFSORT's new JFY function _________________ Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay) |
|
Back to top |
|
 |
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Wed Nov 28, 2007 11:30 am Post subject: |
|
|
Quote: | it says that parameter "JFY" is not found... |
Siva,
If you're using DFSORT, then the message indicates your site has not installed z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 which is required to use DFSORT's JFY function. These PTFs have been available since April, 2006. Ask your System Programmer to install the appropriate PTF (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
www.ibm.com/servers/storage/support/software/sort/mvs/peug/
If you're using another sort product, you can't use JFY since DFSORT is the only sort product that supports it. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
 |
|
|