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 

To update a file using SORT

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


Joined: 27 Nov 2008
Posts: 31
Topics: 9
Location: India

PostPosted: Wed Aug 31, 2011 1:48 pm    Post subject: To update a file using SORT Reply with quote

Hi,
The requirement is to update a file using the contents of other.
For example
File 1 has the below contents:

Code:

............PART 12....
............................


File 2 has the below contents:


Code:

.........
PART 12
........


Is it possible using SORT that we check the contents of File 1 i.e "PART 12" and depending upon that we change the contents of the File 2.

Here the value PART 12 is changing. it it could PART 11/PART 13/PART 14.
But the position is fixed.

Any help would be appreciated.
PS.: I donot want to use any COBOL program.

Thanks!!!
Lenovo
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Wed Aug 31, 2011 2:04 pm    Post subject: Reply with quote

Post a more complete example of the input files and the output you want when the process is run.
_________________
All the best,

di
Back to top
View user's profile Send private message
lenovo
Beginner


Joined: 27 Nov 2008
Posts: 31
Topics: 9
Location: India

PostPosted: Wed Aug 31, 2011 2:37 pm    Post subject: Reply with quote

Hi,

Hope I explain well this time. Apologies if I was not in the earlier case.


Input:
------
File 1 has below contents: size=80 bytes/FB

<some data> PART 12
<some data>


Here PART 12 starts from position 48. And there is only one PART in the whole file.

Output:
------
File 2 has below contents: size=80 bytes/FB

<static data>
PART 12
<static data>

Here PART 12 starts from 1st position in the third line. And there is only one PART in the whole file.


Only the number 12 after PART is changing. i.e. It could be 12/13/14/15.

Now, what I wants is that the utility should read file 1 and search PART and then pick the number after the PART
and then replace the part number in the second file.
Back to top
View user's profile Send private message
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Wed Aug 31, 2011 2:43 pm    Post subject: Reply with quote

lenovo,
Use code tags and please show few samples of Input records from both the file and expected output.

What do you mean by "there is only one PART in the whole file"? Did you mean only one PART value (i.e. part13,14,15 etc)?

What is the common key for both the files?

Thanks,
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: Wed Aug 31, 2011 2:51 pm    Post subject: Reply with quote

Lenovo,

If I understand correctly what you want, then a DFSORT job like the following will do it:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file1 (FB/80)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
  OPTION COPY
  INCLUDE COND=(48,5,CH,EQ,C'PART ')
  INREC BUILD=(C'NEWNUM,''',53,2,C'''',80:X)
/*
//S2 EXEC PGM=SORT
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file2 (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=(1,5,CH,EQ,C'PART'),OVERLAY=(6:NEWNUM))
/*

_________________
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
lenovo
Beginner


Joined: 27 Nov 2008
Posts: 31
Topics: 9
Location: India

PostPosted: Wed Aug 31, 2011 2:53 pm    Post subject: Reply with quote

Hi All,
Thanks for the quick reponses.
@Frank:
Quote:

Can file1 have 'PART xx' whereas file2 always has 'PART 12', and 'PART 12' in file2 should be changed to 'PART xx' ?


Yes Frank, I want this thing only. Since the PART number in File 1 keeps on changing and we want the changed part number to be updated in File 2.
Back to top
View user's profile Send private message
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Wed Aug 31, 2011 3:25 pm    Post subject: Reply with quote

Alternatively you could try below...I have used XX in file1 to indicate any number.
Code:
//STEP0001     EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                           
//SORTJNF1 DD *                                                 
                                                                 
                                               PART XX           
                                                                 
//SORTJNF2 DD *                                                 
PART 12                                                         
PART 13                                                         
PART 13                                                         
PART 14                                                         
PART 14                                                         
PART 14                                                         
PART 15                                                         
PART 15                                                         
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  JOINKEYS FILES=F1,FIELDS=(48,04,A),SORTED,NOSEQCK             
  JOINKEYS FILES=F2,FIELDS=(01,04,A),SORTED,NOSEQCK             
  REFORMAT FIELDS=(F2:01,80,F1:48,7)                             
  INREC OVERLAY=(1:81,7)                                         
  OPTION COPY                                                   
  OUTFIL BUILD=(1,80)                                           
/*                                                               
//JNF1CNTL DD *                                                 
  INCLUDE COND=(48,5,CH,EQ,C'PART ')                             
/*

OUTPUT
Code:
PART XX   
PART XX   
PART XX   
PART XX   
PART XX   
PART XX   
PART XX   
PART XX   

Thanks,
Back to top
View user's profile Send private message
lenovo
Beginner


Joined: 27 Nov 2008
Posts: 31
Topics: 9
Location: India

PostPosted: Wed Aug 31, 2011 3:49 pm    Post subject: Reply with quote

Hi All,
@Frank: Thanks a million. It works fine.
@Sqlcode : Did not get a chance to to test this one. Thanks a lot for your efforts.

Your quick replies are really appreciated!!!
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: Wed Aug 31, 2011 6:50 pm    Post subject: Reply with quote

sqlcode,

As far as I can tell, that only works if every input file 2 record has PART in positions 1-4. But that doesn't match the OP's description of file 2 as:

Quote:

File 2 has below contents: size=80 bytes/FB

<static data>
PART 12
<static data>

Here PART 12 starts from 1st position in the third line. And there is only one PART in the whole file.


When I changed SORTJNF2 in your job to:

//SORTJNF2 DD *
<STATIC DATA>
PART 12
<STATIC DATA>

The output was just:

PART 11

It drops the other records. I don't think that's what the OP wanted.

With the same input file 2 records for my job, the output is:

<STATIC DATA>
PART 11
<STATIC DATA>
_________________
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
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Wed Aug 31, 2011 8:50 pm    Post subject: Reply with quote

Frank,
Yeah, it wouldn't work.

As always thanks for correcting my mistake.

Thanks,
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Sat Sep 03, 2011 7:03 am    Post subject: Reply with quote

But..how do you audit these changes?
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Sat Sep 03, 2011 6:37 pm    Post subject: Reply with quote

Audit - we don' need no steenkin' audit. . .

Using this method, we can sneak anything we want info the file - and remove it later. . .

"Who knows what evil lurks in the hearts of men"

heh heh heh

di
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