Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to compare Packed date in details with System Date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
Floramq

New User


Joined: 18 May 2017
Posts: 2
Location: CAnada

PostPosted: Sun Jan 05, 2020 7:40 am    Post subject: How to compare Packed date in details with System Date
Reply with quote

!When I run the job now, I have these control statements:

Code:
 SORT FIELDS=COPY
INCLUDE COND=(110,5,PD,LT,20200101,
             AND,110,5,PD,GT,20181231)

but I want to dynamically use the system date. No matter when it runs within year NNNN, it should select all records for the preceding year NNNN-1... I see a few posts about using dates and SYMNAMES, but always in Character format...
I don't know how to use that for a compare with Packed Decimal field...

Thanks for any assistance,
Flora
Back to top
View user's profile Send private message

Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 292
Location: Bamberg, Germany

PostPosted: Mon Jan 06, 2020 10:42 am    Post subject:
Reply with quote

Something like this should work.
Code:
OPTION COPY
INREC OVERLAY=(200:110,5,Y4V,208:DATE1,             
               208:208,8,Y4T,SUBYEARS,+1,TOGREG=Y4T)
OUTFIL FNAMES=(SORTOUT),                           
  INCLUDE=(200,4,CH,EQ,208,4,CH)                   
END                                                 
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 810
Location: Maryland

PostPosted: Mon Jan 06, 2020 7:45 pm    Post subject:
Reply with quote

In order to dynamically produce two dates of the required range, several SORT date operations are needed; so, SYMSORT values cannot be used.

You may need to temporary reserve some space with each input record: 10 bytes - to produce two dates in format PD, or 16 bytes - to produce two dates in format ZD.
Code:
//YEARDEC  EXEC  PGM=SORT                                             
//SYSOUT   DD    SYSOUT=*                                             
//SORTIN   DD    *                                                   
20180331                                                             
20190331                                                             
20200331                                                             
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7
//SORTOUT  DD    SYSOUT=*                                             
//SYSIN    DD *                                                       
 INREC IFTHEN=(WHEN=INIT,                                             
               OVERLAY=(30:&DATE1P,&DATE1P)),                         
       IFTHEN=(WHEN=INIT,                                             
               OVERLAY=(30:30,5,Y4V,SUBYEARS,+2,TOGREG=(Y4V),         
                           35,5,Y4V,SUBYEARS,+1,TOGREG=(Y4V))),       
       IFTHEN=(WHEN=INIT,                                             
               OVERLAY=(30:30,5,Y4V,LASTDAYY,TOGREG=(Y4V),           
                           35,5,Y4V,LASTDAYY,TOGREG=(Y4V))),         
       IFTHEN=(WHEN=INIT,                                             
               OVERLAY=(30:30,5,Y4V,ADDDAYS,+1,TOGREG=(Y4V)))         
 SORT FIELDS=COPY                                                     
 OUTREC IFTHEN=(WHEN=(1,8,ZD,GE,30,5,PD,                             
                  AND,1,8,ZD,LE,35,5,PD),                             
                OVERLAY=(10:C'GOOD!')),                               
        IFTHEN=(WHEN=NONE,                                           
                OVERLAY=(10:C'BAD!'))                                 
 OUTFIL BUILD=(1,30,                                                 
            X,30,5,HEX,                                               
            X,35,5,HEX),                                             
        REMOVECC,                                                     
 HEADER1=('INDATE   COMPARED?             HEX FROM   HEX TO    ',     
        /,'-------- -------------         ---------- ----------')     
 END                                                                 

Code:
INDATE   COMPARED?             HEX FROM   HEX TO       
-------- -------------         ---------- ----------   
20180331 BAD!                  020190101C 020191231C   
20190331 GOOD!                 020190101C 020191231C   
20200331 BAD!                  020190101C 020191231C   
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 810
Location: Maryland

PostPosted: Mon Jan 06, 2020 8:18 pm    Post subject:
Reply with quote

The calculation can be simplified a little bit:

Code:
//YEARDEC  EXEC  PGM=SORT                                             
//SYSOUT   DD    SYSOUT=*                                             
//SORTIN   DD    *                                                   
20180331                                                             
20190331                                                             
20200331                                                             
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7
//SORTOUT  DD    SYSOUT=*                                             
//SYSIN    DD *                                                       
 INREC IFTHEN=(WHEN=INIT,                                             
               OVERLAY=(30:&DATE1P,&DATE1P)),                         
       IFTHEN=(WHEN=INIT,                                             
               OVERLAY=(30:30,5,Y4V,SUBYEARS,+2,TOGREG=(Y4V),         
                           35,5,Y4V,SUBYEARS,+1,TOGREG=(Y4V))),       
       IFTHEN=(WHEN=INIT,                                             
               OVERLAY=(30:30,5,Y4V,LASTDAYY,TOGREG=(Y4V),           
                           35,5,Y4V,LASTDAYY,TOGREG=(Y4V)))         
 SORT FIELDS=COPY                                                     
 OUTREC IFTHEN=(WHEN=(1,8,ZD,GT,30,5,PD,    compare to 12/31 two years ago                             
                  AND,1,8,ZD,LE,35,5,PD),   compare to 12/31 one year ago                             
                OVERLAY=(10:C'GOOD!')),                               
        IFTHEN=(WHEN=NONE,                                           
                OVERLAY=(10:C'BAD!'))                                 
 OUTFIL BUILD=(1,30,                                                 
            X,30,5,HEX,                                               
            X,35,5,HEX),                                             
        REMOVECC,                                                     
 HEADER1=('INDATE   COMPARED?             HEX FROM   HEX TO    ',     
        /,'-------- -------------         ---------- ----------')     
 END                                                                 
Back to top
View user's profile Send private message
Floramq

New User


Joined: 18 May 2017
Posts: 2
Location: CAnada

PostPosted: Tue Jan 07, 2020 1:32 am    Post subject: Reply to: How to compare Packed date in details with System Date
Reply with quote

Thank you both for such quick replies ! I will try these straight away
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 292
Location: Bamberg, Germany

PostPosted: Tue Jan 07, 2020 4:13 pm    Post subject:
Reply with quote

@Flora: You will have a little bit increased runtime depending on the amount of data for both solutions. This is due to the necessity to process data after they have passed the global INCLUDE you had specified.
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 -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts To convert numeric to Packed Decimal vinu78 DFSORT/ICETOOL 8 Fri Jul 31, 2020 7:14 pm
No new posts Populating Date and Sequence numer in... PORYES SYNCSORT 11 Thu Jul 16, 2020 5:01 pm
No new posts File transfer to remote system using ... kalyan.lc5 TSO/ISPF 2 Wed Jun 24, 2020 1:24 pm
No new posts How to filter out certain records bas... manugeorge2004 JCL & VSAM 5 Wed Jun 17, 2020 10:05 pm
No new posts reffering the filename with date and ... skbk JCL & VSAM 9 Sat Jun 06, 2020 4:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us