Program Messages

Lawson stores messages in a database file. Each message has a message number associated with it. When a program detects an error, it passes the message number to Environment, and Environment displays or prints the error message.

The following example shows the program code for displaying an error message in an online program.

D S2@EDTACC       PI                               
C*                                                          
C                   IF        F2@FC <> 'I'                  
C                             AND F2@FC <> '+'              
C                             AND F2@FC <> '-'              
C                   RETURN                                  
C                   ENDIF                                   
C                   EVAL      D@CMPNY        = F2@PBGCMP    
C                   EVAL      D@PRCSLV       = *BLANKS      
C                   CALLP     DN@DBHRPRS1(E@DBFINDEQ)       
C                   IF        DPRS@NOTFOUND <> FALSE        
C                   EVAL      E@ERRORNBR     = 122          
C                   EVAL      E@FIELDNBR     = F2FN@PBGCMP  
C                   RETURN
C                   ENDIF

If the error condition is met, the program moves the message number (in this case,122) to E@ERRORNBR. Then the program moves the field number of the field that the cursor should be placed on to E@FIELDNBR. If this is a key field edit, there is no need to process further errors, so the program jumps to the end of the paragraph.

Note: You can also explicitly set the error category by using E@ERRORCAT. If you do not set E@ERRORCAT, the program code is used for the error category.

The following example shows the program code (from GL00) for retrieving a message.

C                   EVAL      D@CHRTNM       = F1@GCCHNM        
C                   CALLP     DN@DBIFGCH1(E@DBFINDEQ)                    
C                   IF        DGCH@NOTFOUND <> FALSE                    
C                   IF        F1@FC = 'A'                             
C                   EVAL      E@MSGNBR       = 150                 
C                   CALLP     U@GETMSG                           Get Msg

If the conditions are met, the program moves the message number (in this case, 150) to E@MSGNBR. It then executes the procedure U@GETMSG (790-GET-MSG).

The following example shows the program code (from GL200) for printing an error message in a batch program.

P****************************************************************** 
P* SEDTPRM - Edit Parameters 
P****************************************************************** 
P SEDTPRM         B                   EXPORT 
D SEDTPRM         PI
C*
C                   IF        F1@GCCHNM <> *BLANKS 
C                   EVAL      D@CHRTNM       = F1@GCCHNM 
C                   CALLP     DN@DBIFGCH1(E@DBFINDEQ)
C                   IF        DGCH@NOTFOUND <> FALSE
C                   EVAL      E@ERRVAR1      = F1@GCCHNM
C                   EVAL      E@ERRORNBR     = 100
C                   CALLP     U@PRINTERRMSG           Print Error Msg
C                   RETURN
C                   ENDIF
C                   ENDIF
C* 
P SEDTPRM         E 

If the error condition is met, the program moves the value of the field in error to the variable E@ERRVAR1 and moves the error number (in this case, 100) to E@ERRORNBR. It then executes the procedure U@PRINTERRMSG (780-PRINTERROR-MSG) and jumps to the end of the subroutine. There are different routines that a report program performs depending on the kind of error.