Merge files from LISTCAT



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Merge files from LISTCAT

Postby Papya013 » Tue Mar 22, 2016 9:42 am

Hi Team,

I have below mentioned data in a PS file created from LISTCAT.

DD DSN=FILE1.ABC
DD DSN=FILE2.ABC
DD DSN=FILE3.ABC
DD DSN=FILE4.ABC



Could you please let me know how we can merge all the above mentioned files.
Papya013
 
Posts: 35
Joined: Wed Nov 06, 2013 6:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Merge files from LISTCAT

Postby Aki88 » Tue Mar 22, 2016 10:58 am

Hello,

Papya013 wrote:I have below mentioned data in a PS file created from LISTCAT.

DD DSN=FILE1.ABC
DD DSN=FILE2.ABC
DD DSN=FILE3.ABC
DD DSN=FILE4.ABC



Could you please let me know how we can merge all the above mentioned files.


Your query is not clear -
a. Do you have LISTCAT data in the datasets mentioned and you want them 'merged'?
b. These DD statements are the actual data?

1. If point a, then do you want data to be sorted, or you want 1-single-output-DS-with-the-data-from-all-4-files-mentioned?

If you need solution for 'point 1', then a simple SORT FIELDS=COPY with your datasets 'DD concatenated' in SORTIN would do the trick (the 125 is the LRECL of the DS which has LISTCAT data):


//TEST     EXEC PGM=SORT              
//SYSOUT   DD SYSOUT=*                
//SORTIN   DD DISP=SHR,DD DSN=FILE1.ABC
//         DD DISP=SHR,DD DSN=FILE2.ABC
//         DD DISP=SHR,DD DSN=FILE3.ABC
//         DD DISP=SHR,DD DSN=FILE4.ABC
//SORTOUT  DD DSN=<YOUR DSN HERE>,    
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(TRK,(5,5),RLSE),  
//            DCB=RECFM=FB            
//SYSIN    DD *                        
 SORT FIELDS=COPY                      
 OUTFIL REMOVECC,VTOF,                
 BUILD=(1:1,125)                      
/*                                    
 


Hth.
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

Re: Merge files from LISTCAT

Postby Papya013 » Tue Mar 22, 2016 12:16 pm

Hi,

Sorry for little confusion there.

I have those mentioned files in a PS file which was generated from LISTCAT and I want to feed that data to SORTIN so that I get the merged file in SORTOUT.

Could you please help me out with this.
Papya013
 
Posts: 35
Joined: Wed Nov 06, 2013 6:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Merge files from LISTCAT

Postby Aki88 » Tue Mar 22, 2016 1:10 pm

Hello,

Papya013 wrote:I have those mentioned files in a PS file which was generated from LISTCAT and I want to feed that data to SORTIN so that I get the merged file in SORTOUT.


Sorry, but the requirement is still unclear; is it that:
a. You have a PS file with DS names.
b. These individual DS - each have LISTCAT data in them.
c. You want this data from point 'b' to be merged into one single dataset.

If 'the above' is your requirement, then:
1. Are the dataset names you mention, fixed, i.e. you know the dataset names at the time of JCL submission; if Yes, then the earlier post's solution will suffice, simply give the 'known' DSN in the SORTIN, and you're good to go.
2. If the DSN are not known at the time of job submission; and all that is known is this one PS file which contains names of the LISTCAT datasets, then you might want to look at SYMNAMES functionality of DFSORT; generate your JCL dynamically using SYMNAMES by reading your DS which has LISTCAT dataset names in it.
To achieve point 2 you'll need, a SYMNAMES set up, which would generate symbolics for dataset names which would be read from your PS file. Pass these to another SORT wherein you build a JCL using these symbolics; and then route your SORTOUT to INTRDR; this will submit a JCL with the build DFSORT setup that merges the files. Note that, by 'merge' I mean - DD concatenate all your DS and do a SORT FIELDS=COPY.

Word of caution: This solution has many break-points, such as what-if the number of DSN in your PS file are greater than 255; what if the PS file has junk characters in it? Also, the amount of code involved is large.

The challenge here is not merging the DS, but getting the DSN (for your PS file) passed to a program as DD statements.
Another approach can be writing a small COBOL/REXX prog, to drive the JCL build process, simply read the PS file until end-of-file, test each record for valid DSN, and route the valid DS names to a working storage construct, where you already have a JCL hard-coded. Write the final working storage to an output DD statement which routes it to INTRDR. (This is much simpler to code, if you're not very comfortable with DFSORT)

PS: There can be a simpler solution to this, but that would require more brainstorming.

Hth.
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

Re: Merge files from LISTCAT

Postby NicC » Tue Mar 22, 2016 4:32 pm

Is this clearer?
You have a dataset (not a file) which contains the following four lines:
DD DSN=FILE1.ABC
DD DSN=FILE2.ABC
DD DSN=FILE3.ABC
DD DSN=FILE4.ABC


and you want to generate a DFsort job with those four datasets as the input to the sort.

Now, if that is correct - what is the sort process? Merge the datasets i.e. create a single output dataset in key sequence order, or concatenate the datasets i.e. create a single output dataset consisting of dataset file1.abc followed by file2.abc etc (or whatever order the datasets are presented on sortin) or something else? For the latter you could use IEBGENER.

Whatever, you would need a step that would read in your dataset and generate the sort required and submit it via the internal reader.

Example exist in the forum.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post