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

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.