Hi Forum,
I am a newbie here but not to MF. I keep coming here for suggestions and tricks. But this is my first post.
I have a unique usecase where I have to prepare the SYSIN card for an IEBCOPY job. I create two temp files - one for the 'copy operation statement' and the other one for the 'select member' statements. Below are the steps.
//STEP010 EXEC PGM=SORT
//SORTIN DD *
COPYGRP INDD=IN0007,OUTDD=OUT0007
//SORTOUT DD DISP=(,PASS),DSN=&&CPYSTMT
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
//*
//STEP020 EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=XXX.XXX.XXX
//OXXX DD DISP=(,PASS),DSN=&&CPYLST
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=OXXX,
INCLUDE=(15,4,CH,EQ,C'XXXX'),
OUTREC=(1:5X,6:C'S M=((YYYY,',17:1,8,25:C'))',27:54X)
I have to merge these two files to prepare the sysin file that should look like below
COPYGRP INDD=IN0007,OUTDD=OUT0007
S M=((YYYY,AAAAAA))
COPYGRP INDD=IN0007,OUTDD=OUT0007
S M=((YYYY,BBBBBB))
I do not know how to achieve this as the first file has only one record and second file has multiple(it will vary) records. I know how to merge records using SEQNUM technique but that'll give a useful output only if the first file has equal no of records as that of the second one. And simple merge won't help either.
Can someone help please?
Side note : For a specific reason I have to copy the content of YYYY member from one dataset to another and rename it to a valid member name. IEBCOPY says that there should be an operation for every copy & rename and that's the reason I need the COPYGRP operation for all members.
Apologies if it seems to be a naïve ask.
Merge two files
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Merge two files
1. Learn how to use the code tags in your code samples.
2. Try to understand the SORT terminology, to distinguish between MERGE, JOIN, and CONCATENATE operations. They are ABSOLUTELY different. What exactly do you need??
3. Prior to presenting the code to perform an operation you don’t know about, please, present examples of your data, with a minor explanation of your goal:
- input data
- desired conversion rules
- desired output data
2. Try to understand the SORT terminology, to distinguish between MERGE, JOIN, and CONCATENATE operations. They are ABSOLUTELY different. What exactly do you need??
3. Prior to presenting the code to perform an operation you don’t know about, please, present examples of your data, with a minor explanation of your goal:
- input data
- desired conversion rules
- desired output data
Javas and Pythons come and go, but JCL and SORT stay forever.
Re: Merge two files
Hi Sergeyken,
Thanks for your reponse.
Basically I have to JOIN these two files
Input file 1 has only one record :
Input file 2 has 5126 records:
My output file should have:
Tia
kbabu
Thanks for your reponse.
Basically I have to JOIN these two files
Input file 1 has only one record :
Code: Select all
COPYGRP INDD=IN0007,OUTDD=OUT0007
Input file 2 has 5126 records:
Code: Select all
S M=((YYYY,AAAAAA ))
S M=((YYYY,BBBBBB ))
.....................
.....................
.....................
My output file should have:
Code: Select all
COPYGRP INDD=IN0007,OUTDD=OUT0007
S M=((YYYY,AAAAAA))
COPYGRP INDD=IN0007,OUTDD=OUT0007
S M=((YYYY,BBBBBB))
...........................
...........................
...........................
Tia
kbabu
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Merge two files
This is neither JOIN, nor MERGE, nor CONCATENATE. I even can hardly understand the goal: what the benefit of this result might be?
So far, I don’t care about your goal...
You can combine your lines, for instance in this manner. There is absolutely no reason to complicate the task when one of your “files” is just a constant string.
So far, I don’t care about your goal...
You can combine your lines, for instance in this manner. There is absolutely no reason to complicate the task when one of your “files” is just a constant string.
Code: Select all
//COMBO EXEC PGM=SORT
. . . . .
//SORTIN DD *
S M=((YYYY,AAAAAA ))
S M=((YYYY,BBBBBB ))
.....................
.....................
.....................
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL BUILD=(C’ COPYGRP INDD=IN0007,OUTDD=OUT0007’,
/,1,80)
END
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Posts: 474
- Joined: Thu Mar 10, 2016 5:03 pm
- Skillset: assembler rexx zOS ispf racf smf
- Referer: saw it in the experts foprum thought I could help here
Re: Merge two files
I might be missing something here.
With IEBCOPY you can have several select statements for a single COPY statement, like:
So as long as you copy between the same 2 libraries I cannot see the need for more then the first COPYGRP.
With IEBCOPY you can have several select statements for a single COPY statement, like:
Code: Select all
COPYGRP INDD=IN0007,OUTDD=OUT0007
S M=((YYYY,AAAAAA))
S M=((YYYY,BBBBBB))
So as long as you copy between the same 2 libraries I cannot see the need for more then the first COPYGRP.
-
- Posts: 474
- Joined: Thu Mar 10, 2016 5:03 pm
- Skillset: assembler rexx zOS ispf racf smf
- Referer: saw it in the experts foprum thought I could help here
Re: Merge two files
So your job could look something like this:
Code: Select all
//STEP020 EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=XXX.XXX.XXX
//OXXX DD DISP=(,PASS),DSN=&&CPYLST
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=OXXX,
INCLUDE=(15,4,CH,EQ,C'XXXX'),
OUTREC=(1:5X,6:C'S M=((YYYY,',17:1,8,25:C'))',27:54X)
//C EXEC PGM=IEBCPY
//SYSPRINT DD SYSOUT=*
//INLIB DD DISP=SHR,DSN=...
//OUTLIB DD DISP=SHR,DSN=...
//SYSIN DD *
COPYGRP INDD=INLIB,OUTDD=OUTLIB
// DD DISP=OLD,DSN=&&CPYLST
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Merge two files
Since the original question about SORT has been transferred into the question about COPY utility, then I may suggest the most straightforward approach:
Code: Select all
//COPYSTEP EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=*
//INLIB DD DISP=SHR,DSN=...
//OUTLIB DD DISP=SHR,DSN=...
//SYSIN DD *
COPYGRP INDD=INLIB,OUTDD=OUTLIB
// DD DISP=SHR,DSN=XXX.XXX.XXX
Javas and Pythons come and go, but JCL and SORT stay forever.
Re: Merge two files
willy jensen wrote:I might be missing something here.
With IEBCOPY you can have several select statements for a single COPY statement, like:Code: Select all
COPYGRP INDD=IN0007,OUTDD=OUT0007
S M=((YYYY,AAAAAA))
S M=((YYYY,BBBBBB))
So as long as you copy between the same 2 libraries I cannot see the need for more then the first COPYGRP.
Hi Willy, Thanks for your inputs. I tried this already but IEBCOPY doesn't allow this construct. Please see the error below
Code: Select all
PDSMAN FASTCOPY PROCESSING ACTIVE 2021074 03:44:26 JOBNAME SY3
COPYGRP INDD=IN0001,OUTDD=OUT0001
S M=((YYYY,AAAAAAAA))
S M=((YYYY,BBBBBBBB))
COPYING TO PDS OUTDD=OUT0001 VOL=DVT01D DSN=XXX.XXX.XXX
FROM PDSE INDD=IN0001 VOL=DVT00A DSN=ZZZ.ZZZ.ZZZ
RECFM/LRECL/BLKSIZE INPUT: FB,80,6160 OUTPUT: FB,80,27920
REBLOCKING IS BEING PERFORMED
CANNOT SPECIFY DUPLICATE MEMBER NAME YYYY FOR SELECT/EXCLUDE/RENAME
Re: Merge two files
sergeyken wrote:This is neither JOIN, nor MERGE, nor CONCATENATE. I even can hardly understand the goal: what the benefit of this result might be?
So far, I don’t care about your goal...
You can combine your lines, for instance in this manner. There is absolutely no reason to complicate the task when one of your “files” is just a constant string.Code: Select all
//COMBO EXEC PGM=SORT
. . . . .
//SORTIN DD *
S M=((YYYY,AAAAAA ))
S M=((YYYY,BBBBBB ))
.....................
.....................
.....................
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL BUILD=(C’ COPYGRP INDD=IN0007,OUTDD=OUT0007’,
/,1,80)
END
Yes sergeyken. Your solution worked like a charm. Thanks a lot for your time.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 1
- 1839
-
by sergeyken
View the latest post
Mon Nov 23, 2020 7:25 pm
-
-
Merge multiple fixed length files of different record length
by corvette1982 » Mon Mar 01, 2021 11:46 pm » in JCL - 8
- 5274
-
by willy jensen
View the latest post
Tue Mar 02, 2021 3:02 am
-
-
-
Joining 2 vb files into vsam files ended error
by newbiemainframe » Thu Nov 12, 2020 7:59 am » in JCL - 1
- 1749
-
by NicC
View the latest post
Thu Nov 12, 2020 7:15 pm
-
-
- 0
- 2570
-
by JIMDOOEY
View the latest post
Tue Mar 01, 2022 8:48 am
-
- 1
- 1235
-
by sergeyken
View the latest post
Tue Nov 08, 2022 7:22 pm