Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SNDPGMMSG Command Problems

Status
Not open for further replies.

jsplice

Programmer
Jun 3, 2003
88
US
Hello all. I seem to be having a problem with handing error messages that are to be written to the subfile error message record. A small CL program is being called by the RPG to send a specified error message to the screen (using a string, not a message file). Here is the CL:

Code:
PGM        PARM(&SFPGMQ &MSGTXT)               
                                               
DCL        VAR(&SFPGMQ) TYPE(*CHAR) LEN(10)    
DCL        VAR(&MSGTXT) TYPE(*CHAR) LEN(512)   
                                               
SNDPGMMSG  MSG(&MSGTXT) TOPGMQ(*SAME (&SFPGMQ))
MONMSG     MSGID(CPF0000)                      
                                               
ENDPGM

I'm using a Monitor block in the RPG to handle an error when checking a date. I move the display file date input field (character field) into an internal date field; on-error, call the CL with the message text. It's adding the message to the error message subfile, however it is first putting a system error message saying "Date, Time or Timestamp value is not valid." So essentially it’s writing two error messages instead of just the one that I sent to the CL. How can I keep this command from writing the system message and only write the message I specify?
 
I don't think you can stop the system error message. The way the Monitor opcode works is that it tries to execute the line then falls through to the On-Error opcode when an error occurs. This means that an error must have happened or the Monitor block doesn't pick it up. I had the same problem and ended up using
Code:
Test(de) *EUR FROMF1;
If %Error;                        
  Error = SendMsg('SDR9003');     
  FromError = *On;                
Else;                             
  FromDate = %Date(FROMF1 : *EUR);
EndIF;
because I couldn't find any other way around it. The SendMsg procedure is the equivalent of your CL-pgm just doing a call to the QMHSNDPM API.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top