Repository navigation
SND MSG
SND-MSG sends a message. The message type is one of *INFO (the default),
*DIAG, *COMP, *STATUS, *NOTIFY or *ESCAPE. IBM i writes the others to
the job log; OpenRPG has no job log, so it prints them to stderr, prefixed with
their type. *ESCAPE behaves as on IBM i: it is an error, sent to a call-stack
entry.
SND-MSG *INFO 'Informational message';
SND-MSG *DIAG 'Diagnostic detail';
SND-MSG *COMP 'Processing complete';
// Bare form — defaults to *INFO
SND-MSG 'Something happened';
// Variable message
DCL-S msg VARCHAR(100);
msg = 'Row count: ' + %CHAR(rowCount);
SND-MSG *DIAG msg;The type is written directly after SND-MSG. SND-MSG TYPE(*INFO) 'text' is
rejected: IBM i reads TYPE as a variable name (RNF0203).
By default an *ESCAPE message goes to the caller of the procedure that
sends it, as on IBM i: that procedure ends at once -- its own MONITOR and
*PSSR do not see the message -- and in the caller it is an error with status
202, message CPF9898 (in the PSDS). This is how a procedure reports failure:
DCL-PROC checkQty;
DCL-PI *N;
qty INT(10) VALUE;
END-PI;
IF qty < 0;
SND-MSG *ESCAPE 'Quantity cannot be negative'; // checkQty ends here
ENDIF;
END-PROC;
MONITOR;
checkQty(-1);
ON-ERROR;
DSPLY ('Caught: ' + %CHAR(%STATUS)); // Caught: 202
ENDMON;%TARGET(*SELF) sends it to the procedure itself instead, where its own
MONITOR handles it, with status 9999. Sent from the main procedure to its
caller, an *ESCAPE ends the program, printing its text. %TARGET does not
change where the other message types go.
- Installation
- Quick Start
- CLI Reference
- Language Basics
- Data Types
- Variables and Constants
- Data Structures
- Arrays
- Varying-Dimension Arrays
- Control Flow
- Procedures
- Procedure Overloading
- Built-In Functions
- Error Handling
- Operation Extenders
- Enumerations
- Program Status Data Structure
- Data Areas
- SND-MSG
- Embedded SQL
- Record-Level Access
- Display Files (WORKSTN)
- Program-Described Files (I-Specs and O-Specs)
- DATA-INTO and DATA-GEN
- XML-INTO
- Fixed-Format Source
- Database Connections
- Multi-Module Programs
- Environment Variables
- Testing
- Complete Example: Employee Report
- IBM i Conformance Results
- IBM i Execution Results