Merge 2 PDS member to 1 - zos

I have a seemingly easy task of of merging 2 member of a PDS, say MYDSN.X(A) and MYDSN.X(B) to a common member MYDSN.X(AB).
My attempt was to use IEBCOPY but somehow I wasn't able to do this particular task, although I found quite a few helpful examples here.
A further special case of this task would be to create a new member, say MYDSN.X(A3) that contains 3 times the content of MYDSN.X(A). Any ideas on that special case, too?

What you want to do is very simple with dataset concatenation:
//SOMENAME DD DISP=SHR,DSN=yourpds(yourmem1)
// DD DISP=SHR,DSN=yourpds(yourmem1)
You can use that directly in your JCL that runs the step(s) you want to test, or, if you want a permanent copy, you can make a copy:
//SORTCOPY EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=yourpds(yourmem1)
// DD DISP=SHR,DSN=yourpds(yourmem2)
//SORTOUT DD DISP=OLD,DSN=yourpds(yournew)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
Notice the DISP=OLD for the output. That will ensure you won't potentially lose data if two jobs doing this run at the same time.
PDSEs are "safer" than PDSs.
If you want multiple copies of the same member:
//SORTCOPY EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=yourpds(yourmem1)
// DD DISP=SHR,DSN=yourpds(yourmem1)
// DD DISP=SHR,DSN=yourpds(yourmem1)
// DD DISP=SHR,DSN=yourpds(yourmem1)
//SORTOUT DD DISP=OLD,DSN=yourpds(yournew)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
Using your editor to Repeat is really simple.

Related

Is is possible to dump the contents of a JCL SYSOUT to a z/OS flat file?

