IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Dynamically changing value in 'include cond' when using Sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Suresh Shankarakrishnan

New User


Joined: 11 Jul 2008
Posts: 42
Location: USA

PostPosted: Sat Jul 12, 2008 7:16 am
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Jul 12, 2008 3:23 pm
Reply with quote

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
View user's profile Send private message
Suresh Shankarakrishnan

New User


Joined: 11 Jul 2008
Posts: 42
Location: USA

PostPosted: Sat Jul 12, 2008 4:05 pm
Reply with quote

Thanks enrico - will give it a shot.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Jul 12, 2008 8:58 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Jul 12, 2008 9:17 pm
Reply with quote

Thank You Frank for the clarification !
Back to top
View user's profile Send private message
Suresh Shankarakrishnan

New User


Joined: 11 Jul 2008
Posts: 42
Location: USA

PostPosted: Sun Jul 13, 2008 6:24 pm
Reply with quote

Thanks Frank! Appreciate it.
Back to top
View user's profile Send private message
Suresh Shankarakrishnan

New User


Joined: 11 Jul 2008
Posts: 42
Location: USA

PostPosted: Mon Jul 14, 2008 4:29 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Jul 15, 2008 1:15 am
Reply with quote

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
View user's profile Send private message
Suresh Shankarakrishnan

New User


Joined: 11 Jul 2008
Posts: 42
Location: USA

PostPosted: Tue Jul 15, 2008 11:32 pm
Reply with quote

Thanks again, Frank, that works !! icon_biggrin.gif
Back to top
View user's profile Send private message
Suresh Shankarakrishnan

New User


Joined: 11 Jul 2008
Posts: 42
Location: USA

PostPosted: Wed Jul 16, 2008 1:44 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jul 16, 2008 2:15 am
Reply with quote

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
View user's profile Send private message
Suresh Shankarakrishnan

New User


Joined: 11 Jul 2008
Posts: 42
Location: USA

PostPosted: Wed Jul 16, 2008 7:33 am
Reply with quote

Thanks Frank, yes that helps.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top