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

Date condition


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

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Tue Jul 02, 2013 10:46 pm
Reply with quote

Hi,

I have requirement to check date condition using sort.

Input is

Code:

f1  date1   date2     f2
--- -------- -------- ---
asd 20131209 20131208 dsd
dbd 20130930 20131209 esd
sds 20130923 20131213 fsd


if date1 < 20130930 then i need move date2 to date1
if date1 >= 20130930 then i need to move the fixed date 20130930 to date1

output should be
Code:

asd 20130930 20131208 dsd
dbd 20130930 20131209 esd
sds  20131213 20131213 fsd


I am also working on this, If i complete it i will post the code. Some one already done this, please share it with me.

Regards,
Magesh
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Jul 02, 2013 10:55 pm
Reply with quote

Forget the fact that they are dates! In the format shown they are just numbers and can be directly compared as numeric (or character) fields.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 12:03 am
Reply with quote

Hi,

I could get the second condition, could some one help me in getting first condition.

condition 1 : if date1 < 20130930 then i need to move date2 to date1
condition 2 : if date1 >= 20130930 then i need to move the fixed date 20130930 to date1

Code:

//STEP01 EXEC PGM=SORT                               
//SORTIN DD *                                       
20131209 20131208                                   
20130930 20131209                                   
20130923 20131213                                   
//SORTOUT DD SYSOUT=*                               
//SYSOUT DD SYSOUT=*                                 
//SYSIN DD *                                         
  SORT FIELDS=COPY                                   
  OUTREC IFTHEN=(WHEN=(1,8,CH,GE,C'20130930'),       
  OVERLAY=(1:C'20130930'))                           
