IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Mearging files with resequencing


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gaurav Bhayawala

New User


Joined: 17 Apr 2008
Posts: 14
Location: Pune

PostPosted: Wed Jun 09, 2010 4:11 pm
Reply with quote

I want to merge 3 Files. Files data are as follow
(Second field of each record in SEQ-NO)

File - 1
xxxx 001 yyyy zzzzz
aaaa 002 bbbb ccccc
-
-
-
oooo 099 pppp qqqq
xxxx 100 pppp ssss
----------------------------
File - 2
nnnn 001 mmm oooo
aaaa 002 qqqq ccccc
-
-
-
oooo 049 ZZZZ qqqq
xxxx 050 SSSS DDD
----------------------------
File - 3
PPPP 001 mmm oooo
ZZZZ 002 qqqq ccccc
-
-
-
BBBB 049 ZZZZ qqqq
YYYY 060 SSSS DDD

I want o/p file - Which merge all above 3 files & resequence the SEQ-NO field. So o/p should be look like as follow.

xxxx 001 yyyy zzzzz
aaaa 002 bbbb ccccc
-
-
-
oooo 099 pppp qqqq
xxxx 100 pppp ssss
nnnn 101 mmm oooo
aaaa 102 qqqq ccccc
-
-
-
oooo 149 ZZZZ qqqq
xxxx 150 SSSS DDD
PPPP 151 mmm oooo
ZZZZ 152 qqqq ccccc
-
-
-
BBBB 209 ZZZZ qqqq
YYYY 210 SSSS DDD

Please provide me any way to solve this.
I want it to solve throug SORT. Please help to resolve it...
(Here no of records in input files are not known... Above is just taken as example...)
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Jun 09, 2010 4:20 pm
Reply with quote

Because the solution for sort related questions may vary from product to product, please ensure that you state clearly which sort product you are using.

If you are not sure, then by running a simple sort step shown below, you will be able to find out for yourself.

If the messages start with ICE then your product is DFSORT. Please also post the output of the complete line which has a message code ICE201I, as this will enable our DFSORT experts to determine which release of DFSORT that you have installed. This may also affect the solution offered.

If the messages start with WER or SYT then the product is SYNCSORT and the topic will be moved into the JCL forum by one of the moderators. Please also post the information telling which version of SYNCSORT is installed, as this may also affect the solution offered.

Thank you for taking your time to ensure that the valuable time of others is not wasted by offering inappropriate solutions which are not relevant due to the sort product being used and/or the release that is installed in your site.

Code:
//SORTSTEP EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
ABC
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  SORT     FIELDS=COPY


You also need to provide more detail than you already have.
The RECFM & LRECL of the input and output files.
The position, length and format of the key fields.
Back to top
View user's profile Send private message
Gaurav Bhayawala

New User


Joined: 17 Apr 2008
Posts: 14
Location: Pune

PostPosted: Wed Jun 09, 2010 4:45 pm
Reply with quote

Hi expat,

Message starts with WER - so it is SYNCSORT

SYNCSORT FOR Z/OS 1.3.2.1R U.S. PATENTS: 4210961, 5117495 (C) 2007 SYNCSORT INC. z/OS 1.9.0

Please find the version from above. I am not sure abt it.

Regarding file details
RECFM = Fixed (for both i/p & o/p files)
LRECL = 2742 (for both i/p & o/p files)

Key format = PIC 9(09)
Position = 4 to 12 (length = 9 bytes)

Regards,
Gaurav
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Jun 09, 2010 5:08 pm
Reply with quote

As far as I can see, all you need to do is to sort on the key position, with your three files concatenated as SORTIN.
Back to top
View user's profile Send private message
Gaurav Bhayawala

New User


Joined: 17 Apr 2008
Posts: 14
Location: Pune

PostPosted: Wed Jun 09, 2010 5:18 pm
Reply with quote

Hi expat,

Three files concatenated as SORTIN is fine. But I want the key (SEQ-NO) of 2nd & 3rd files to be resequenced in output files (Please refer my question above)

Better if you provide the sollution with taking any similar example...

Regards,
Gaurav.
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Wed Jun 09, 2010 5:34 pm
Reply with quote

Gaurav , i think expact gave you the correct reply , just concatenate and sort on ur sequence number,

assuming that ur sequence number starts from position 6 (in all 3 files)

//R010 EXEC PGM=SORT,COND=(0,NE)
//SORTIN DD DSN=XXXX,DISP=SHR
// DD DSN=YYYY,DISP=SHR
// DD DSN=ZZZZ,DISP=SHR
//SORTOUT DD DSN=ANS,DISP=(,CATLG,DELETE)
//SYSIN DD *
SORT FIELDS=(6,3,CH,A)
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*

u can use the above code. If i had misunderstood your question , please do correct me.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Jun 09, 2010 7:33 pm
Reply with quote

Wouldn't a simple COPY of the concatenated datasets with an inrec/outrec overlay of the old sequence number with a SEQNUM be what the OP is looking for?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jun 09, 2010 7:49 pm
Reply with quote

CICS Guy wrote:
Wouldn't a simple COPY of the concatenated datasets with an inrec/outrec overlay of the old sequence number with a SEQNUM be what the OP is looking for?

That would depend on what the OP means by merge!
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Jun 09, 2010 8:02 pm
Reply with quote

Craq Giegerich wrote:
That would depend on what the OP means by merge!
Judging from the provided inputs and expected output, it seems fairly clear that he wants them concatenated and the old sequence number re-sequenced......
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Jun 09, 2010 8:35 pm
Reply with quote