I'm interested in knowing if it is possible to get the contents of a JCL SYSOUT into a z/OS flat file; either in the same JCL step or in a JCL step executed later in the same JCL.
AttentionĀ”, I do not mean the other way round; which is generate the SYSOUT directy in a z/OS file and, after, in another JCL step dump it onto SYSOUT.
For example; in the following JCL step I'm interested in getting the contents of SYSOUT=2 in a flat file.
May anyone shed light in this issue?.
Many thanks in advance.
//WNMPRAD5 EXEC PGM=WNMPRAD5,COND=(4,LT)
//SYSPRINT DD SYSOUT=1
//SYSDBOUT DD SYSOUT=1
//ENTRADA DD DSN=WNMT.SCADUC.WGPT022.ZXDALMA.UNLDBI,DISP=OLD
//SORTIDA DD DSN=WNMT.SCADUC.WGPT022.ZXDALMA.OUTPUT.V02,
// DISP=(NEW,CATLG,DELETE),UNIT=DISK,
// DCB=(RECFM=FB,LRECL=278),
// SPACE=(27998,(2500,2500),RLSE)
//SYSOUT DD SYSOUT=2
//SYSIN DD *
N0100
/*
SYSOUT is no different than any other DD but is used by convention for output. You can create a DD like this in the STEP that creates the file:
//SYSOUT DD DSN=MY.SYSOUT,
// DISP=(NEW,CATLG,DELETE),UNIT=DISK,
// DCB=(RECFM=FBA,LRECL=133,BLKSIZE=0),
// SPACE=(27998,(2500,2500),RLSE)
The DCB will vary depending but 133 (assuming ASA character) is common. No need for a different step.
If you want, you could in a following step use IEBGENER to copy the Disk to another SYSOUT to store the contents in the JOB. Its not possible, as far as I know, to easily grab a SYSOUT in the next step and copy to disk.
Yes. You have to get the LRECL and RECFM correct, but you can get those from the source code to the program you're executing. Most standard reports are 133 and FB or 132 and FBA. I seem to remember IDCAMS was 121 and VBA.
//WNMPRAD5 EXEC PGM=WNMPRAD5,COND=(4,LT)
//SYSPRINT DD SYSOUT=1
//SYSDBOUT DD SYSOUT=1
//ENTRADA DD DSN=WNMT.SCADUC.WGPT022.ZXDALMA.UNLDBI,DISP=OLD
//SORTIDA DD DSN=WNMT.SCADUC.WGPT022.ZXDALMA.OUTPUT.V02,
// DISP=(NEW,CATLG,DELETE),UNIT=DISK,
// DCB=(RECFM=FB,LRECL=278),
// SPACE=(27998,(2500,2500),RLSE)
//SYSOUT DD DISP=(NEW,CATLG,DELETE),
// DSN=&SYSUID..STEPNAME.SYSOUT,
// AVGREC=K,
// LRECL=133,
// RECFM=FB,
// SPACE=(500,(10,10))
//SYSIN DD *
N0100
/*
Provide the disposition parameter and dataset name in the sysout. So, it will be something like
//sysout dd dsn=abc.xyz,disp=(as per your choice)

I keep getting an error with the JCL code and I don't know why

//BJCL1804 JOB 1,NOTIFY=&SYSUID
//SORT01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD DISP,SHR,DSN=ZOS.PUBLIC.DATA(ASCII)
//SORTOUT DD SYSOUT=*
//SYSIN DD SYSIN=*
//SORT DD =(1,1,CH,A)
I am trying to use this JCL code and when I use the SUB command, I always get an error. Even after hours of trying and trying, I cannot seem to fix this error. I looked up the error codes from the =SD and I cannot figure out how to fix the issue. The syntax seems to be correct. I just don't understand. Can someone please help me understand why this is causing an error to occur?
You have two things wrong with this:
//SORTIN DD DISP,SHR,DSN=ZOS.PUBLIC.DATA(ASCII)
This should be "DISP=SHR", not "DISP,SHR"
//SYSIN DD SYSIN=*
//SORT DD =(1,1,CH,A)
This should be:
//SYSIN DD SYSIN=*
SORT FIELDS=(1,1,CH,A)
The SYSIN=* is creating an instream temporary dataset with the sort control statements. Also, I think you need something like "SORT FIELDS=(1,1,CH,A)".
//SYSIN DD SYSIN=*
is incorrect syntax. I believe you want
//SYSIN DD *
and SORT control statements don't begin with //, which is what is causing your IEFC641I error.
The documentation is your friend.
//BJCL1804 JOB 1,NOTIFY=&SYSUID
//SORT01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD DISP,SHR,DSN=ZOS.PUBLIC.DATA(ASCII)
//SORTOUT DD SYSOUT=*
//SYSIN DD SYSIN=*
//SORT DD =(1,1,CH,A)
The format of your JOB statement should be the same as that for other developers at your site. That "1," looks wrong, but since knowing for sure won't help, I'm not going to check. The JCL Reference will tell you.
The SYSPRINT and SYSUDUMP you do not need for a SORT step, although perhaps you are supposed to have them at your site, even though pointless.
As has been pointed out, your SYSIN DD is incorrect. You can't just follow the format of a different type of DD statement and hope for the best. it should be:
//SYSIND DD *
Where the * means "instream data" rather than a named dataset.
Sort Control Cards do not start with // and do start with at least one blank.
If you are trying to sort a file, it will look something like this:
SORT FIELDS=(1,1,CH,A)

Adding amounts present in the character format

I have a PS with LRECL = 500 and RECFM=FB and in positions 70 through 82, I have the below amount fields in character format.
-000000042.99
-000000001.50
-000000003.00
-000000001.50
-000000042.99
+000000025.00
+000000019.52
+000000058.36
How can I convert this to Packed Decimal? My intention is I need to sum up the amounts field.Any ideas?
We have DFSORT. These amount fields are not in Packed decimal or numeric format. This file comes from an external system and I would like to sum all the amounts in this file through a JCL. I have to know the amount. For obvious reasons I do not wish to export this file to an excel and find the total there. I do not want to sum the totals based on a key. I just want to sum all the amounts in that file in that column.
//SORTA EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
TRAILER1=(TOTAL=(1,13,SFF,
EDIT=(SIIIIIIIIT.TT),
SIGNS=(+,-),
LENGTH=13))
//SORTIN DD *
-000000010.10
-000000020.20
+000000005.88
Now I am getting the desired output
-000000010.10
-000000020.20
+000000005.88
-24.42
It is a simple task using OUTFIL and its reporting functions:
//TOTALREP EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
TRAILER1=(TOTAL=(1,13,SFF,
EDIT=(SIIIIIIIIT.TT),
SIGNS=(+,-),
LENGTH=13))
//SORTIN DD *
-000000042.99
-000000001.50
-000000003.00
-000000001.50
-000000042.99
+000000025.00
+000000019.52
+000000058.36
SORTOUT contains:
-000000042.99
-000000001.50
-000000003.00
-000000001.50
-000000042.99
+000000025.00
+000000019.52
+000000058.36
+3.86
REMOVECC says don't include a printer Control Code, TRAILER1 is actioned at the end of the OUTFIL group, TOTAL (or TOT) says give a total of the position (here 1) length (13) and type (FS) (which you should look up in the DFSORT Application Programming Guide, which, for your version of DFSORT, can be found here: http://www-01.ibm.com/support/docview.wss?uid=isg3T7000080 . The EDIT, SIGNS and LENGTH dictate how the TOTAL value is going to appear.
UFF is Unsighed Free Format - This will strip out all non-numeric digits and process the result
SFF is Signed Free Format - This will strip out all non-numeric digits and process the result based on the presence, anywhere in the field, and that means anywhere, of one or more -If - is located, value will be negative otherwise positive.
FS
CSF These two are synonymous and can handle leading signs, but not decimal points. In the original example, the presence of the decimal point caused the number to be treated as only the decimal part. Everything in front of the decimal point was ignored, including the sign.

Passing symbol value using DFSORT to file

Statement: Earlier files were fetched from remote server location to mainframe. Then
those files content were get and saved at mainframe in a sequential file. But
sometime, some file names contained spaces. Due to this job fails while getting its
content.
Now to solve this problem, we fetched all files from server and separated good files
and bad files. Now we fetch only good file contents.
Problem: While renaming the files, we add prefix Process_ and Odate(fetched from Control M) to file name.
But earlier it was done in jcl as below through unix code.
Pseudo code:
print "rename " $1 " " "Process_" %%DAT "_" $1
We are fetching ODATE from a software control-M.
Jcl code:
//JOBNAME JOB (DEE),'Job Desc',CLASS=P,MSGCLASS=J,
// MSGLEVEL=(1,1),COND=(0,NE)
//* %%SET %%DAT = %%$ODATE
//STEP01 EXEC PROC1
PROC1 code:
//STEP02 EXEC PGM=SORT
//SORTIN DD DSN=DS.FILE1,
// DISP=SHR
//SORTOUT DD DSN=DS.FILE2,
// UNIT=SYSSF,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0),
// SPACE=(27920,(29,6),RLSE),
// DISP=(NEW,CATLG,DELETE)
//SYSIN DD DSN=DS.PARM(PARM03),DISP=SHR
PARM03 contains:
Here I am creating unix code to rename file:
SORT FIELDS=COPY
OUTFIL BUILD=(1:C'print "get " r_fi',18:SEQNUM, -
3,ZD,22:C'" //DD:upload"',/,1:C'print "rename " r_fi', -
21:SEQNUM,3,ZD,24:C' ', -
25:C' " " "Process_" %%DAT "_" r_fi',53:SEQNUM,3,ZD,80:X)
/*
The unix code which I am creating dynamically:
Here depending on the number of files p_fi01, p_fi02, p_fi03..... is generated.
I am saving the unix code in a dataset and passing it as instream to run.
The problem is, it is not able to get the value in DAT variable.
Is there any way, I can pass the value of D from jcl to proc and append it with
"Process_" using sort card in proc.
Example data:
File File1.csv contents are fetched and then renamed as Process_20140101_File1.csv
Assuming that the rest of your code is OK, it is fairly simple with DFSORT, using JPn, which is a special DFSORT symbol which allows the separate values of up to 10 parameters to be used in control cards.
Here is an example:
// SET INPARM='ABC'
//*
//STEP0100 EXEC PGM=SORT,PARM='JP0"&INPARM"'
//SYSOUT DD SYSOUT=*
//SYMNOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(JP0)
//SORTIN DD *
IRRELEVANT DATA, JUST AN EXAMPLE
I have used SET to create a JCL symbol, but you have yours already from CONTROL-M, so just replace &INPARM on the PARM with your CONTROL-M symbol.
JPn means JP0 through JP9. Three separate pieces of data could look like this:
//STEP0100 EXEC PGM=SORT,PARM='JP0"&INPARM1",JP1"&INPARM2",JP2"&INPARM3"'
The SYMNOUNT DD is optional, but very, very useful, as it will show you the translated values of the symbols.
Assuming that the rest of your code is correct, you would make this change:
25:C' " " "Process_"',JP0,C'"_" r_fi',53:SEQNUM,3,ZD,80:X)
And include a PARM on the EXEC card, PARM='JP0"[yourControl-M-symbol]"'
SyncSort does not have JPn, so that is lucky for you that you have DFSORT. A different technique would be required for SyncSort.

copy a member from one pds to another? using the jcl statement

How can i use the IEBGENER utilty to copy a member from one pds to another.
something similar to this:
//myjob job1
// exec pg=eibgener
??
don't know the the rest.
Assuming the output PDS has already been created and contains
sufficient space, you
could try something like:
//jobname your-jobcard-info
//stepname EXEC PGM=IEBGENER
//SYSUT1 DD DSN=input-pds(member),DISP=OLD
//SYSUT2 DD DSN=output-pds(member),DISP=OLD
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//*
I think IDCAMS REPRO is more commonly used for this sort of thing these days.
Most folks use IEBCOPY for copying members from one PDS(E) to another. Sample JCL is available by following the link.