Problem solve Get help with specific problems with your technologies, process and projects.

Display Log (QHST) -- revisited

Displaying the history log for the previous day.

This is an alternative program for displaying the history log for the previous day (see the tip "DSPLOG QHST for...

a specific time). The attached CL code will take into account the system date format (for retrieving the system date and for the DSPLOG command) and will check for the first day of the year. I have seen issues with subtracting Julian dates across years. If it is the first day of the year, the last day of the previous year will be used in the DSPLOG command. Otherwise, the previous day will be used.


 
************************************ 
DCL        VAR(&DTFMT)  TYPE(*CHAR) LEN(3)                 
DCL        VAR(&SDATE)  TYPE(*CHAR) LEN(6)                 
DCL        VAR(&JDATE)  TYPE(*CHAR) LEN(5)                 
DCL        VAR(&JDATEN) TYPE(*DEC)  LEN(5 0)               
DCL        VAR(&DATE8)  TYPE(*CHAR) LEN(8)                 
DCL        VAR(&CCYY)   TYPE(*CHAR) LEN(4)                 
DCL        VAR(&MM)     TYPE(*CHAR) LEN(2)                 
DCL        VAR(&DD)     TYPE(*CHAR) LEN(2)                 
DCL        VAR(&CCYYN)  TYPE(*DEC)  LEN(4 0) 
DCL        VAR(&DDN)    TYPE(*DEC)  LEN(2 0)               

STEP00: 
RTVSYSVAL  SYSVAL(QDATFMT) RTNVAR(&DTFMT) 
 
STEP01: 
IF         COND(&DTFMT *EQ 'MDY') THEN(DO) 
RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&SDATE)   
CVTDAT     DATE(&SDATE) TOVAR(&JDATE) FROMFMT(*MDY) + 
            TOFMT(*JUL) TOSEP(*NONE) 
ENDDO 
 
IF         COND(&DTFMT *EQ 'YMD') THEN(DO)
RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&SDATE)  
CVTDAT     DATE(&SDATE) TOVAR(&JDATE) FROMFMT(*YMD) +  
            TOFMT(*JUL) TOSEP(*NONE) 
ENDDO
 
IF         COND(&DTFMT *EQ 'DMY') THEN(DO) 
RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&SDATE) 
CVTDAT     DATE(&SDATE) TOVAR(&JDATE) FROMFMT(*DMY) +
            TOFMT(*JUL) TOSEP(*NONE) 
ENDDO 

IF         COND(&DTFMT *EQ 'JUL') THEN(DO) 
RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&JDATE) 
ENDDO 
 
STEP02: 
CVTDAT     DATE(&JDATE) TOVAR(&DATE8) FROMFMT(*JUL) +
            TOFMT(*YYMD) TOSEP(*NONE)  
CHGVAR     VAR(&CCYY) VALUE(%SST(&DATE8 1 4))
CHGVAR     VAR(&MM) VALUE(%SST(&DATE8 5 2)) 
CHGVAR     VAR(&DD) VALUE(%SST(&DATE8 7 2)) 
CHGVAR     VAR(&DDN) VALUE(&DD) 
CHGVAR     VAR(&DDN) VALUE(&DDN - 1)
 
IF         COND(&DDN *EQ 00) THEN(DO) 
CHGVAR     VAR(&DD) VALUE('31') 
CHGVAR     VAR(&MM) VALUE('12') 
CHGVAR     VAR(&CCYYN) VALUE(&CCYY) 
CHGVAR     VAR(&CCYYN) VALUE(&CCYYN - 1)
CHGVAR     VAR(&CCYY) VALUE(&CCYYN)
CHGVAR     VAR(&DATE8) VALUE(&CCYY || &MM || &DD)
CVTDAT     DATE(&DATE8) TOVAR(&JDATE) FROMFMT(*YYMD) + 
            TOFMT(*JUL) TOSEP(*NONE) 
ENDDO 
ELSE       DO 
CHGVAR     VAR(&JDATEN) VALUE(&JDATE)
CHGVAR     VAR(&JDATEN) VALUE(&JDATEN - 1)
CHGVAR     VAR(&JDATE) VALUE(&JDATEN)
ENDDO 

STEP03:
IF COND(&DTFMT *EQ 'JUL') THEN(DO) 
   DSPLOG PERIOD((220000 &JDATE)) 
   GOTO END
   ENDDO

IF COND(&DTFMT *EQ 'MDY') THEN(DO)
   CVTDAT DATE(&JDATE) TOVAR(&SDATE) FROMFMT(*JUL) +
    TOFMT(*MDY) TOSEP(*NONE)
   ENDDO

IF COND(&DTFMT *EQ 'YMD') THEN(DO)
   CVTDAT DATE(&JDATE) TOVAR(&SDATE) FROMFMT(*JUL) +
    TOFMT(*YMD) TOSEP(*NONE)
   ENDDO

IF COND(&DTFMT *EQ 'DMY') THEN(DO)
   CVTDAT DATE(&JDATE) TOVAR(&SDATE) FROMFMT(*JUL) +
    TOFMT(*DMY) TOSEP(*NONE)
   ENDDO
                        
DSPLOG PERIOD((220000 &SDATE))

END: ENDPGM
********* End of data ******************************


==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: Tips, tutorials and more.

Ask your systems management questions--or help out your peers by answering them--in our live discussion forums.

Read this Search400.com Featured Topic: Managing your iSeries.

Ask the Experts yourself: Our systems management gurus are waiting to answer your technical questions.

Dig Deeper on Performance

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

SearchDataCenter

Close