How to obtain only current YEAR and subtract years from it?



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

How to obtain only current YEAR and subtract years from it?

Postby prisgs » Thu Nov 17, 2022 11:27 pm

Hello!
I need to work with records (read from a work file), whose values for the YEARS field (it is a numeric field in position 1, with length 4) need to be in a range: INITIAL YEAR (CURRENT YEAR - 4) and FINAL YEAR (CURRENT YEAR - 1).
My issue is about how to obtain the current year, in a simple way for this case, and use it subtracting values... here is a sample code of what I would like to work with INITIAL-YEAR and FINAL-YEAR:
   SORT FIELDS=COPY          
   OMIT COND=(1,4,ZD,LT,INITIAL-YEAR,AND,
              1,4,ZD,GT,FINAL-YEAR)

If anyone could help me, I'd appretiate it.
Thanks in advance.
prisgs
 
Posts: 5
Joined: Thu Nov 17, 2022 6:54 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to obtain only current YEAR and subtract years from

Postby sergeyken » Fri Nov 18, 2022 12:58 am

prisgs wrote:Hello!
I need to work with records (read from a work file), whose values for the YEARS field (it is a numeric field in position 1, with length 4) need to be in a range: INITIAL YEAR (CURRENT YEAR - 4) and FINAL YEAR (CURRENT YEAR - 1).
My issue is about how to obtain the current year, in a simple way for this case, and use it subtracting values... here is a sample code of what I would like to work with INITIAL-YEAR and FINAL-YEAR:
   SORT FIELDS=COPY          
   OMIT COND=(1,4,ZD,LT,INITIAL-YEAR,AND,
              1,4,ZD,GT,FINAL-YEAR)

If anyone could help me, I'd appretiate it.
Thanks in advance.


Search all content by "YEAR", and/or "DATE"
https://www-40.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R3sc236880/$file/iceg200_v2r3.pdf

None of SORT utilities does allow use of dashes in field/values names (unlike COBOL)
INITIAL-YEAR



Where are any results of your attempts?
Any error message, or whatever else, at all??
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 425
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 7 times
Been thanked: 40 times

Re: How to obtain only current YEAR and subtract years from

Postby sergeyken » Fri Nov 18, 2022 1:35 am

Everything is described in detail in almost any of available manuals.

Did you hear about Google Search?

The working example is as primitive as 1st grade student exercise...

//SORT     EXEC PGM=SORT              
//SYSOUT   DD  SYSOUT=*              
//SORTIN   DD  *                      
20110101                              
20111231                              
20120101                              
20121231                              
20130101                              
20131231                              
20140101                              
20141231                              
20150101                              
20151231                              
20160101                              
20161231                              
20170101                              
20171231                              
20180101                              
20181231                              
20190101                              
20191231                              
20200101                              
20201231                              
20210101                              
20211231                              
20220101                                              
20221231                                              
20230101                                              
20231231                                              
20240101                                              
20241231                                              
20250101                                              
20251231                                              
20260101                                              
20261231                                              
20270101                                              
20271231                                              
20280101                                              
20281231                                              
20290101                                              
20291231                                              
//*                                                    
//SORTOUT1 DD  SYSOUT=*                                
//SORTOUT2 DD  SYSOUT=*                                
//*                                                    
//SYSIN    DD  *                                      
 SORT FIELDS=COPY                                      
 OUTREC BUILD=(1,10,DATE1)                            
  OUTFIL FNAMES=SORTOUT1,                          
        OVERLAY=(30:C'SORTOUT1'),                  
        INCLUDE=(1,4,CH,GE,DATE1-1461,   = 365*4 + 1  
             AND,1,4,CH,LE,DATE1-365)    = 365*1  
 OUTFIL FNAMES=SORTOUT2,                          
        OVERLAY=(30:C'SORTOUT2'),                  
        SAVE                                      
 END                                                  
//*                                                  


20180101  20221117           SORTOUT1  
20181231  20221117           SORTOUT1  
20190101  20221117           SORTOUT1  
20191231  20221117           SORTOUT1  
20200101  20221117           SORTOUT1  
20201231  20221117           SORTOUT1  
20210101  20221117           SORTOUT1  
20211231  20221117           SORTOUT1  


20110101  20221117           SORTOUT2  
20111231  20221117           SORTOUT2  
20120101  20221117           SORTOUT2  
20121231  20221117           SORTOUT2  
20130101  20221117           SORTOUT2  
20131231  20221117           SORTOUT2  
20140101  20221117           SORTOUT2  
20141231  20221117           SORTOUT2  
20150101  20221117           SORTOUT2  
20151231  20221117           SORTOUT2  
20160101  20221117           SORTOUT2  
20161231  20221117           SORTOUT2  
20170101  20221117           SORTOUT2  
20171231  20221117           SORTOUT2  
20220101  20221117           SORTOUT2  
20221231  20221117           SORTOUT2  
20230101  20221117           SORTOUT2  
20231231  20221117           SORTOUT2  
20240101  20221117           SORTOUT2  
20241231  20221117           SORTOUT2  
20250101  20221117           SORTOUT2  
20251231  20221117           SORTOUT2  
20260101  20221117           SORTOUT2  
20261231  20221117           SORTOUT2    
20270101  20221117           SORTOUT2    
20271231  20221117           SORTOUT2    
20280101  20221117           SORTOUT2    
20281231  20221117           SORTOUT2    
20290101  20221117           SORTOUT2    
20291231  20221117           SORTOUT2    


I hope changing the 'OUTFIL INCLUDE=' to 'INCLUDE COND=' should not be a problem?
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 425
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 7 times
Been thanked: 40 times

Re: How to obtain only current YEAR and subtract years from

Postby prisgs » Fri Nov 18, 2022 6:27 pm

sergeyken wrote:Everything is described in detail in almost any of available manuals.

Did you hear about Google Search?


I used Google search in my research, but all topics especific for this matter (finding the current year) that appeared were from community foruns, and in some of then the question was not resolved, and in another ones, the solutions were a bit complex to understand.
In manuals, I only found out how to obtain the current date. Could you please send me the link to the manual where there's this example?

But thanks for the example, in any case.
prisgs
 
Posts: 5
Joined: Thu Nov 17, 2022 6:54 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post