View previous topic :: View next topic
|
Author |
Message |
Suresh Shankarakrishnan
New User
Joined: 11 Jul 2008 Posts: 42 Location: USA
|
|
|
|
File1 has 2008 and 2009 in columns 135 thru' 138. Based on the value of the year, it is split into file2(2008) and file3(2009). Next year the value changes to 2009 and 2010.
Is there any way to dynamically change this value in the 'INCLUDE COND' without changing the jcl manually?
Sysin statement listed below...
//SYSIN DD *
SORT FIELDS=(135,4,A),FORMAT=CH
INCLUDE COND=(135,4,CH,EQ,C'2009') |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
Is there any way to dynamically change this value in the 'INCLUDE COND' without changing the jcl manually?
|
as a principle yes...
in general You might have to write two steps to satisfy Your requirement
the first step to create the customized control data for the second one
there are a few samples on the forums on how to build a dynamic sort control statement
for example
http://www.ibmmainframes.com/viewtopic.php?t=25255&highlight=sort+dynamic+date
depending on your scheduler capabilities and customization You might also be able to hev the scheduler modify on the flight the sysin data |
|
Back to top |
|
|
Suresh Shankarakrishnan
New User
Joined: 11 Jul 2008 Posts: 42 Location: USA
|
|
|
|
Thanks enrico - will give it a shot. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Suresh,
You can do what you described in one step/pass using a DFSORT job like this:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
CUR_YEAR,S'&YR4'
/*
//IN DD DSN=... input file
//OUT1 DD DSN=... records for current year
//OUT2 DD DSN=... records for next year
//SYSIN DD *
SORT FIELDS=(135,4,A),FORMAT=CH
OUTFIL FNAMES=OUT1,INCLUDE=(135,4,CH,EQ,CUR_YEAR)
OUTFIL FNAMES=OUT2,SAVE
/*
|
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Thank You Frank for the clarification ! |
|
Back to top |
|
|
Suresh Shankarakrishnan
New User
Joined: 11 Jul 2008 Posts: 42 Location: USA
|
|
|
|
Thanks Frank! Appreciate it. |
|
Back to top |
|
|
Suresh Shankarakrishnan
New User
Joined: 11 Jul 2008 Posts: 42 Location: USA
|
|
|
|
A slight variation to the problem posed before...
Input file - lrecl = 138, columns 135 thru' 138 has year in YYYY format.
Output file 1 will ALWAYS have the greater YYYY. Can never be empty
Output file 2 will ALWAYS have the lesser YYYY. Can be empty if YYYY
has only one value in the input file .
Scanario 1
INput file listed below
0----+----1----+----2----+----3---+---
01 TEST1 PT13712009
01 TEST3 PT13712009
01 TEST6 PT13712009
-----------------------------------------------------
Output file1 listed below
0----+----1----+----2----+----3---+---
01 TEST1 PT13712009
01 TEST3 PT13712009
01 TEST6 PT13712009
-----------------------------------------------------
Output file 2 is empty as there is only one value of YYYY, i.e. 2009
===============================================
Scenario 2
Input file listed below - has two different values in cols 135 thru' 138
- 2 records with 2009 and one record with 2008
0----+----1----+----2----+----3---+---
01 TEST1 PT13712009
01 TEST3 PT13712009
01 TEST6 PT13712008
-----------------------------------------------------
Output file1 listed below
0----+----1----+----2----+----3---+---
01 TEST1 PT13712009
01 TEST3 PT13712009
-----------------------------------------------------
Output file2 listed below
0----+----1----+----2----+----3---+---
01 TEST6 PT13712008
-----------------------------------------------------
YYYY in cols can change, hence it can be dynamically changed.
Output file2 can be empty. If it is not empty, it will always have a lower
value of YYYY compared to Output file1. There can be only two differnt values of YYYY in the Input file.
Can I compare the values ( for example less than or greater than) when splitting in addition to the dynamic splitting like Frank showed above? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will do what you asked for:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/138)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
SORT FIELDS=(135,4,CH,D)
OUTFIL ENDREC=1,BUILD=(C'G_YEAR,''',135,4,C'''',80:X)
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file (FB/138)
//OUT1 DD SYSOUT=* records for greater year
//OUT2 DD SYSOUT=* records for lesser year
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=OUT1,INCLUDE=(135,4,CH,EQ,G_YEAR)
OUTFIL FNAMES=OUT2,SAVE
/*
|
|
|
Back to top |
|
|
Suresh Shankarakrishnan
New User
Joined: 11 Jul 2008 Posts: 42 Location: USA
|
|
|
|
Thanks again, Frank, that works !! |
|
Back to top |
|
|
Suresh Shankarakrishnan
New User
Joined: 11 Jul 2008 Posts: 42 Location: USA
|
|
|
|
Frank, could you please explain the following statement? Did some research, but the following statement is not clear....
Code: |
//SYSIN DD *
SORT FIELDS=(135,4,CH,D)
OUTFIL ENDREC=1,BUILD=(C'G_YEAR,''',135,4,C'''',80:X)'
|
thanks,
Suresh |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
The SORT statement sorts the records in descending order by the year field in positions 135-138. After the records are sorted, the highest year will be in the first record (e.g. 2009 if the years are 2009 and 2008).
The OUTFIL statement takes the first sorted record (ENDREC=1) which has the highest year, and creates a DFSORT symbol as follows:
G_YEAR,'yyyy'
where yyyy is the highest year.
Does that help? |
|
Back to top |
|
|
Suresh Shankarakrishnan
New User
Joined: 11 Jul 2008 Posts: 42 Location: USA
|
|
|
|
Thanks Frank, yes that helps. |
|
Back to top |
|
|
|