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

If Space found, replace with value


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abraralum

New User


Joined: 19 Dec 2010
Posts: 42
Location: Bangalore

PostPosted: Tue Sep 11, 2012 11:14 am
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Sep 11, 2012 11:57 am
Reply with quote

OK - you have been trying. What have you come up with that does not work?
Back to top
View user's profile Send private message
abraralum

New User


Joined: 19 Dec 2010
Posts: 42
Location: Bangalore

PostPosted: Tue Sep 11, 2012 12:03 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 11, 2012 12:13 pm
Reply with quote

use SS
Back to top
View user's profile Send private message
abraralum

New User


Joined: 19 Dec 2010
Posts: 42
Location: Bangalore

PostPosted: Tue Sep 11, 2012 12:17 pm
Reply with quote

Thax Dick, I have got it. I will build the rest now.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 11, 2012 12:20 pm
Reply with quote

you are more than welcome.

thank you for showing initiative.
Back to top
View user's profile Send private message
abraralum

New User


Joined: 19 Dec 2010
Posts: 42
Location: Bangalore

PostPosted: Tue Sep 11, 2012 12:51 pm
Reply with quote

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
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Tue Sep 11, 2012 1:26 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Sep 11, 2012 1:27 pm
Reply with quote

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
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Tue Sep 11, 2012 1:34 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Sep 11, 2012 1:42 pm
Reply with quote

chandan.inst,

Why would you think that?

Having thought that, why use the IFTHEN after the INCLUDE?
Back to top
View user's profile Send private message
abraralum

New User


Joined: 19 Dec 2010
Posts: 42
Location: Bangalore

PostPosted: Tue Sep 11, 2012 1:47 pm
Reply with quote

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
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Tue Sep 11, 2012 1:51 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Sep 11, 2012 1:55 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Sep 11, 2012 1:59 pm
Reply with quote

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
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Tue Sep 11, 2012 2:08 pm
Reply with quote

Thanks Bill icon_smile.gif
Back to top
View user's profile Send private message
abraralum

New User


Joined: 19 Dec 2010
Posts: 42
Location: Bangalore

PostPosted: Tue Sep 11, 2012 4:34 pm
Reply with quote

Thanks All ...
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts How I Found a Bug in a FORTRAN Compiler All Other Mainframe Topics 4
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
No new posts To replace jobname in a file with ano... SYNCSORT 12
Search our Forums:

Back to Top