/*                                                   


Regards,
Magesh
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jul 03, 2013 12:18 am
Reply with quote

Have you looked in your copy of the sort manual for the syntax of the OVERLAY statement?
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 12:31 am
Reply with quote

Thanks got it,

Code:

//STEP01 EXEC PGM=SORT                                           
//SORTIN DD *                                                     
ASD 20131209 20131208 DSD                                         
DBD 20130930 20131209 ESD                                         
SDS 20130923 20131213 FSD                                         
//SORTOUT DD SYSOUT=*                                             
//SYSOUT DD SYSOUT=*                                             
//SYSIN DD *                                                     
  SORT FIELDS=COPY                                               
  OUTREC IFTHEN=(WHEN=(4,8,CH,LT,C'20130930'),OVERLAY=(4:13,8)), 
         IFTHEN=(WHEN=(4,8,CH,GE,C'20130930'),                   
  OVERLAY=(4:C'20130930'))                                       
/*                                                               


Regards,
Magesh
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 03, 2013 12:49 am
Reply with quote

Good for getting there yourself.

However.

You give yourself a maintenance problem doing it that way. What if you need to change the date for the test, but you typo/forget one of them?
Code:

//STEP01 EXEC PGM=SORT                                           
//SORTIN DD *                                                     
ASD 20131209 20131208 DSD                                         
DBD 20130930 20131209 ESD                                         
SDS 20130923 20131213 FSD                                         
//SORTOUT DD SYSOUT=*                                             
//SYSOUT DD SYSOUT=*                                             
//SYSIN DD *                                                     
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=(4,8,CH,LT,C'20130930'),
                 OVERLAY=(4:13,8)),
        IFTHEN=(WHEN=NONE,                   
                 OVERLAY=(4:C'20130930'))                                       
/*               


Symbols would also help, but everyone's too busy to save themselves time :-)

Code:

//STEP01 EXEC PGM=SORT                                           
//SYMNAMES DD *
ACCOUNT-ANALYSIS-DATE,4,8,CH
ACCOUNT-START-DATE,13,8,CH
CUTOFF-DATE,C'20130930'
//SYMNOUT DD SYSOUT=*
//SORTIN DD *                                                     
ASD 20131209 20131208 DSD                                         
DBD 20130930 20131209 ESD                                         
SDS 20130923 20131213 FSD                                         
//SORTOUT DD SYSOUT=*                                             
//SYSOUT DD SYSOUT=*                                             
//SYSIN DD *                                                     

  SORT FIELDS=COPY                                               

  INREC IFTHEN=(WHEN=(ACCOUNT-ANALYSIS-DATE,
                       LT,CUTOFF-DATE),
                 OVERLAY=(ACCOUNT-ANALYSIS-DATE:
                           ACCOUNT-START-DATE)),

        IFTHEN=(WHEN=NONE,                   
                 OVERLAY=(ACCOUNT-ANALYSIS-DATE:
                           CUTOFF-DATE))                                                 

/*               
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 2:29 am
Reply with quote

Thanks Bill,

But My out of the jcl looks different

ASD 20131209 20131208 DSD
DBD 20131200 20131209 ESD
SDS 20131213 20131213 FSD

why it showing 00

output took from spool

Code:


------- ORIGINAL STATEMENTS FROM SYMNAMES -------                 
ACCOUNT-ANALYSIS-DATE,4,8,CH                                     
ACCOUNT-START-DATE,13,8,CH                                       
CUTOFF-DATE,C'20130930'                                           
                                                                 
------------------ SYMBOL TABLE -----------------                 
ACCOUNT-ANALYSIS-DATE,4,8,CH                                     
ACCOUNT-START-DATE,13,8,CH                                       
CUTOFF-DATE,C'20130930'                                           
ASD 20131209 20131208 DSD                                         
DBD 20131200 20131209 ESD                                         
SDS 20131213 20131213 FSD                                         
ICE270I 0 PROCESSING SYMNAMES STATEMENTS                         
ICE280I 1 ORIGINAL STATEMENTS FROM SYSIN    FOLLOW               
            SORT FIELDS=COPY                                     
            INREC IFTHEN=(WHEN=(ACCOUNT-ANALYSIS-DATE,           
                                 LT,CUTOFF-DATE),                 
                           OVERLAY=(ACCOUNT-ANALYSIS-DATE:
                                     ACCOUNT-START-DATE)),     
                  IFTHEN=(WHEN=NONE,                           
                           OVERLAY=(ACCOUNT-ANALYSIS-DATE:     
                                     CUTOFF-DATE))             
ICE282I 0 PERFORMING SYMBOL SUBSTITUTION AS NEEDED             
ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                       


JCL
Code:

//STEP01 EXEC PGM=SORT                                   
//SYMNAMES DD *                                         
ACCOUNT-ANALYSIS-DATE,4,8,CH                             
ACCOUNT-START-DATE,13,8,CH                               
CUTOFF-DATE,C'20130930'                                 
//SYMNOUT DD SYSOUT=*                                   
//SORTIN DD *                                           
ASD 20131209 20131208 DSD                               
DBD 20130930 20131209 ESD                               
SDS 20130923 20131213 FSD                               
//SORTOUT DD SYSOUT=*                                   
//SYSOUT DD SYSOUT=*                                     
//SYSIN DD *                                             
  SORT FIELDS=COPY                                       
  INREC IFTHEN=(WHEN=(ACCOUNT-ANALYSIS-DATE,             
                       LT,CUTOFF-DATE),                 
                 OVERLAY=(ACCOUNT-ANALYSIS-DATE:         
                           ACCOUNT-START-DATE)),         
        IFTHEN=(WHEN=NONE,                               
                 OVERLAY=(ACCOUNT-ANALYSIS-DATE:         
                           CUTOFF-DATE))                 
/*                                                       


Regards,
Magesh
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 03, 2013 3:28 am
Reply with quote

Well, I didn't test mine. Did you test yours?

If your sample data is accurate, your start positions are wrong. I just copied those from your Control Cards, I didn't think to check them :-)

Now, what you do is change this:

Code:
ACCOUNT-ANALYSIS-DATE,4,8,CH                                     
ACCOUNT-START-DATE,13,8,CH                                       

to this:
Code:

ACCOUNT-ANALYSIS-DATE,5,8,CH                                     
ACCOUNT-START-DATE,14,8,CH   


You can compare to see how many places you'd have had to correct it in your original...
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 12:13 pm
Reply with quote

Oversight error, Sorry, thanks, Now it is fine.

Regards,
Magesh
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
No new posts Fetch data from programs execute (dat... DB2 3
Search our Forums:

Back to Top