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

Sorting Date Field


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

New User


Joined: 12 Feb 2024
Posts: 14
Location: India

PostPosted: Tue Sep 03, 2024 4:49 pm
Reply with quote

Hi All,

I have the input as below in my input dataset:

Code:
=COLS> ----+----1----+----2----+----3----+----4
000001 AAAAAAAA A01023420  26 May 2024
000002 BBBBBBBB B01914562  NO PASSPHRASE
000003 CCCCCCCC C01978902  NO PASSPHRASE
000004 DDDDDDDD D01222435  23 Sep 2024
000005 EEEEEEEE Z20044447  21 Oct 2024
000006 FFFFFFFF F01045630   5 Mar 2024
000007 GGGGGGGG A00022120   1 Jan 2025
000008 HHHHHHHH H01442220   1 Jan 2025
000009 IIIIIIII I04938520   1 Jan 2025
000010 JJJJJJJJ J01982220   1 Jan 2025
000011 KKKKKKKK K01045326   1 Jan 2025
000012 LLLLLLLL L01003292  29 Oct 2024
000013 MMMMMMMM M01005826   1 Jan 2025
000014 NNNNNNNN N01005567   1 Jan 2025
000015 OOOOOOOO O01027892  21 Mar 2025
000016 PPPPPPPP P01039102  21 Mar 2025
000017 QQQQQQQQ Q01001253  21 Mar 2025
000018 RRRRRRRR R01000984  21 Mar 2025
000019 SSSSSSSS S02207635   6 Dec 2024
000020 TTTTTTTT T05829220   6 Dec 2024
000021 UUUUUUUU U20456887  18 Apr 2025
000022 VVVVVVVV V24697617  18 Apr 2025
000023 WWWWWWWW W01003333  26 May 2024
000024 XXXXXXXX X01987245  NO PASSPHRASE
000025 YYYYYYYY Y01368352  NO PASSPHRASE
000026 ZZZZZZZZ Z01934905  NO PASSPHRASE


I would like to sort the column that starts from position 21 by oldest date. Here the oldest date is 5 Mar 2024. So this record should come first and then the records belongs to 26 May 2024 and so on. I am ok with the sequence on those records that contains 'NO PASSPHRASE' at position 21

Both my input & output datasets are FB, 80, 800.

I tried the below sort option but it is not giving the desired output :

Code:
//STEP0100 EXEC PGM=SORT
//SYSPRINT DD  SYSOUT=*
//SYSOUT   DD  SYSOUT=*
//SORTIN   DD  DSN=Input Dataset,DISP=SHR
//SORTOUT  DD  DSN=Output Dataset,DISP=SHR
//SYSIN    DD  *
  SORT FIELDS=(28,04,Y2W,A)
  SORT FIELDS=COPY