Well, I got to agree with Craig, MERGE is something used (and means) quite differently in this very forum.
Back to top
View user's profile Send private message
Gaurav Bhayawala

New User


Joined: 17 Apr 2008
Posts: 14
Location: Pune

PostPosted: Thu Jun 10, 2010 10:53 am
Reply with quote

Hi cvishu,

I tried your solution. But it just resequences record but doesn't change the key.

As per your suggestion.. I am getting below output.

xxxx 001 yyyy zzzzz
nnnn 001 mmm oooo
PPPP 001 mmm oooo
aaaa 002 bbbb ccccc
aaaa 002 qqqq ccccc
ZZZZ 002 qqqq ccccc
-
-
-

But in actual I want the output as follow. I want key (SEQ-NO) of 2nd & 3rd file should be changed in o/p file.

xxxx 001 yyyy zzzzz
nnnn 002 mmm oooo
PPPP 003 mmm oooo
aaaa 004 bbbb ccccc
aaaa 005 qqqq ccccc
ZZZZ 006 qqqq ccccc
-
-
-

Please provide the required solution.
If it is possible thru INREC / OUTREC.. Please provide any example.. so I can try it for my scenarion...

Hoping the answer from you...

Regards,
Gaurav.
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Thu Jun 10, 2010 12:20 pm
Reply with quote

Hi Guarav,

Please check the below sort card -
Code:
INREC FIELDS=(01:01,03,04:SEQNUM,09,ZD,13:13,2730)
SORT FIELDS=(04,09,ZD,A)


I think this will give you the result you are looking for.
Let me know in case this does not gives desired result.

Thanks.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jun 10, 2010 12:29 pm
Reply with quote

why sort... and not use a plain OPTION COPY
a copy of the concatenation of the three dataset would be more than enough ...
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Thu Jun 10, 2010 12:43 pm
Reply with quote

Hi enrico,

The records will be concatenated but I think what gaurav needs is to increament the key field also ( if 1st file has seq-no till 100, in merged file seqno for the records of 2nd file must start wid 101)

I am not sure is this can be achieved with concatenation.
Please correct with if am wrong.

Thanks.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jun 10, 2010 12:46 pm
Reply with quote

a sequence number generated by sort will be ascending by definition and will make useless a sort on the same sequence number
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Thu Jun 10, 2010 12:56 pm
Reply with quote

Hi enrico,

Yes you are right. Even if we use the sort card -

Code:
INREC FIELDS=(01:01,04,05:SEQNUM,03,ZD,08:08,09)
SORT FIELDS=COPY                               


It will give the same result.
But was wondering can we achieve the seq-no just by simple concatenation.
Back to top
View user's profile Send private message
Gaurav Bhayawala

New User


Joined: 17 Apr 2008
Posts: 14
Location: Pune

PostPosted: Thu Jun 10, 2010 12:59 pm
Reply with quote

Hi anshul_gugnani ,
Your followimg suggestion has solved my problem.... Thanks buddy...

INREC FIELDS=(01:01,03,04:SEQNUM,09,ZD,13:13,2730)
SORT FIELDS=(04,09,ZD,A)

Thanks all for your valuable inputs....

Regards,
Gaurav.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jun 10, 2010 1:15 pm
Reply with quote

there is a language barrier here...
dataset concatenation will simply copy the datasets in the sequence given by the concatenation order...
records from the first file
records from the second file

and so on and so on

modifying as in this case the content of the records is a different show

...

suggestion for the TS
use SORT FIELDS COPY ... no use in sorting an already sorted file
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Thu Jun 10, 2010 2:09 pm
Reply with quote

anshul ,

Your SEQ number concept is correct , but the only thing is we need to first concatenate and sort the input as it it , and then the sequence number genration has to be done for the resultant output .

So gauvravu , u need to combine both the steps that i gave and ansul gave and u get your output.

Step1 : Concatenate and sort on ur key
step2 : Generate the sequence number and replace ur KEY with it .

Do let me know if this doesnt works.

PS (this is not necessiarily the only solution u are welcome to share better ideas)
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Thu Jun 10, 2010 2:50 pm
Reply with quote

Hi cvishu,

Looking at the sample input output which guarav posted, I thnk the input is not sorted,just merged and seq nos are replaced.
So provided that solution.
icon_smile.gif
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Thu Jun 10, 2010 4:56 pm
Reply with quote

Isn't this a simple first 'occurence' wins situation?
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Thu Jun 10, 2010 5:03 pm
Reply with quote

anshul , sorry i dint notice icon_exclaim.gif , you are correct icon_biggrin.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Jun 10, 2010 6:05 pm
Reply with quote

Quote:
Chanin Smoker => "I hate cigaretes .... thats why i burn them down "

There s always a smater way to express urself
But one should not advocate for wrong things ! (Well, let's don't talk about "perception" here, some things are beyond that because they are facts.)
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jun 10, 2010 6:21 pm
Reply with quote

Quote:
Step1 : Concatenate and sort on ur key
step2 : Generate the sequence number and replace ur KEY with it .


the TS request was simply ...
concatenate file1 file2 file 3 and create e unique sequence number
as seen from the example of the output file...

sorting as suggested will mix up the records

so forget about SORTING anything,
any suggestion about sort is ...
1) a misunderstanding of the initial requirement
2) a useless waste of resources in sorting what has already been sorted
( see my previous posts and the replies that follow them )
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Thu Jun 10, 2010 6:49 pm
Reply with quote

enrico,

great pattern recognition!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top