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
 

 

Date condition

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

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Tue Jul 02, 2013 10:46 pm    Post subject: Date condition
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: 1715
Location: UK

PostPosted: Tue Jul 02, 2013 10:55 pm    Post subject:
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: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 12:03 am    Post subject: Reply to: Date condition
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: 7913
Location: Bellevue, IA

PostPosted: Wed Jul 03, 2013 12:18 am    Post subject:
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: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 12:31 am    Post subject: Reply to: Date condition
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Jul 03, 2013 12:49 am    Post subject: Reply to: Date condition
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: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 2:29 am    Post subject: Reply to: Date condition
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Jul 03, 2013 3:28 am    Post subject: Reply to: Date condition
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: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 12:13 pm    Post subject: Reply to: Date condition
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    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 TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
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
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Add system date inside of a PS file a... pramitdas DFSORT/ICETOOL 5 Sun Aug 28, 2016 12:06 am


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