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
 

 

Retrieve current year or month using SORT card

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
vnktrrd

New User


Joined: 12 Jan 2010
Posts: 22
Location: india

PostPosted: Tue Mar 15, 2016 4:14 pm    Post subject: Retrieve current year or month using SORT card
Reply with quote

HI,

Due to huge data in the input file I want to extract only those records with current year in the first date field. It is in the format '2016/01/01'.
I want to do this by comparing the first 4 positions of the file to current year, current month and current date individually.

Please advise how to achieve this using sort card.

Input
2014mmdd
2015mmdd
2016mmdd

Output should be the records of the current year like below.
2016mmdd

I want the same for month and date as well.

Thanks,
Ramana.
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Tue Mar 15, 2016 4:17 pm    Post subject:
Reply with quote

If you want a sort solution why post in JCL & VSAM? Why didn't you post in the relevant sort sub-section of the forum. Also provide the full information re the dataset - RECFM, LRECL and representative data showing if duplicates could be present and whether they are in sort sequence or not.

Moving to DFSort but if you use Syncsort then say so and it will be moved there.
Back to top
View user's profile Send private message
vnktrrd

New User


Joined: 12 Jan 2010
Posts: 22
Location: india

PostPosted: Tue Mar 15, 2016 4:25 pm    Post subject:
Reply with quote

dataset is of format FB and LRECL is 95 with first field having date in 'YYYYMMDD' format.

There are duplicates in this field and file is sorted in descending order on this field.

Thanks.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Tue Mar 15, 2016 4:58 pm    Post subject: Reply to: Retrieve current year or month using SORT card
Reply with quote

Anything wrong with this, and similar?

Code:
 OPTION COPY
 INCLUDE COND=(1,4,CH,EQ,C'2016')
Back to top
View user's profile Send private message
vnktrrd

New User


Joined: 12 Jan 2010
Posts: 22
Location: india

PostPosted: Tue Mar 15, 2016 5:17 pm    Post subject:
Reply with quote

I want the year to be dynamic and match with the current year always.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Tue Mar 15, 2016 6:40 pm    Post subject: Reply to: Retrieve current year or month using SORT card
Reply with quote

I doubt that that is true, if you think about it.

First working day of January, you want nothing? Even if it is a December job running late?

You going to force testing data at various levels always to be for the current year? And prevent any testing of what happens around the year end?

Means you can never do a re-run without changing the code.

For what?

Sure you can do it. Not really sure that you really want to.

Code:
 OPTION COPY
 INCLUDE COND=(1,4,CH,EQ,DATE1)


You can read-up on the documentation of INCLUDE to see why it works.
Back to top
View user's profile Send private message
vnktrrd

New User


Joined: 12 Jan 2010
Posts: 22
Location: india

PostPosted: Tue Mar 15, 2016 8:30 pm    Post subject:
Reply with quote

DATE1 gives us the complete date. But I only want to compare with year.

I wont run this in prod so I don't have to bother about the issue you are mentioning.

Please advise.

Thanks
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Tue Mar 15, 2016 9:09 pm    Post subject: Reply to: Retrieve current year or month using SORT card
Reply with quote

I know what DATE1 means, and how long it is.

You can also chose from DATE2, DATE3, DATE4 and DATE5 for this. You can also put & in front of them.

I assumed you'd test it, and wonder how it worked, which is why I pointed you at how to understand how it works.

I wasn't expecting you to tell me it doesn't work without you trying. If you feel it doesn't work, then, well, you'll have to try something else.
Back to top
View user's profile Send private message
kranthikumarb

Active User


Joined: 02 Jan 2009
Posts: 114
Location: Hyderabad

PostPosted: Wed Mar 16, 2016 1:58 pm    Post subject: Reply to: Retrieve current year or month using SORT card
Reply with quote

vnktrrd,

if you dont find something that gives you CCYY only, you may use this

Code:

//STEP001  EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SYSPRINT DD SYSOUT=*                                         
//SORTIN   DD *                                                 
2015MMDD                                                       
2016MMDD                                                       
2014MMDD                                                       
2016DDMM                                                       
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
 INREC  OVERLAY=(96:DATE1)                                     
 SORT FIELDS=COPY                                               
 OUTFIL FNAMES=SORTOUT,BUILD=(1,95),INCLUDE=(96,4,CH,EQ,1,4,CH)
