|
View previous topic :: View next topic
|
| Author |
Message |
rohanthengal
Active User
.jpg)
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
I want to replace junks in file fields with some default value. Can i accomplish this task with DFSORT options ?
| Code: |
example: length of input file can be 5
INPUT FILE
-------------
YAY.Y
.AYYY
Y.Y.Y
YA..Y
YRN.. |
assume . =junk character
I want to check for all places in records for junks like..
1) for first field in input file, i have to check ---
IF it is not 'Y' or 'N' then replace it with default value 'N'
2) for second field in input file, i have to check ---
IF it is not 'A'or 'R then replace it with default value 'R'
3) for third field in input file, i have to check ---
IF it is not 'Y'or 'N' then replace it with default value 'N'
4) for fourth field in input file, i have to check ---
IF it is not 'Y'or 'N' then replace it with default value 'N'
5) for fifth field in input file, i have to check ---
IF it is not 'Y'or 'N' then replace it with default value 'N'
OUTPUT FILE should be as below
-------------------------------------
| Code: |
YAYNY
NAYYY
YRYNY
YANNY
YRNNN |
Let me know if we can do this with sort options/how or eazytrieve...
Which option would be better from performance point of view ? |
|
| Back to top |
|
 |
rohanthengal
Active User
.jpg)
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
| this will help me to recreate file in case of any accidental damage. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
| Quote: |
| this will help me to recreate file in case of any accidental damage. |
If this "file" you are creating will have only specific values, how will this help recreating the file? How does a file "accidentally" get damaged so that the values can be "reset" this way  |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
| Quote: |
| this will help me to recreate file in case of any accidental damage. |
Why not ensure a process which is accident free? |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| Quote: |
| How does a file "accidentally" get damaged |
the same way a damsel gets unexpectedly/accidentally pregnant  |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Took something seriously that was poked at her in fun . . .
d |
|
| Back to top |
|
 |
Anbarasan D
New User
Joined: 20 Apr 2010 Posts: 21 Location: USA
|
|
|
|
try this
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=(1,1,CH,NE,C'Y',AND,1,1,CH,NE,C'N'),
OVERLAY=(1:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(2,1,CH,NE,C'A',AND,2,1,CH,NE,C'R'),
OVERLAY=(2:C'R'),HIT=NEXT),
IFTHEN=(WHEN=(3,1,CH,NE,C'Y',AND,3,1,CH,NE,C'N'),
OVERLAY=(3:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(4,1,CH,NE,C'Y',AND,4,1,CH,NE,C'N'),
OVERLAY=(4:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(5,1,CH,NE,C'Y',AND,5,1,CH,NE,C'N'),
OVERLAY=(5:C'N')) |
|
|
| Back to top |
|
 |
rohanthengal
Active User
.jpg)
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
Can i go for Easytrieve ?
Performancewise both option look are same... |
|
| Back to top |
|
 |
rohanthengal
Active User
.jpg)
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
| @Pandro.. you know if there is something called as 'Risk Management..' |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Yes, it can be done it Easytrieve. |
|
| Back to top |
|
 |
rohanthengal
Active User
.jpg)
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
| @enrico, i agree, but i am still in learning phase... i can help on whatever i learned here..for sure..Thank you |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
| Quote: |
| Performancewise both option look are same... |
Why do you believe this? |
|
| Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1217 Location: Dublin, Ireland
|
|
|
|
| Anbarasan D wrote: |
try this
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=(1,1,CH,NE,C'Y',AND,1,1,CH,NE,C'N'),
OVERLAY=(1:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(2,1,CH,NE,C'A',AND,2,1,CH,NE,C'R'),
OVERLAY=(2:C'R'),HIT=NEXT),
IFTHEN=(WHEN=(3,1,CH,NE,C'Y',AND,3,1,CH,NE,C'N'),
OVERLAY=(3:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(4,1,CH,NE,C'Y',AND,4,1,CH,NE,C'N'),
OVERLAY=(4:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(5,1,CH,NE,C'Y',AND,5,1,CH,NE,C'N'),
OVERLAY=(5:C'N')) |
|
Why not...
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=(1,1,CH,NE,C'Y'),
OVERLAY=(1:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(2,1,CH,NE,C'A'),
OVERLAY=(2:C'R'),HIT=NEXT),
IFTHEN=(WHEN=(3,1,CH,NE,C'Y'),
OVERLAY=(3:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(4,1,CH,NE,C'Y'),
OVERLAY=(4:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(5,1,CH,NE,C'Y'),
OVERLAY=(5:C'N')) |
There's no need to check for a value if you're going to change it to the same value anyway.
Garry |
|
| Back to top |
|
 |
Anbarasan D
New User
Joined: 20 Apr 2010 Posts: 21 Location: USA
|
|
|
|
I got it. Thanks  |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
A simpler approach is to use the CHANGE command.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
YAY.Y
.AYYY
Y.Y.Y
YA..Y
YRN..
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(1:1,1,CHANGE=(1,C'Y',C'Y'),NOMATCH=(C'N'),
2:2,1,CHANGE=(1,C'A',C'A'),NOMATCH=(C'R'),
3:3,1,CHANGE=(1,C'Y',C'Y'),NOMATCH=(C'N'),
4:4,1,CHANGE=(1,C'Y',C'Y'),NOMATCH=(C'N'),
5:5,1,CHANGE=(1,C'Y',C'Y'),NOMATCH=(C'N'))
//* |
the output from this
| Code: |
YAYNY
NAYYY
YRYNY
YANNY
YRNNN |
|
|
| Back to top |
|
 |
rohanthengal
Active User
.jpg)
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
Skolusu, i think this optin can not check range if required..
e.g. if i want to check for one place if it is not in the range of 000 to 100 then reset to 000. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| and how does the last question relate to the initial one ??? |
|
| Back to top |
|
 |
rohanthengal
Active User
.jpg)
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
@Anbarasan D & @Garry Carroll
This is perfect PLUS optimized one...
Which one should be opted performancewise
1. Eazytriev or
2. given SORT
When i tried, i found both are almost equal but only few programmers who are more used to Eazytrieve, are using Eazytrieve and
those new generation who is more familer with SORT CARDs, prefers it because of many in one advantages...
Let me know if wrong. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
| Quote: |
When i tried, i found both are almost equal but only few programmers who are more used to Eazytrieve, are using Eazytrieve and
those new generation who is more familer with SORT CARDs, prefers it because of many in one advantages...
Let me know if wrong. |
What do you mean "almost equal"?
If the local standards permit the use of either, then either should be ok.
From what i've seen many places, sort will perform better than Easytrieve for large volumes of data. Easytrieve is intended to be an entire programming language. I believe that neither is the tool for "everything". One should determine the better tool for the job and use that tool. Have you ever seen a master carpenter with only one saw? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| rohanthengal wrote: |
Skolusu, i think this optin can not check range if required..
e.g. if i want to check for one place if it is not in the range of 000 to 100 then reset to 000. |
rohanthengal,
You are provided with a solution specific to the requirements posted in your first post. We cannot read your mind or requirements. Post detailed information on what you're trying to accomplish. Do not make people guess what you mean. This will give you a much better chance of getting a good answer to your question.
Please Seek solutions instead of Shopping for solutions. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|