View previous topic :: View next topic
|
Author |
Message |
abraralum
New User
Joined: 19 Dec 2010 Posts: 42 Location: Bangalore
|
|
|
|
Hi,
Need pointers for the below:
I am trying to extarct the records if any of the character (starting from 1-6 or 8 to 14) contains space in the 6 character field colum, and replace with '111111' in one condition.
Example
989 87 7 8 99
To replace with
111111 111111 |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
OK - you have been trying. What have you come up with that does not work? |
|
Back to top |
|
|
abraralum
New User
Joined: 19 Dec 2010 Posts: 42 Location: Bangalore
|
|
|
|
I have tried Sort card as below, but it wont evaluate each character for space...(takes as a 6 char field)
Code: |
SORT FIELDS=COPY
INCLUDE COND=(01,06,CH,EQ,C' ',OR,
08,06,CH,EQ,C' ')
|
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
use SS |
|
Back to top |
|
|
abraralum
New User
Joined: 19 Dec 2010 Posts: 42 Location: Bangalore
|
|
|
|
Thax Dick, I have got it. I will build the rest now. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you are more than welcome.
thank you for showing initiative. |
|
Back to top |
|
|
abraralum
New User
Joined: 19 Dec 2010 Posts: 42 Location: Bangalore
|
|
|
|
One issue while doing Overlay :
Code: |
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(01,06,SS,EQ,C' '),OVERLAY=(01:C'111111'))
|
When I run this, the value C'111111' copied to all the records while expectation is only t copy if it meets condition of WHEN.
Please let me know if any thing is missing ... |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
Hi,
I just ran a sample code like below
Code: |
//STEP1 EXEC PGM=SORT
//SORTIN DD *
1234 61
A BCDE2
TESTING
X YZDER
1234567
8999999
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(01,06,SS,EQ,C' '),OVERLAY=(01:C'111111'))
/* |
And the output coming as
Code: |
1111111
1111112
TESTING
111111R
1234567
8999999 |
Output looks good as per your expectation.
Can you please provide your input and output?
Regards,
Chandan |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
abraralum,
It should work as you expect.
Try this, for testing only:
Code: |
OUTREC IFTHEN=(WHEN=(01,06,SS,EQ,C' '),
OVERLAY=(07:1,6,01:C'111111')) |
This will allow you to see the contents of 1,6 - and there should be at least on space in every one. |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
abraralum,
If you want only those records which has at least one space in first 6 characters then change the sort card as below and it will work
Code: |
SORT FIELDS=COPY
INCLUDE COND=(01,06,SS,EQ,C' ')
OUTREC IFTHEN=(WHEN=(01,06,SS,EQ,C' '),OVERLAY=(01:C'111111')) |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
chandan.inst,
Why would you think that?
Having thought that, why use the IFTHEN after the INCLUDE? |
|
Back to top |
|
|
abraralum
New User
Joined: 19 Dec 2010 Posts: 42 Location: Bangalore
|
|
|
|
Bill/Chandan,
Thanks for your replies.
My output is showing all the records along with the changed ones (as shown in test run of Chandan),so code is working as expected and my undrstanding was different.
Now, since my Input has the millions of records, its not quite easy to find whether the value changed or not in O/P.
Any suggestion/pointer please |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
Hi Bill,
I thought of Include because one of earlier post by abraralum where DIck suggested to use 'SS'.
abraralum wrote: |
I have tried Sort card as below, but it wont evaluate each character for space...(takes as a 6 char field)
Code: |
SORT FIELDS=COPY
INCLUDE COND=(01,06,CH,EQ,C' ',OR,
08,06,CH,EQ,C' ')
|
|
I agree with you if we use INCLUDE there is no need of IFTHEN.
It's my bad that I did a copy paste for sort card from previous post and added INCLUDE
Regards,
Chandan |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
chandan.inst,
Well thought out.
abraralum,
Code: |
OPTION COPY
INCLUDE COND=(01,06,SS,EQ,C' ',
OR,08,06,SS,EQ,C' ')
OUTREC IFTHEN=(WHEN=(01,06,SS,EQ,C' '),
OVERLAY=(01:C'111111'),HIT=NEXT),
IFTHEN=(WHEN=(08,06,SS,EQ,C' '),
OVERLAY=(08:C'111111'))
|
This input:
Code: |
12345 1
012345 012345 2
012345 01 345 3
12345 4
987654 012345 5
98 654 012945 6
12345 7
8
|
Produces this output:
Code: |
111111 111111 1
012345 111111 3
111111 111111 4
111111 012945 6
111111 111111 7
111111 111111 8 |
EDIT: Crossed-in-the-post
chandan.inst, even weller thought out :-)
Further EDIT: As earlier viewers would have realised, this is not tested.
Further EDIT: Testing is great. Code changed significantly. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
Quote: |
Now, since my Input has the millions of records, its not quite easy to find whether the value changed or not in O/P.
Any suggestion/pointer please |
did You ever hear about testing on a subset of the data ?
no need to use the full dataset ...
for example
using Chandan snippet extract a small subset of the data
process the subset using the overlay suggested
and look at the output
a few thousandths record should be easily browsable |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
Thanks Bill |
|
Back to top |
|
|
abraralum
New User
Joined: 19 Dec 2010 Posts: 42 Location: Bangalore
|
|
|
|
Thanks All ... |
|
Back to top |
|
|
|