To give error messages with COLOR based on severity

If you would like to give error messages with COLOR based on severity, use the HexaDecimal color codes to send Colored Error messages. You can change the program to send messages with different colors based on severity.


 
 PGM        PARM(&MSGID)                                   
 DCL        VAR(&MSG) TYPE(*CHAR) LEN(78)                  
 DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)                 
 DCL        VAR(&SEV) TYPE(*DEC) LEN(2)                    
 DCL        VAR(&MSGDTA) TYPE(*CHAR) LEN(78)               
 DCL        VAR(&BLUE) TYPE(*CHAR) LEN(1) VALUE(X'3A')     
 DCL        VAR(&WHITE) TYPE(*CHAR) LEN(1) VALUE(X'22')    
 DCL        VAR(&RED) TYPE(*CHAR) LEN(1) VALUE(X'28')      
 DCL        VAR(&GREEN) TYPE(*CHAR) LEN(1) VALUE(X'40')    
 DCL        VAR(&PINK) TYPE(*CHAR) LEN(1) VALUE(X'38')     
 DCL        VAR(&TURQ) TYPE(*CHAR) LEN(1) VALUE(X'30')     
 DCL        VAR(&YELL) TYPE(*CHAR) LEN(1) VALUE(X'32')     
 DCL        VAR(&RIMG) TYPE(*CHAR) LEN(1) VALUE(X'21')     
 DCL        VAR(&UNDER) TYPE(*CHAR) LEN(1) VALUE(X'24')    
 DCL        VAR(&DELIM) TYPE(*CHAR) LEN(1) VALUE(X'20')    
 DCL        VAR(&COLOR) TYPE(*CHAR) LEN(1)                 
                                                           
 RTVMSG     MSGID(&MSGID) MSGF(QCPFMSG) MSG(&MSG) SEV(&SEV)
                                                           
 IF         COND(&SEV = 00) THEN(CHGVAR VAR(&COLOR) +      
              VALUE(&WHITE))                             
                                                         
 IF         COND(&SEV > 00) THEN(CHGVAR VAR(&COLOR) +    
              VALUE(&PINK))                              
                                                         
 IF         COND(&SEV >= 30) THEN(CHGVAR VAR(&COLOR) +   
              VALUE(&YELL))                              
                                                         
 IF         COND(&SEV >= 60) THEN(CHGVAR VAR(&COLOR) +   
              VALUE(&RED))                               
                                                         
 CHGVAR     VAR(&MSGDTA) VALUE(' ' *CAT &COLOR *CAT &MSG)
 CHGVAR     VAR(&MSGDTA) VALUE(&MSGDTA *TCAT &DELIM)     
                                                         
 SNDPGMMSG  MSG(&MSGDTA)                                 
 ENDPGM

This was first published in February 2001

Dig deeper on RPG iSeries programming

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close