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
 

 

If Space found, replace with value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: If Space found, replace with value
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: 1715
Location: UK

PostPosted: Tue Sep 11, 2012 11:57 am    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 269
Location: Mumbai

PostPosted: Tue Sep 11, 2012 1:26 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Tue Sep 11, 2012 1:27 pm    Post subject: Reply to: If Space found, replace with value
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: 269
Location: Mumbai

PostPosted: Tue Sep 11, 2012 1:34 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Tue Sep 11, 2012 1:42 pm    Post subject: Reply to: If Space found, replace with value
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    Post subject:
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: 269
Location: Mumbai

PostPosted: Tue Sep 11, 2012 1:51 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Tue Sep 11, 2012 1:55 pm    Post subject: Reply to: If Space found, replace with value
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Sep 11, 2012 1:59 pm    Post subject: Reply to: If Space found, replace with value
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: 269
Location: Mumbai

PostPosted: Tue Sep 11, 2012 2:08 pm    Post subject:
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    Post subject:
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    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 Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Need a help how to replace a string i... gurunath82 CLIST & REXX 12 Tue Jul 26, 2016 11:43 pm
No new posts Difference space showed for TS and it... autobox DB2 1 Thu Apr 14, 2016 1:07 pm


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