Assign system date & time to a mainframe dataset

How to add current date & time stamp to a mainframe dataset using sort JCL. Use the OUTFIL control statements DATENS & TIME1.

DATENS: To assign the date in the given format YYYYMMDD
DATENS=(4MD): To assign a date in the form ‘YYYYMMDD’
TIME1: To assign the timestamp in the given format HHMMSS
66X: To fill the remaining position with spaces to make logical length of 80

Execute the JCL and see the output file.

There are more Date & Time formats available to use it in SORT OUTFIL control statement. Refer the IBM manual for more details.