/*                                                             
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Mar 16, 2016 3:09 pm    Post subject: Reply to: Retrieve current year or month using SORT card
Reply with quote

kranthikumarb,

You didn't like my suggestion either?
Back to top
View user's profile Send private message
kranthikumarb

Active User


Joined: 02 Jan 2009
Posts: 114
Location: Hyderabad

PostPosted: Wed Mar 16, 2016 3:57 pm    Post subject:
Reply with quote

Bill,

I tried DATE1,2,3,4,5 etc. But couldn't get CCYY format. Just as a back up plan I gave this idea.

No doubt, your suggestion is easy way to do, if there is a way to get CCYY alone.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Wed Mar 16, 2016 5:19 pm    Post subject:
Reply with quote

Quote:
Just as a back up plan I gave this idea.


Would have been nice if this was known at the beginning.

Those who posted could have given it 'back up' effort as well.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Mar 16, 2016 6:10 pm    Post subject: Reply to: Retrieve current year or month using SORT card
Reply with quote

It is clear that no-one is actually trying what I suggested, so here it is in action:

Code:
//DATECCYY EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INCLUDE COND=(1,4,CH,EQ,DATE1)
                               
//SORTIN   DD *
20160316  THIS ONE
20151234  NOT THIS ONE
20141234  NOT THIS ONE EITHER
//DACCYYMM EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INCLUDE COND=(1,6,CH,EQ,DATE1)
                               
//SORTIN   DD *
20160316  THIS ONE
20151234  NOT THIS ONE
20141234  NOT THIS ONE EITHER
//DACCYYMM EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INCLUDE COND=(1,8,CH,EQ,DATE1)
                               
//SORTIN   DD *
20160316  THIS ONE
20151234  NOT THIS ONE
20141234  NOT THIS ONE EITHER
//DATECCYY EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INCLUDE COND=(1,4,CH,EQ,DATE1(/))
                                   
//SORTIN   DD *
2016/03/16  THIS ONE
20151234  NOT THIS ONE
20141234  NOT THIS ONE EITHER
//DACCYYMM EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INCLUDE COND=(1,6,CH,EQ,DATE1(/))
                                   
//SORTIN   DD *
2016/03/16  THIS ONE
20151234  NOT THIS ONE
20141234  NOT THIS ONE EITHER
//DACCYYMM EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INCLUDE COND=(1,8,CH,EQ,DATE1(/))
                                   
//SORTIN   DD *
2016/03/16  THIS ONE
20151234  NOT THIS ONE
20141234  NOT THIS ONE EITHER



Run that lot, and look at the SORTOUTs in the spool.

You will see

Code:
20160316  THIS ONE


as output from the first three steps, and

Code:
2016/03/16  THIS ONE


as output from the last three steps.

For those who not only don't run the suggested code, but don't read the suggested manual either:

Quote:
Tip: When a field is shorter than the character string it's compared to, DFSORT truncates the string on the right. You can take advantage of this to compare a field to only part of the DATE4 timestamp when appropriate. For example:
INCLUDE COND=(1,13,CH,GT,DATE4)
would compare the field in positions 1-13 to the truncated DATE4 constant C'yyyy-mm-dd-hh'.


What works with DATE4 in the example is not specific to DATE4, it works with all the date constants, edited or not.
Back to top
View user's profile Send private message
John Del

New User


Joined: 27 Apr 2012
Posts: 20
Location: NY

PostPosted: Wed Mar 16, 2016 10:11 pm    Post subject:
Reply with quote

If it is the current year and month, sort symbolics utilizing system symbolics.


Code:
CCYY,S'&LYR4'
CCYYMM,S'&LYR4.&LMON'

------------------ SYMBOL TABLE -----------------

CCYY,C'2016'
CCYYMM,C'201603'



If you want to use a previous date range, generate your own symbolics to be used in the sort step. You could configure to use them as a passed exec parm so that you can override the values as you need to.

Code:

// SET OBCDATE='CCYYMM'
//********************************************************
//* GENERATE DATE PARMS FOR DATA EXTRACTION
//********************************************************
//STEP0001 EXEC PGM=SORT,PARM=('JP0"&OBCDATE"')
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
CCYYMM  MMCCYY  MMDDCCYY  CCYYDDD
//DATEPARM DD DSN=&&S,DISP=(,PASS,DELETE),UNIT=SYSDA,SPACE=(TRK,(1,1))
//DATEPARX DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY,STOPAFT=1

* EDIT TO SEE IF THERE IS A PARM DATE OVERRIDE, OTHERWISE USE DEFAULT
*  FOR PREVIOUS MONTH, EXPECTS CCYYMM FORMAT AND CONVERTS TO JULIAN
*
  INREC IFOUTLEN=80,
         IFTHEN=(WHEN=(1,6,CH,NE,JP0),
            OVERLAY=(81:JP0,C'01',81:81,8,Y4T,TOJUL=Y4T,
                     1:81,7,10:81,7,Y4T,LASTDAYM,TOJUL=Y4T),HIT=NEXT),
          IFTHEN=(WHEN=(1,6,CH,EQ,JP0),
            OVERLAY=(81:DATE2-1,C'01',81:81,8,Y4T,TOJUL=Y4T,
                     1:81,7,10:81,7,Y4T,LASTDAYM,TOJUL=Y4T))

 * BUILD THE SYMBOLICS USED BY SORT
 *
   OUTFIL FNAMES=(DATEPARM,DATEPARX),
          BUILD=(C'BEG-DATE,',1,7,80:X,/,
                 C'END-DATE,',10,7,80:X)
/*
//STEP0002 EXEC PGM=SORT
//SYMNAMES DD DISP=SHR,DSN=&SYMBLIB(SYMCONST)
//         DD DISP=SHR,DSN=&&S
//SYMNOUT  DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DISP=SHR,DSN=&YOURFILE(0)
//SORTOUT  DD DSN=&OUTFILE(+1),
// DISP=(NEW,CATLG,DELETE),UNIT=POOL,SPACE=(TRK,(1,1),RLSE)
//SYSIN    DD *
  OPTION COPY
  INCLUDE COND=(SOME-DATE,GE,BEG-DATE,&,
                SOME-DATE,LE,END-DATE)





J
Back to top
View user's profile Send private message
John Del

New User


Joined: 27 Apr 2012
Posts: 20
Location: NY

PostPosted: Wed Mar 16, 2016 11:25 pm    Post subject:
Reply with quote

Bill -

Sorry, only afterwards did I get what you were saying. Please feel free to delete my previous post to avoid confusion.

This would be my solution that would allow users to dynamically override the date parm when based on year (year, month, day, what have you) :

Code:
// SET SYMBLIB='CR.#050.PROD.PARMLIB'
// SET OBCDATE='&LYR4'
//*SET OBCDATE='2015'
//*SET OBCDATE='&LYR4.&LMON'
//*SET OBCDATE='201603'
//********************************************************
//* GENERATE DATE PARMS FOR DATA EXTRACTION
//********************************************************
//STEP0001 EXEC PGM=SORT,PARM=('JP0"&OBCDATE"')
//SYMNAMES DD DISP=SHR,DSN=&SYMBLIB(SYMCONST)
//         DD *
MY-INPUT-RECORD,1,80,CH
  MY-INPUT-YEAR-ZD,=,4,ZD
   MY-INPUT-YEAR-CH,=,4,CH
  MY-INPUT-DAYS,*,3,ZD
  MY-INPUT-DONTCARE,*,73,CH
//SYMNOUT  DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
//SORTIN   DD *
20150316 PAST
2016014I.DONT.CARE.ABOUT.THE.REST
2017014 FUTURE
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY

  INCLUDE COND=(MY-INPUT-YEAR-CH,EQ,JP0)
/*

J
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Thu Mar 17, 2016 12:37 am    Post subject: Reply to: Retrieve current year or month using SORT card
Reply with quote

No problem John. Since I don't like the requirement, I prefer your solutions anyway :-)

I'd do this:

Code:
   MY-INPUT-YEAR-CH,=,=,CH


Just to keep the definition more bound to the original field.
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts Wishing everyone a very Happy Diwali ... Rohit Umarjikar General Talk & Fun Stuff 1 Sat Oct 29, 2016 1:54 am
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm


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