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 

Replacing characters in a record

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


Joined: 23 Mar 2005
Posts: 19
Topics: 6

PostPosted: Wed Mar 23, 2005 1:24 pm    Post subject: Replacing characters in a record Reply with quote

So here's my dilemma. I have a file which is too large to simply edit. I have a single record in that file in which I need to change one value. I have the file layout, and criteria on which to find the file (three fields). Based on a match of these three fields, I need to change the value in a fourth field from x to y.
I was wondering if there is any way to do this in a single sort, and if so, how? This is something that I need to have done today to several files and it would be much easier to use a sort than to write a COBOL program to do this. It would also be a useful tool for the future for my colleagues & I.

Thanks,
_________________
Robert Tighe
Legacy Systems Analyst
Keane Canada, Inc.
Robert_F_Tighe@keane.com
Back to top
View user's profile Send private message MSN Messenger
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Wed Mar 23, 2005 2:00 pm    Post subject: Reply with quote

You can do this quite easily with the new IFTHEN and OVERLAY parameters of DFSORT's INREC, OUTREC or OUTFIL statement available with z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004). For complete information on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/

You didn't give any details, so I'll set up an example to give you the idea.

If you want to find a record that has 'XX' in positions 5-6 and 'Y' in position 10 and 'ZAB' in positions 15-17, and change positions 20-22 in that record to 'YES', you can use the following DFSORT job:

Code:

