Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Dynamically changing value in 'include cond' when using Sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Dynamically changing value in 'include cond' when using Sort
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Sat Jul 12, 2008 3:23 pm    Post subject: Reply to: Dynamically changing value in 'include cond' when
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    Post subject:
Reply with quote

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

DFSORT Moderator


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

PostPosted: Sat Jul 12, 2008 8:58 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Sat Jul 12, 2008 9:17 pm    Post subject: Reply to: Dynamically changing value in 'include cond' when
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Tue Jul 15, 2008 1:15 am    Post subject:
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    Post subject: Reply to: Dynamically changing value in 'include cond' when
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    Post subject:
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 Moderator


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

PostPosted: Wed Jul 16, 2008 2:15 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us