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
 

 

Mearging files with resequencing
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Mearging files with resequencing
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: 8593
Location: Back in jolly old England

PostPosted: Wed Jun 09, 2010 4:20 pm    Post subject:
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    Post subject: Reply to: Mearging files with resequencing
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: 8593
Location: Back in jolly old England

PostPosted: Wed Jun 09, 2010 5:08 pm    Post subject:
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    Post subject: Reply to: Mearging files with resequencing
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    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Wed Jun 09, 2010 7:33 pm    Post subject:
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    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Wed Jun 09, 2010 8:02 pm    Post subject:
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

Senior Member


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

PostPosted: Wed Jun 09, 2010 8:35 pm    Post subject:
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    Post subject: Reply to: Mearging files with resequencing
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Jun 10, 2010 12:29 pm    Post subject: Reply to: Mearging files with resequencing
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Jun 10, 2010 12:46 pm    Post subject: Reply to: Mearging files with resequencing
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    Post subject:
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    Post subject: Reply to: Mearging files with resequencing
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Jun 10, 2010 1:15 pm    Post subject: Reply to: Mearging files with resequencing
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    Post subject:
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    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Adding records from two files into on... shiitiizz SYNCSORT 4 Mon Sep 19, 2016 8:41 pm
No new posts Icetool or Joinkeys example to compar... ishant chauhan DFSORT/ICETOOL 21 Sat Aug 20, 2016 2:40 am


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