//S1    EXEC  PGM=ICEMAN                                       
//SYSOUT    DD  SYSOUT=*                                       
//SORTIN DD *                                                 
R01 XQ   Y    ZAB  NOO                                         
R02 XX   Y    ZAB  NOO                                         
R03 XX   Z    ZAB  NOO                                         
R04 XX   Y    ZAC  NOO           
/*                             
//SORTOUT DD SYSOUT=*                                         
//SYSIN    DD    *                                             
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=(5,2,CH,EQ,C'XX',AND,10,1,CH,EQ,C'Y',AND, 
   15,3,CH,EQ,C'ZAB'),OVERLAY=(20:C'YES'))                     
/*


SORTOUT would have:

Code:

R01 XQ   Y    ZAB  NOO
R02 XX   Y    ZAB  YES
R03 XX   Z    ZAB  NOO
R04 XX   Y    ZAC  NOO


Note that you can use any INCLUDE condition for WHEN, so the criteria can be simple or very complex.

If you need help with a specific example, give me the details.
_________________
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
tiggy
Beginner


Joined: 23 Mar 2005
Posts: 19
Topics: 6

PostPosted: Wed Mar 23, 2005 2:05 pm    Post subject: Reply with quote

This is awesome, that's exactly what I'm looking for. Thanks so much. I'll be sure to put more detail next time.

Thanks again.
_________________
Robert Tighe
Legacy Systems Analyst
Keane Canada, Inc.
Robert_F_Tighe@keane.com
Back to top
View user's profile Send private message MSN Messenger
tiggy
Beginner


Joined: 23 Mar 2005
Posts: 19
Topics: 6

PostPosted: Wed Mar 23, 2005 2:33 pm    Post subject: Reply with quote

I think I spoke too soon. I tried what you gave me:
Code:

//SORT01   EXEC PGM=ICEMAN                                   
//SORTIN   DD  DISP=SHR,DSN=T0J0H7T.SHR.PLS.CXC014.MSTR.RYR16
//SORTOUT  DD  DSN=T0J0H7T.SHR.PLS.CXC014.MSTR.RYR16.MOD,     
//             DISP=(NEW,CATLG,DELETE),                       
//             UNIT=(SYSDA,3),SPACE=(CYL,(222,222),RLSE)     
//SYSIN    DD  *                                             
   OPTION COPY                                                 
   INREC IFTHEN=(WHEN=(1,17,CH,EQ,C'5TDZA22C05S257526',       
    AND,26,8,CH,EQ,C'20050204',AND,                           
    56,5,CH,EQ,C'32097'),OVERLAY=(34:C'999'))                 
/*                                                           
//SYSOUT   DD  SYSOUT=*                                       
//SYSPRINT DD  SYSOUT=*                                       
//SORTPTNT DD  SYSOUT=*                                       
//SYSUDUMP DD  SYSOUT=D                                       

and now I'm getting a return code  RC=0016:
ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                               
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AND MORE
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 11:30 ON WED MAR 23, 2005 -
           OPTION COPY                                                         
             INREC IFTHEN=(WHEN=(1,17,CH,EQ,C'5TDZA22C05S257526',             
                   $                                                           
ICE104A 0 INVALID INREC OR OUTREC STATEMENT OPERAND                           
              AND,26,8,CH,EQ,C'20050204',AND,                                 
              $                                                               
ICE005A 0 STATEMENT DEFINER ERROR                                             
              56,5,CH,EQ,C'32097'),OVERLAY=(34:C'999'))                       
              $                                                               
ICE007A 0 SYNTAX ERROR                                                         
ICE012A 2 MISSING FIELDS OPERAND DEFINER                                       
ICE751I 0 C5-BASE   C6-BASE   C7-BASE   C8-Q83041 E7-BASE                     
ICE052I 3 END OF DFSORT                               


Any suggestions?
_________________
Robert Tighe
Legacy Systems Analyst
Keane Canada, Inc.
Robert_F_Tighe@keane.com
Back to top
View user's profile Send private message MSN Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Mar 23, 2005 2:52 pm    Post subject: Reply with quote

Tiggy,

I guess you don't have the latest ptf installed in your shop. here is an alternate way of doing it.

I assuming your input file is 80 bytes in length and is of FB recfm.

Using OUTREC fileds we put the first 17 bytes and 8 bytes from 26 byte and 5 bytes from 56th byte at the end of every record.

Now using a change command on OUTFIL we look it as a single string and change the position at the 34 and copy rest of the bytes upto 80 bytes.

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                                                   
  OUTREC FIELDS=(01,80,                                             
                 01,17,                                             
                 26,8,                                               
                 56,5)                                               
  OUTFIL OUTREC=(1,33,                                               
                34:81,30,CHANGE=(3,C'5TDZA22C05S2575262005020432097',
                                   C'999'),NOMATCH=(34,3),           
                37,44)                                               
                                       
/*


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
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Wed Mar 23, 2005 3:15 pm    Post subject: Reply with quote

Tiggy,

The error messages indicate you don't have DFSORT's Dec, 2004 PTF installed. Ask your System Programmer to install it (it's free).

Note that the method using CHANGE that Kolusu shows works when the criteria involves matching a set of character strings, but becomes problematical when the criteria is more complex such as when it involves numeric comparisons (ZD field gt +250), or when OR must be used ((A OR B OR C) AND D), etc). IFTHEN can handle all of these cases!
_________________
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
tiggy
Beginner


Joined: 23 Mar 2005
Posts: 19
Topics: 6

PostPosted: Wed Mar 23, 2005 3:25 pm    Post subject: Reply with quote

Great, thanks for all your time and help, the two of you. This has been a great help and very educational. I really appreciate it.

Thanks,
_________________
Robert Tighe
Legacy Systems Analyst
Keane Canada, Inc.
Robert_F_Tighe@keane.com
Back to top
View user's profile Send private message MSN Messenger
rishikesh_u
Beginner


Joined: 26 Jul 2004
Posts: 5
Topics: 3

PostPosted: Wed Mar 30, 2005 6:06 am    Post subject: Reply with quote

Kolusu,

Tried the sort option as given by you and it's working fine. But i am not very clear how this is acheived.

What is the need of "Using OUTREC fileds we put the first 17 bytes and 8 bytes from 26 byte and 5 bytes from 56th byte at the end of every record."

and can you also explain how the below works and how did you arrive at
C'5TDZA22C05S2575262005020432097'.

OUTFIL OUTREC=(1,33,
34:81,30,CHANGE=(3,C'5TDZA22C05S2575262005020432097',
C'999'),NOMATCH=(34,3),
37,44)

your reply is highly appreciable..

Thanks,
Back to top
View user's profile Send private message AIM Address
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Mar 30, 2005 7:19 am    Post subject: Reply with quote

Rishikesh_u,

The orginal poster wanted to validate 3 fileds at different locations and change another field. Using Outrec fields I put the 3 fields together at the end of every record, so that he can validate the 3 fields as one single field.

Quote:

and can you also explain how the below works and how did you arrive at
C'5TDZA22C05S2575262005020432097'.


Look at 4th post from top in this topic. He was checking for

Code:

1,17,CH,EQ,C'5TDZA22C05S257526',AND,
26,8,CH,EQ,C'20050204',AND,
56,5,CH,EQ,C'32097'),


I just put the 3 field together and validated as single string
Code:

C'5TDZA22C05S2575262005020432097'. 


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
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