Вы находитесь на странице: 1из 20

1.

extract data from the tape file (file record length-387) with condition that "whenever
chars B8 is found at 68th position,only those records needs to be extracted.
Assuming your input tape file has RECFM=FB, you can use a DFSORT job like the
following to do what you asked for (there's nothing special about using a tape file as
input other than specifying the correct JCL parameters):

Code:

//S1 EXEC PGM=SORT


//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input tape file (FB/387)
//SORTOUT DD DSN=... output file (FB/387)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(68,2,CH,EQ,C'B8')
/*

---------------------------------

2. A lesson in looking up DFSORT/ICETOOL messages:

DFSORT is an IBM product. DFSORT includes ICETOOL. The messages for IBM
products are easily accessible. The easiest way to look up an IBM message is to use
IBM's LookAt facility at:

http://www.ibm.com/servers/eserver/zseries/zos/bkserv/lookat/

Everyone should bookmark this.

You just choose the version of z/OS you want, e.g. V1R12, type the message into the
message ID box (for example, ICE077A), hit enter and the message text is displayed.

The other easy way to look up DFSORT messages is in "z/OS DFSORT Messages,
Codes and Diagnosis Guide" which you can access along with all the other DFSORT
books from:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080

Click on "Messages and Codes", then "Informational and Error Messages" and you'll get
a clickable list of the DFSORT messages. Here's the direct link:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CM20/2.2?
SHELF=&DT=20060721170811&CASE=
---------------------------------------

3. Many z/OS DFSORT functions were delivered as PTFs at various times, so in order to
use them your System Programmer needs to have installed a specific DFSORT PTF. To
read all about the DFSORT functions delivered in October, 2010, November, 2009, July,
2008, April, 2006 and Dec, 2004, see:

http://ibmmainframes.com/viewtopic.php?t=1348

Note: z/OS DFSORT V1R10 is used for z/OS 1.10-1.11. z/OS DFSORT V1R12 is used
for z/OS 1.12. These are the only currently supported releases of DFSORT.

To determine which level of DFSORT functions you have available, look at message
ICE201I in the //SYSOUT messages you receive from the DFSORT job shown below, or
from any successful DFSORT job.

If you see:

ICE201I H RECORD TYPE ...

the H indicates you have the October, 2010 DFSORT functions (RESIZE, IFTRAIL,
ACCEPT, ADDDAYS, DATEDIFF, TRAN=ATOE, KEYBEGIN, etc) and all of the
earlier functions. This function level corresponds to z/OS DFSORT V1R10 PTF
UK90025 and z/OS DFSORT V1R12 PTF UK90026. You are completely up to date on
DFSORT functional PTFs.

Note: If you see WERxxxs messages, you have Syncsort, not DFSORT.

If you see:

ICE201I G RECORD TYPE ...

the G indicates you have the November, 2009 DFSORT functions (JOINKEYS, TOJUL,
TOGREG, WEEKDAY, etc) and all of the earlier functions. This function level
corresponds to z/OS DFSORT V1R5 PTF UK51706 and z/OS DFSORT V1R10 PTF
UK51707. You are behind on DFSORT functional PTFs. Ask your System Programmer
to install z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF
UK90026.

If you see:

ICE201I F RECORD TYPE ...

the F indicates you have the July, 2008 DFSORT functions (FINDREP,
WHEN=GROUP, DATASORT, SUBSET, etc) and all of the earlier functions.
This function level corresponds to z/OS DFSORT V1R5 PTF UK90013 and z/OS
DFSORT V1R10 PTF UK90014. You are behind on DFSORT functional PTFs. Ask
your System Programmer to install z/OS DFSORT V1R10 PTF UK90025 or z/OS
DFSORT V1R12 PTF UK90026.

If you see:

ICE201I E RECORD TYPE ...

the E indicates you have the April, 2006 DFSORT functions (PARSE, JFY, SQZ,
SPLIT1R, etc) and all of the earlier functions. This function level corresponds to z/OS
DFSORT V1R5 PTF UK90007. You are behind on DFSORT functional PTFs. Ask your
System Programmer to install z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT
V1R12 PTF UK90026.

If you see:

ICE201I 0 RECORD TYPE ...

the 0 indicates you do not have the July, 2008 or April, 2006 DFSORT functions. You
are way behind on DFSORT functional PTFs. Ask your System Programmer to install
z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026.

You may or may not have the Dec, 2004 DFSORT functions (IFTHEN, OVERLAY,
SFF, UFF, etc), which corresponds to z/OS DFSORT V1R5 PTF UQ95214. try using one
of these functions - if you get errors trying to use it, then you don't even have the Dec,
2004 PTF installed.

*******************

You can run this job to see the ICE201I message:

Code:

//S1 EXEC PGM=ICEMAN


//SYSOUT DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
/*
---------
3. file one contains 30 records and file 2 contains 100 records.
when I spliced them together file3 contained only the records from file1.

File1 has a field that that has to be added to file2 where the keys match and a default
value where they do not match.

here is my JCL

//JS010 EXEC PGM=ICETOOL


//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DISP=SHR,DSN=file1
//IN2 DD DISP=SHR,DSN=file2
//TEMP1 DD DSN=&&temp1
//COMBINE DD DSN=file3
//TOOLIN DD *
COPY FROM(IN1) TO(TEMP1) USING(CTL1)
COPY FROM(IN2) TO(TEMP1) USING(CTL2)
SPLICE FROM(TEMP1) WITHALL -
ON(1,15,CH) - key
WITH(30,446) -
TO(COMBINE)
/*
* Move IN1 fields to their locations
//CTL1CNTL DD *
OUTREC FIELDS=(01:02,15, key
16:17,14,
475:X)
/*
* Move IN2 fields to their locations
//CTL2CNTL DD *
OUTREC FIELDS=(01:01,15, key
30:16,446) REST
/*
----------------------
4. File-1 is set and file-2 sub set(all records of file-2 will present in file-1, but vise-versa
is NOT true)

Now I want to know which all records are missing in file-2, when compare to file-1.

File-1
Code:
01
02
03
04
05
06

File-2
Code:
01
03
05

Expected out of file-3


File-3
Code:
02
04
06

NOTE: content of all files is in BINARY format

You can use the DFSORT job below.

Code:

//S1 EXEC PGM=SORT


//SYSOUT DD SYSOUT=*
//IN1 DD DSN=... input file1
//IN2 DD DSN=... input file2
//SORTOUT DD DSN=... output file
//SYSIN DD *
JOINKEYS F1=IN1,FIELDS=(1,2,A)
JOINKEYS F2=IN2,FIELDS=(1,2,A)
JOIN UNPAIRED,F1,ONLY
REFORMAT FIELDS=(F1:1,2)
OPTION COPY
//*
If the records in input file1 are already sorted (as shown in the example), it would be
more efficient to add SORTED to the JOINKEYS statement for F1. If the records in input
file2 are already sorted (as shown in the example), it would be more efficient to add
SORTED to the JOINKEYS statement for F2.

Alternatively, assuming the two input files have the same RECFM and LRECL, you can
use a DFSORT/ICETOOL job like the following:

Code:

//S1 EXEC PGM=ICETOOL


//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=... input file1
// DD DSN=... input file2
//OUT DD DSN=... output file
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(1,2,BI) NODUPS
/*

-----------------------
5.
I have an input file having one or more fee
amounts charged to a customer. For each
record, I need to sum all the fee amounts of
'SALE' and 'MGMT' type and generate the
result in single column in output file.

The input file is of variable length of max 84(+4


for storing length). The first 4 bytes of data are
normal fields whereas the remaining 80 bytes
gets build within an OCCURS claues that can
go max upto 10 times based on value present in
field "COUNT" (described later).
Fields are (as per data provided below):-
Customer Number-- from position 1 to 3
(Format: Char)
Count-- from position 4 to 4 (Format: Number)
- Indicates how many fees will be there in the
record, since record is of variable length

===Next two fields repeats based on the


COUNT field ===
Desc-- from position 5 to 8 (Format: Char) -
Indicates type of fee
Amount-- from position 9 to 12 (Format:
Signed packed decimal i.e. S9(9)V9(2) COMP-
3) - Indicates the amount for that description

Consider data as below

Code:

A014SALE====MGMT====SALE====SAL
E====
B014MGMT====SALE====MGMT====MG
MT====
C015ADMN====MGMT====SALE====INS
U====SALE====
D012ADMN====SALE====
E013MGMT====ADMN====SALE====

Expected output:

Sum of all SALE and MGMT in same row, to


be populated in output for that row.

Code:

A01====
B01====
C01====
D01====
E01====
Anyway we can do it through
DFSORT/ICEMAN/ICETOOL?

Or atleast If I could get below output, which is


one record for each fee amount for same
customer:
Code:

A01====
A01====
A01====
A01====
B01====
B01====
B01====
B01====
C01====
C01====
C01====
D01====
E01====
E01====

Thanks in advance for any help or guidance !!!

--- Andy
Back to top

References<>
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005


Posts: 6691
Location: San Jose, CA
Posted: Sat Feb 05, 2011 4:10 am Post subject:

I have some questions about your description.

What is the RECFM of the input file? It's difficult to tell whether this is really a VB file, or an
FB file padded with blanks. Which is it?

Quote:
Amount-- from position 9 to 12 (Format: Signed packed decimal i.e. S9(9)V9(2) COMP-3) -
Indicates the amount for that description

An S(9)V9(2) COMP-3 field would be 6 bytes. But you say the amount is in positions 9-12
which is only 4 bytes. Which is correct?

Quote:
within an OCCURS claues that can go max upto 10 times based on value present in field
"COUNT"

Count-- from position 4 to 4 (Format: Number)

What type of number? You can't use a ZD or PD value to get 10 into one byte, so what kind of
number is it?
Back to top

Andy85

New User

Joined: 25 Dec 2008


Posts: 25
Location: India
Posted: Sat Feb 05, 2011 4:18 am Post subject: Reply to: Sum amounts from different positions
in same row

Ooops....made a mistake while mentioning the examples.

You can consider the maximum occurences as 9 and the COUNT field as of type ZD with length
of 1 character.
Back to top

Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005


Posts: 6691
Location: San Jose, CA
Posted: Sat Feb 05, 2011 5:07 am Post subject:

And what about my other two questions about RECFM, and 4-bytes vs 6-bytes for the PD field?
Back to top

devil13

New User

Joined: 18 Jul 2010


Posts: 40
Location: chennai
Posted: Mon Feb 07, 2011 12:19 pm Post subject:

Hi Andy85,
You can modify the below JCL and use it for your requirement:
Code:

//SORTIN DD *
A014SALE2000MGMT2000SALE2000SALE2000
B014MGMT1000SALE1000MGMT1000MGMT1000
C015ADMN1000MGMT1000SALE1000INSU1000SALE1000
D012ADMN9999SALE9999
E013MGMT9000ADMN9000SALE9000SALE9000
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(4,1,ZD,EQ,2),
BUILD=(1,3,9,4,ZD,ADD,17,4,ZD,20:X)),
IFTHEN=(WHEN=(4,1,ZD,EQ,3),
BUILD=(1,3,9,4,ZD,ADD,17,4,ZD,ADD,25,4,ZD,20:X)),
IFTHEN=(WHEN=(4,1,ZD,EQ,4),
BUILD=(1,3,9,4,ZD,ADD,17,4,ZD,ADD,25,4,ZD,
ADD,33,4,ZD)),
IFTHEN=(WHEN=(4,1,ZD,EQ,5),
BUILD=(1,3,9,4,ZD,ADD,17,4,ZD,ADD,25,4,ZD,
ADD,33,4,ZD,ADD,41,4,ZD)),
IFTHEN=(WHEN=(4,1,ZD,EQ,6),
BUILD=(1,3,9,4,ZD,ADD,17,4,ZD,ADD,25,4,ZD,
ADD,33,4,ZD,ADD,41,4,ZD,ADD,49,4,ZD)),
IFTHEN=(WHEN=(4,1,ZD,EQ,7),
BUILD=(1,3,9,4,ZD,ADD,17,4,ZD,ADD,25,4,ZD,
ADD,33,4,ZD,ADD,41,4,ZD,ADD,49,4,ZD,
ADD,57,4,ZD)),
IFTHEN=(WHEN=(4,1,ZD,EQ,8),
BUILD=(1,3,9,4,ZD,ADD,17,4,ZD,ADD,25,4,ZD,
ADD,33,4,ZD,ADD,41,4,ZD,ADD,49,4,ZD,
ADD,57,4,ZD,ADD,65,4,ZD)),
IFTHEN=(WHEN=(4,1,ZD,EQ,9),
BUILD=(1,3,9,4,ZD,ADD,17,4,ZD,ADD,25,4,ZD,
ADD,33,4,ZD,ADD,41,4,ZD,ADD,49,4,ZD,
ADD,57,4,ZD,ADD,65,4,ZD,ADD,73,4,ZD))
//*

This Jcl can be modified based on your requirement.


output:
Code:
A01 8000
B01 4000
C01 5000
D01 19998
E01 27000

devil13
There is always a better solution.
Back to top

vasanthz

Active User

Joined: 28 Aug 2007


Posts: 452
Location: South Indian CEO's Chair (picture above)
Posted: Mon Feb 07, 2011 12:53 pm Post subject:

@devil13

Quote:
BUILD=(1,3,9,4,ZD,ADD,17,4,ZD,20:X)),

Hi,
User wants to add comp3 values. so ZD should be changed to something else right?
Back to top

devil13

New User
Joined: 18 Jul 2010
Posts: 40
Location: chennai
Posted: Mon Feb 07, 2011 2:12 pm Post subject:

Hi Vasanthz,
You are right.
Actually Frank had raised the questions regarding the size of the variables:
Quote:

An S(9)V9(2) COMP-3 field would be 6 bytes. But you say the amount is in positions 9-12
which is only 4 bytes. Which is correct?

So the user can make changes in the sort card according to the data he has in the input.

- for comp3 he can use PD.

devil13
There is always a better solution
Back to top

Andy85

New User

Joined: 25 Dec 2008


Posts: 25
Location: India
Posted: Mon Feb 07, 2011 9:28 pm Post subject: Reply to: Sum amounts from different positions
in same row

Quote:
An S(9)V9(2) COMP-3 field would be 6 bytes. But you say the amount is in positions 9-12
which is only 4 bytes. Which is correct?

Frank,

The field picture clause is S9(9)V9(2).So the amount position would be of 6 bytes. You are
correct. Incorrectly mentioned it as 4-bytes in my examples.
Back to top

Andy85

New User

Joined: 25 Dec 2008


Posts: 25
Location: India
Posted: Mon Feb 07, 2011 9:35 pm Post subject: Reply to: Sum amounts from different positions
in same row

devil13,

The parameters/job you have mentioned sums up all the amounts in the same row. However, my
requirement is to sum up only those amounts for SALE & MGMT. There is no such condition in
the SORTIN that you have provided. Is there any way of adding this condition too?
Back to top

Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005


Posts: 6691
Location: San Jose, CA
Posted: Tue Feb 08, 2011 12:21 am Post subject:
Andy,

Assuming that the PD values are 6 bytes each, and the RECFM is FB, you can use a DFSORT
job like the following to do what you asked for. The result will have the customer number
followed by the 6 byte PD totals for SALE and MGMT.

Code:

//S1 EXEC PGM=SORT


//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB)
//SORTOUT DD DSN=... output file (FB/9)
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ABSPOS=5,
STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6),
%02=(STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6),
%03=(STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6),
%04=(STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6),
%05=(STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6),
%06=(STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6),
%07=(STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6),
%08=(STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6),
%09=(STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6)),
BUILD=(1,3,%01,X'FF',%02,X'FF',%03,X'FF',%04,X'FF',
%05,X'FF',%06,X'FF',%07,X'FF',%08,X'FF',%09,X'FF')),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=4,
IN=X'404040404040FF',OUT=X'00000000000C00')),
IFTHEN=(WHEN=INIT,
BUILD=(1,3,4,6,PD,ADD,11,6,PD,ADD,18,6,PD,ADD,25,6,PD,ADD,
32,6,PD,ADD,39,6,PD,ADD,46,6,PD,ADD,53,6,PD,ADD,60,6,PD,
TO=PD,LENGTH=6))
/*

Back to top

devil13

New User
Joined: 18 Jul 2010
Posts: 40
Location: chennai
Posted: Tue Feb 08, 2011 9:13 am Post subject:

Hi Andy85,
You have the solution now.

Quote:

Or atleast If I could get below output, which is one record for each fee amount for same
customer:
Code:

A01====
A01====
A01====
A01====
B01====
B01====
B01====
B01====
C01====
C01====
C01====
D01====
E01====
E01====

The below JCL is just to meet the above requirement. Thought this would also be helpful for
someone like me in future

Code:

//SORTIN DD *
A014SALE2000MGMT2000SALE2000SALE2000
B014MGMT1000SALE1000MGMT1000MGMT1000
C015ADMN1000MGMT1000SALE1000INSU1000SALE1000
D012ADMN9999SALE9999
E013MGMT9000ADMN9000SALE9000
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL IFTHEN=(WHEN=(4,1,ZD,EQ,2),
BUILD=(1,3,5,8,/,
1,3,13,8)),
IFTHEN=(WHEN=(4,1,ZD,EQ,3),
BUILD=(1,3,5,8,/,
1,3,13,8,/,
1,3,21,8)),
IFTHEN=(WHEN=(4,1,ZD,EQ,4),
BUILD=(1,3,5,8,/,
1,3,13,8,/,
1,3,21,8,/,
1,3,29,8)),
IFTHEN=(WHEN=(4,1,ZD,EQ,5),
BUILD=(1,3,5,8,/,
1,3,13,8,/,
1,3,21,8,/,
1,3,29,8,/,
1,3,37,8)),
IFTHEN=(WHEN=(4,1,ZD,EQ,6),
BUILD=(1,3,5,8,/,
1,3,13,8,/,
1,3,21,8,/,
1,3,29,8,/,
1,3,37,8,/,
1,3,45,8)),
IFTHEN=(WHEN=(4,1,ZD,EQ,7),
BUILD=(1,3,5,8,/,
1,3,13,8,/,
1,3,21,8,/,
1,3,29,8,/,
1,3,37,8,/,
1,3,45,8,/,
1,3,53,8)),
IFTHEN=(WHEN=(4,1,ZD,EQ,8),
BUILD=(1,3,5,8,/,
1,3,13,8,/,
1,3,21,8,/,
1,3,29,8,/,
1,3,37,8,/,
1,3,45,8,/,
1,3,53,8,/,
1,3,61,8)),
IFTHEN=(WHEN=(4,1,ZD,EQ,9),
BUILD=(1,3,5,8,/,
1,3,13,8,/,
1,3,21,8,/,
1,3,29,8,/,
1,3,37,8,/,
1,3,45,8,/,
1,3,53,8,/,
1,3,61,8,/,
1,3,69,8)),
//*

Output of the same:


Code:

A01SALE2000
A01MGMT2000
A01SALE2000
A01SALE2000
B01MGMT1000
B01SALE1000
B01MGMT1000
B01MGMT1000
C01ADMN1000
C01MGMT1000
C01SALE1000
C01INSU1000
C01SALE1000
D01ADMN9999
D01SALE9999
E01MGMT9000
E01ADMN9000
E01SALE9000

devil13
There is always a better solution.
Back to top

Skolusu

DFSORT Developer

Joined: 07 Dec 2007


Posts: 1338
Location: San Jose
Posted: Tue Feb 08, 2011 10:37 pm Post subject:

devil13 wrote:
The below JCL is just to meet the above requirement. Thought this would also be helpful for
someone like me in future.

devil13,

With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026
(Oct,2010), you can now use the new RESIZE operator of DFSORT's ICETOOL to easily create
smaller records from larger records or larger records from smaller records.

Code:

//STEP0100 EXEC PGM=ICETOOL


//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
A014SALE2000MGMT2000SALE2000SALE2000
B014MGMT1000SALE1000MGMT1000MGMT1000
C015ADMN1000MGMT1000SALE1000INSU1000SALE1000
D012ADMN9999SALE9999
E013MGMT9000ADMN9000SALE9000
//OUT DD SYSOUT=*
//TOOLIN DD *
RESIZE FROM(IN) TO(OUT) TOLEN(11) USING(CTL1)
//CTL1CNTL DD *
INREC BUILD=(1,3,5,8,1,3,13,8,1,3,21,8,1,3,29,8,1,3,37,8,
1,3,45,8,1,3,53,8,1,3,61,8,1,3,69,8)
OUTFIL OMIT=(4,1,CH,EQ,C' ')
//*

Вам также может понравиться