/*


The sample required output should be :

Code:
=COLS> ----+----1----+----2----+----3----+----4
000001 FFFFFFFF F01045630   5 Mar 2024
000002 AAAAAAAA A01023420  26 May 2024
000003 WWWWWWWW W01003333  26 May 2024
000004 DDDDDDDD D01222435  23 Sep 2024
000005 EEEEEEEE Z20044447  21 Oct 2024
000012 LLLLLLLL L01003292  29 Oct 2024
000013 SSSSSSSS S02207635   6 Dec 2024
000014 TTTTTTTT T05829220   6 Dec 2024
000015 GGGGGGGG A00022120   1 Jan 2025
000016 HHHHHHHH H01442220   1 Jan 2025
000017 IIIIIIII I04938520   1 Jan 2025
000018 JJJJJJJJ J01982220   1 Jan 2025
000019 KKKKKKKK K01045326   1 Jan 2025


And so on....the records that contains 'NO PASSPHRASE' should also be there in the output. Can someone help me here please?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue Sep 03, 2024 6:59 pm
Reply with quote

Code:
ALTSEQ CODE=(D7FF)                                         
INREC IFTHEN=(WHEN=INIT,                                   
  OVERLAY=(81:28,4,                                       
              24,3,CHANGE=(2,C'Jan',C'01',                 
                             C'Feb',C'02',                 
                             C'Mar',C'03',                 
                             C'Apr',C'04',                 
                             C'May',C'05',                 
                             C'Jun',C'06',                 
                             C'Jul',C'07',                 
                             C'Aug',C'08',                 
                             C'Sep',C'09',                 
                             C'Oct',C'10',                 
                             C'Nov',C'11',                 
                             C'Dec',C'12'),NOMATCH=(C'00'),
              21,2,JFY=(SHIFT=RIGHT,LEAD=C'0')))           
SORT FIELDS=(81,8,AQ,A,1,8,CH,A)                                   
OUTFIL FNAMES=(SORTOUT),                                   
  REMOVECC,BUILD=(1,80)                                   
END

o/p
Code:
**************************** Datenanfang ******
FFFFFFFF F01045630   5 Mar 2024 
AAAAAAAA A01023420  26 May 2024 
WWWWWWWW W01003333  26 May 2024 
DDDDDDDD D01222435  23 Sep 2024 
EEEEEEEE Z20044447  21 Oct 2024 
LLLLLLLL L01003292  29 Oct 2024 
SSSSSSSS S02207635   6 Dec 2024 
TTTTTTTT T05829220   6 Dec 2024 
GGGGGGGG A00022120   1 Jan 2025 
HHHHHHHH H01442220   1 Jan 2025 
IIIIIIII I04938520   1 Jan 2025 
JJJJJJJJ J01982220   1 Jan 2025 
KKKKKKKK K01045326   1 Jan 2025 
MMMMMMMM M01005826   1 Jan 2025 
NNNNNNNN N01005567   1 Jan 2025 
OOOOOOOO O01027892  21 Mar 2025 
PPPPPPPP P01039102  21 Mar 2025 
QQQQQQQQ Q01001253  21 Mar 2025 
RRRRRRRR R01000984  21 Mar 2025 
UUUUUUUU U20456887  18 Apr 2025 
VVVVVVVV V24697617  18 Apr 2025 
BBBBBBBB B01914562  NO PASSPHRASE
CCCCCCCC C01978902  NO PASSPHRASE
XXXXXXXX X01987245  NO PASSPHRASE
YYYYYYYY Y01368352  NO PASSPHRASE
ZZZZZZZZ Z01934905  NO PASSPHRASE
**************************** Datenende ********
Back to top
View user's profile Send private message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 14
Location: India

PostPosted: Tue Sep 03, 2024 7:31 pm
Reply with quote

Thank you for your swift help. FYI, I am getting the output as below :

Code:
FFFFFFFF F01045630   5 Mar 2024
SSSSSSSS S02207635   6 Dec 2024
TTTTTTTT T05829220   6 Dec 2024
EEEEEEEE Z20044447  21 Oct 2024
DDDDDDDD D01222435  23 Sep 2024
AAAAAAAA A01023420  26 May 2024
WWWWWWWW W01003333  26 May 2024 
LLLLLLLL L01003292  29 Oct 2024
GGGGGGGG A00022120   1 Jan 2025
HHHHHHHH H01442220   1 Jan 2025
IIIIIIII I04938520   1 Jan 2025
JJJJJJJJ J01982220   1 Jan 2025
KKKKKKKK K01045326   1 Jan 2025
MMMMMMMM M01005826   1 Jan 2025
NNNNNNNN N01005567   1 Jan 2025
UUUUUUUU U20456887  18 Apr 2025
VVVVVVVV V24697617  18 Apr 2025
OOOOOOOO O01027892  21 Mar 2025
PPPPPPPP P01039102  21 Mar 2025
QQQQQQQQ Q01001253  21 Mar 2025
RRRRRRRR R01000984  21 Mar 2025
BBBBBBBB B01914562  NO PASSPHRASE
CCCCCCCC C01978902  NO PASSPHRASE
XXXXXXXX X01987245  NO PASSPHRASE
YYYYYYYY Y01368352  NO PASSPHRASE
ZZZZZZZZ Z01934905  NO PASSPHRASE


Can you please see and suggest?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue Sep 03, 2024 7:36 pm
Reply with quote

I do get for the data provided:
Code:
FFFFFFFF F01045630   5 Mar 2024   
AAAAAAAA A01023420  26 May 2024   
WWWWWWWW W01003333  26 May 2024   
DDDDDDDD D01222435  23 Sep 2024   
EEEEEEEE Z20044447  21 Oct 2024   
LLLLLLLL L01003292  29 Oct 2024   
SSSSSSSS S02207635   6 Dec 2024   
TTTTTTTT T05829220   6 Dec 2024   
GGGGGGGG A00022120   1 Jan 2025   
HHHHHHHH H01442220   1 Jan 2025   
IIIIIIII I04938520   1 Jan 2025   
JJJJJJJJ J01982220   1 Jan 2025   
KKKKKKKK K01045326   1 Jan 2025   
MMMMMMMM M01005826   1 Jan 2025   
NNNNNNNN N01005567   1 Jan 2025   
OOOOOOOO O01027892  21 Mar 2025   
PPPPPPPP P01039102  21 Mar 2025   
QQQQQQQQ Q01001253  21 Mar 2025   
RRRRRRRR R01000984  21 Mar 2025   
UUUUUUUU U20456887  18 Apr 2025   
VVVVVVVV V24697617  18 Apr 2025   
BBBBBBBB B01914562  NO PASSPHRASE
CCCCCCCC C01978902  NO PASSPHRASE
XXXXXXXX X01987245  NO PASSPHRASE
YYYYYYYY Y01368352  NO PASSPHRASE
ZZZZZZZZ Z01934905  NO PASSPHRASE


Check that your i/p is FB something please.
Back to top
View user's profile Send private message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 14
Location: India

PostPosted: Tue Sep 03, 2024 10:13 pm
Reply with quote

Both my input and output files are FB,80,800 Joerg.

FYI, in total my input has 86 records and I just mentioned few sample records here as input. I sense, it might be due to the below while sorting the fields :

Code:
SORT FIELDS=(81,8,AQ,A,1,8,CH,A)


Basically, the sort should happen only on third column and it is considering date(5, 6, 21, 23, 29 - irrespective of month) which is in 21st position. That's why I am getting out as mentioned in the previous post.

Since you are getting the desired output, do I need to look at any settings here?
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 COBOL sorting, with input GDG base COBOL Programming 7
No new posts Date format correction using dfsort DFSORT/ICETOOL 3
No new posts CONVERT a given date from UTC TO BST CICS 0
No new posts Pull data using date difference betwe... DB2 6
No new posts CA7 count with DATE variable CA Products 0
Search our Forums:

Back to Top