Description:
The last TPX logon date for a user is stored in variable VUSRDACC. If this value is blank, that means the user has never signed on to TPX. You cannot directly extract on a blank value for this variable. This batch example shows you how to manipulate extracted data to report and delete users that have never logged on to TPX.
Solution:
NOTE: These sort steps invoke CA-SORT. If you use a different sort utility then you will need to modify the sort step JCL and parameters accordingly.
//* THIS JCL INCLUDES A DELETE STEP *** //* //* Cannot extract directly on blank value for VUSRDACC, so... //* Extract all users and the last time they signed on to TPX //* then sort and include only those that have blank value. //* //* 1) Step BATCHEXT: The TPX batch job sends the RPTFILE to a //* catalogued dataset rather than SYSOUT. //* 2) Step SORT1: The first sort step captures the 2 title lines. //* 3) Step SORT2: The second sort step skips the title lines, //* then sorts the remaining lines that include only blank dates. //* 4) Step REPORT1: Print out original RPTFILE with all users. //* 5) Step REPORT2: Concatenates the titles and condensed report from //* the SORT steps into one SYSOUT file. //**6) Batch DELETE based on output from SORT2 step //* 7) Extract again to show results of delete //* //********************************************************************/ //* 1) Extract //********************************************************************/ //BATCHEXT EXEC TPX,VNODE='*BATCH*' //EXTFILE DD UNIT=SYSDA,SPACE=(CYL,(1,1)) //*RPTFILE DD SYSOUT=* //RPTFILE DD UNIT=SYSDA,SPACE=(CYL,(1,1)),DISP=(NEW,CATLG), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0), // DSN=userid.TPX.RPTFILE //* //SYSIN DD * EXTRACT GIVING(EXTFILE) USER AND NO SESSIONS (UIDXNAME(ABC-----)) SET RTITLE1 ' USERID Last TPX Logon - BLANK indicates have never signed on' SET RTITLE2 ' ======== ==============' REPORT GIVING(RPTFILE) USING(EXTFILE) (( ' &UIDXNAME' ' &VUSRDACC ')) /* //* //********************************************************************/ //* 2) Capture first 2 lines that are Title lines (STOPAFT=2) //********************************************************************/ //SORT1 EXEC PGM=SORT,REGION=1024K //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=A //SYSPUNCH DD SYSOUT=B //SYSPRINT DD SYSOUT=* //SORTIN DD DSN=userid.TPX.RPTFILE, // DISP=SHR //SORTOUT DD DSN=userid.TPX.RPTFILE.TITLES, // UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0), // SPACE=(TRK,(1,1)), // DISP=(NEW,CATLG) //SYSIN DD * SORT FIELDS=COPY,STOPAFT=2 /* //********************************************************************/ //* 3) Skip title lines, then include only blank dates //********************************************************************/ //SORT2 EXEC PGM=SORT,REGION=1024K //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=A //SYSPUNCH DD SYSOUT=B //SYSPRINT DD SYSOUT=* //SORTIN DD DSN=userid.TPX.RPTFILE, // UNIT=SYSDA, // DISP=SHR //SORTOUT DD DSN=userid.TPX.RPTFILE.BODY, // UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0), // SPACE=(TRK,(1,1)), // DISP=(NEW,CATLG) //SYSIN DD * SORT FIELDS=(1,40,AC,A), SKIPREC=3, FILSZ=50 INCLUDE COND=(12,8,CH,EQ,C' ') /* //********************************************************************/ //* 4) Generate original extract report with all userids //********************************************************************/ //REPORT1 EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DISP=SHR,DSN=userid.TPX.RPTFILE //SYSUT2 DD SYSOUT=* //SYSUT3 DD UNIT=3390,SPACE=(CYL,(10)) //SYSUT4 DD UNIT=3390,SPACE=(CYL,(10)) //SYSIN DD * GENERATE MAXFLDS=1 //********************************************************************/ //* 5) Generate report of the massaged data //********************************************************************/ //REPORT2 EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DISP=SHR,DSN=userid.TPX.RPTFILE.TITLES // DD DISP=SHR,DSN=userid.TPX.RPTFILE.BODY //SYSUT2 DD SYSOUT=* //SYSUT3 DD UNIT=3390,SPACE=(CYL,(10)) //SYSUT4 DD UNIT=3390,SPACE=(CYL,(10)) //SYSIN DD * GENERATE MAXFLDS=1 // //* S T O P S T O P S T O P S T O P //* Comment out the above // when you are ready to actually DELETE. //* This will allow you to first see how many users will be affected //* before making any actual updates. //* //********************************************************************/ //* 6) Extract and DELETE Users that have never signed on //********************************************************************/ //DELETE EXEC TPX,VNODE='*BATCH*' //EXTFILE DD UNIT=SYSDA,SPACE=(CYL,(1,1)) //RPTFILE DD SYSOUT=* //* //SYSIN DD * C C Extract the list of userids previously created C EXTRACT GIVING(EXTFILE) USER AND NO SESSIONS (UIDXNAME( // DD DISP=SHR,DSN=userid.TPX.RPTFILE.BODY // DD * )) SET RTITLE1 ' USERID Last TPX Logon - BLANK indicates have never signed on' SET RTITLE2 ' ======== ==============' REPORT GIVING(RPTFILE) USING(EXTFILE) (( ' &UIDXNAME' ' &VUSRDACC ')) C DELETE USER USING(EXTFILE) C /* //* //********************************************************************/ //* 7) Final report on all remaining users with userid=ABC* //********************************************************************/ //FINALRPT EXEC TPX,VNODE='*BATCH*' //EXTFILE DD UNIT=SYSDA,SPACE=(CYL,(1,1)) //RPTFILE DD SYSOUT=* //* //SYSIN DD * C C List all users and the date they last logged on. (userid=ABC*) C EXTRACT GIVING(EXTFILE) USER AND NO SESSIONS (UIDXNAME(ABC-----)) SET RTITLE1 ' POST-DELETE - There should be no more userids with blank logon date' SET RTITLE2 ' USERID Last TPX Logon - BLANK indicates have never signed on' SET RTITLE3 ' ======== ==============' REPORT GIVING(RPTFILE) USING(EXTFILE) (( ' &UIDXNAME' ' &VUSRDACC ')) /*