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
 

 

INREC and IFTHEN combination not working as desired

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Raymond Sachs

New User


Joined: 13 Dec 2007
Posts: 45
Location: USA

PostPosted: Tue Mar 06, 2012 12:25 pm    Post subject: INREC and IFTHEN combination not working as desired
Reply with quote

Dear Listers,

I want to look for 'L' and replace it with a zero (0). The Character
'L' can occur only between 6 and 9 positions. We are a SYNCSORT shop.
Input file: FB
Code:
************************
ABCD LLLGHIJ  1990-12-31
ABCD FLLGHIJ  2010-12-31
ABCD LFGGHIJ  1993-12-31
ABCD UFFGHIJ  1999-12-31
ABCD LLLLHIJ  2009-12-31
************************


I tried to use the following cards
Code:
//SYSIN     DD *                                         
   SORT FIELDS=COPY                                     
   INREC IFTHEN=(WHEN=(6,1,CH,EQ,C'L'),OVERLAY=(6:C'0')),
         IFTHEN=(WHEN=(7,1,CH,EQ,C'L'),OVERLAY=(7:C'0')),
         IFTHEN=(WHEN=(8,1,CH,EQ,C'L'),OVERLAY=(8:C'0')),
         IFTHEN=(WHEN=(9,1,CH,EQ,C'L'),OVERLAY=(9:C'0'))


Output is not what I desired. It seems only the first occurrence of 'L'
is being replaced.
Code:
************************
ABCD 0LLGHIJ  1990-12-31
ABCD F0LGHIJ  2010-12-31
ABCD 0FGGHIJ  1993-12-31
ABCD UFFGHIJ  1999-12-31
ABCD 0LLLHIJ  2009-12-31
************************


What I require is
Code:
************************
ABCD 000GHIJ  1990-12-31
ABCD F00GHIJ  2010-12-31
ABCD 0FGGHIJ  1993-12-31
ABCD UFFGHIJ  1999-12-31
ABCD 0000HIJ  2009-12-31
************************


Any pointers or help will be greatly appreciated
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7254

PostPosted: Tue Mar 06, 2012 12:55 pm    Post subject: Reply to: INREC and IFTHEN combination not working as desire
Reply with quote

To get multiple matches from IFTHEN with and expression, you need HIT=NEXT so that the next IFTHEN will be processed for that record. For your case, you'll need three of them.

You might check if your Syncsort has FINDREP (find and replace).
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Tue Mar 06, 2012 12:56 pm    Post subject: Reply to: INREC and IFTHEN combination not working as desire
Reply with quote

HI Raymond Sachs,

Try the below code. Added " HIT=NEXT " to your code.

Code:

SORT FIELDS=COPY                                                 
   INREC IFTHEN=(WHEN=(6,1,CH,EQ,C'L'),OVERLAY=(6:C'0'),HIT=NEXT),
         IFTHEN=(WHEN=(7,1,CH,EQ,C'L'),OVERLAY=(7:C'0'),HIT=NEXT),
         IFTHEN=(WHEN=(8,1,CH,EQ,C'L'),OVERLAY=(8:C'0'),HIT=NEXT),
         IFTHEN=(WHEN=(9,1,CH,EQ,C'L'),OVERLAY=(9:C'0'))



Your expected Output :-

Code:

ABCD 000GHIJ  1990-12-31
ABCD F00GHIJ  2010-12-31
ABCD 0FGGHIJ  1993-12-31
ABCD UFFGHIJ  1999-12-31
ABCD 0000HIJ  2009-12-31



Or you can use FINDREP.

Code:

SORT FIELDS=COPY                                         
  OUTREC FINDREP=(INOUT=(C'L',C'0'),STARTPOS=6,ENDPOS=9)


Thanks
-3nadh
Back to top
View user's profile Send private message
Raymond Sachs

New User


Joined: 13 Dec 2007
Posts: 45
Location: USA

PostPosted: Tue Mar 06, 2012 1:14 pm    Post subject:
Reply with quote

Bill/Bodatrinadh,

The HIT=NEXT syntax worked. That is exactly what I wanted.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SCRNAME not working on my mainframe? mrsidhu12 TSO/ISPF 7 Thu Sep 01, 2016 2:17 pm
No new posts 2 same CLIST pgm but with different n... boyti ko CLIST & REXX 5 Fri Jun 03, 2016 4:55 pm
No new posts REXX Screen not working due to LINKED... sundarkudos CLIST & REXX 1 Mon May 09, 2016 1:44 pm
No new posts Free FILE not working for specific users sankalp-goyal CLIST & REXX 12 Mon Apr 25, 2016 6:33 pm
No new posts What does this INREC do? Lino Pontes DFSORT/ICETOOL 5 Fri Apr 08, 2016 12:17 am


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