MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Change - Based on two conditions

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
sasubashri
Beginner


Joined: 20 May 2003
Posts: 15
Topics: 7

PostPosted: Tue Jan 06, 2004 6:36 am    Post subject: Change - Based on two conditions Reply with quote

Hi,

I have a requirement wherein I have to replace ## in positions 98-99
with // if
1) positons 98-99 have a ## and
2) positions 1-3 have 4RB or 001

else the original value should be retained.

Can we do this in a single control statement ?
Can any one tell me how to do this.
_________________
Thanks,
Subashri.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jan 06, 2004 9:00 am    Post subject: Reply with quote

Subasri,

It would be helpful if you supplied more info like LRECL , RECFM and sample of input data and desired output.

Any way I am assuming that your input file is having LRECL of 100 and is of FB recfm.

The following JCL will give you desired results.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=* 
//SORTIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//SORTOUT  DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *
  SORT FIELDS=COPY                                                 
  OUTFIL OUTREC=(1,97,                                             
     98:1,3,CHANGE=(2,                                             
                C'001',C'//',      * CHANGE TO // WHEN '001'       
                C'4RB',C'//'),     * CHANGE TO // WHEN '4RB'       
                NOMATCH=(98,2),    * ORGINAL VALUE WHEN NOT MATCHED
                99,2)              * REST OF THE FIELDS         
/*     


Hope this helps...

cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ofer71
Intermediate


Joined: 12 Feb 2003
Posts: 358
Topics: 4
Location: Israel

PostPosted: Tue Jan 06, 2004 10:57 am    Post subject: Reply with quote

Here is a rexx solution:
Code:

/* REXX */

ADDRESS TSO "ALLOC FI(T) DA('your.input.file') SHR"
            "EXECIO * DISKR T (STEM LINE. FINIS"

DO I = 1 TO LINE.0
  IF SUBSTR(LINE.I,98,2) = '##' & (SUBSTR(LINE.I,1,3) = '4RB' | (SUBSTR(LINE.I,1,3) = '001') THEN
    LINE.I = OVERLAY('//',LINE.I,98,2)
END

ADDRESS TSO "EXECIO * DISKW T (STEM LINE. FINIS"
            "FREE FI(T)"

EXIT


O.
________
MARY JANE


Last edited by ofer71 on Thu Mar 17, 2011 10:36 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Unspec
Beginner


Joined: 02 Dec 2002
Posts: 6
Topics: 1
Location: Nottingham

PostPosted: Tue Jan 06, 2004 11:33 am    Post subject: Reply with quote

Kolusu,

Strangely enough, I checked this board today because I have a very similar requirement to the one described by sasubashri.

This is how I understood sasubashri's problem in pseudo-code:-

Change (98,2) to '//' if
((98,2) EQUALS '##') AND ((1,3) EQUALS '001' OR (1,3) EQUALS '4RB')

I think that your solution will change (98,2) without any regard to its original value. I doubt whether there is a SORT solution to the problem as I understood it but, if there is, I'd be very grateful.

Sorry if I've completely misunderstood the original problem, by the way.


Last edited by Unspec on Tue Jan 06, 2004 11:52 am; edited 1 time in total
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Jan 06, 2004 11:42 am    Post subject: Reply with quote

Subashri said
Quote:
I have a requirement wherein I have to replace ## in positions 98-99 with // if
1) positons 98-99 have a ## and
2) positions 1-3 have 4RB or 001


Kolusu,

Your job satisfies condition 2, but not condition 1. It will put // in 98-99 even if 98-99 does not have ##.

Here's a DFSORT job that will satisfy BOTH conditions:

Code:

//S1    EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=...   input file                         
//SORTOUT  DD DSN=...  output file                                       
//SYSIN    DD *                                                 
  OPTION COPY           
* Copy 98-88 and 1-3 to 101-105                                       
  INREC FIELDS=(1,100,101:98,2,1,3)                             
  OUTREC FIELDS=(1,97,                                         
* CHANGE 98-99 TO // IF 101-105 HAS ##001 OR ##4RB.   
* OTHERWISE, KEEP 98-99.                                       
     98:101,5,CHANGE=(2,                                       
                C'##001',C'//',                                 
                C'##4RB',C'//'),                               
              NOMATCH=(98,2),                                 
      100,1)                                         
/*                                                             


For example, if the input is as follows:

Code:

4RB  R01 ... ##
001  R02 ... ##
002  R03 ... ##
5RB  R04 ... ##
001  R05 ... A#
4RB  R06 ... #A


The output for this job would be:

Code:

4RB  R01 ... //
001  R02 ... //
002  R03 ... ##
5RB  R04 ... ##
001  R05 ... A#
4RB  R06 ... #A

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jan 06, 2004 11:59 am    Post subject: Reply with quote

Frank,

Thanks for pointing out the error. I guess I have interpreted the question wrong. I assumed that pos 98-99 will always have ## for the records whose first 3 bytes is 001 or 4RB. I apologize for the bad assumption

Thanks

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Wed Jan 07, 2004 12:41 am    Post subject: Reply with quote

Nice post, I am getting fascinated by powers of sort.
Back to top
View user's profile Send private message Send e-mail
sasubashri
Beginner


Joined: 20 May 2003
Posts: 15
Topics: 7

PostPosted: Wed Jan 07, 2004 1:51 am    Post subject: Reply with quote

Hi All,

Thanks a lot for your time.

The solution works fine for me.

Thanks,
Subashri. Smile
_________________
Thanks,
Subashri.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group