Feedback
Did this article resolve your question/issue?

   

Article

4GL/ABL: How to programmatically get the description of an error message based on its number?

« Go Back

Information

 
Title4GL/ABL: How to programmatically get the description of an error message based on its number?
URL Name19758
Article Number000120376
EnvironmentProduct: Progress
Version: 9.x
Product: OpenEdge
Version: 10.x, 11.x
OS: All supported platforms
Question/Problem Description
4GL/ABL: How to programmatically get the description of a PROMSG based on its number?
Where are the files containing the OpenEdge error messages located?
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution

This functionality was offered in earlier releases in the GetMessageDescription procedure from the src/prohelp/msgs.i include file. This code no longer ships with the product.

The following code demonstrates how to programmatically get the description of an OpenEdge error message based on its number:

 

FUNCTION getMsgDataFileName RETURNS CHARACTER ( INPUT piMsgNum AS INTEGER ):

 DEFINE VARIABLE iFileNum AS INTEGER NO-UNDO.
 DEFINE VARIABLE cDataFile AS CHARACTER NO-UNDO.

 iFileNum = TRUNCATE((piMsgNum - 1) / 50, 0) + 1.
 cDataFile = SEARCH("prohelp/msgdata/msg" + STRING(iFileNum)).

 RETURN cDataFile.
END FUNCTION.

FUNCTION getMsgDescription RETURNS CHARACTER ( INPUT piMsgNum AS INTEGER ):

 DEFINE VARIABLE cDescription AS CHARACTER NO-UNDO INITIAL ?.
 DEFINE VARIABLE cMsgFile AS CHARACTER NO-UNDO.
 DEFINE VARIABLE cMsgNumber AS CHARACTER NO-UNDO FORMAT "x(6)".
 DEFINE VARIABLE cText AS CHARACTER NO-UNDO FORMAT "x(78)".
 DEFINE VARIABLE cLine AS CHARACTER NO-UNDO EXTENT 9 FORMAT "x(78)".
 DEFINE VARIABLE cCategory AS CHARACTER NO-UNDO FORMAT "xx".
 DEFINE VARIABLE cCategoryArray AS CHARACTER NO-UNDO FORMAT "x(30)" EXTENT 7.
 DEFINE VARIABLE cCategoryCodes AS CHARACTER NO-UNDO.
 DEFINE VARIABLE cKnowledgeBase AS CHARACTER NO-UNDO FORMAT "X(78)".
 DEFINE VARIABLE cEol AS CHARACTER NO-UNDO.
 DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
 DEFINE VARIABLE iPosition AS INTEGER NO-UNDO.
 DEFINE VARIABLE cCategoryIndex AS INTEGER NO-UNDO.

     cCategoryCodes = "C,D,I,M,O,P,S".
     cCategoryArray[1] = "Compiler".
     cCategoryArray[2] = "Database".
     cCategoryArray[3] = "Index".
     cCategoryArray[4] = "Miscellaneous".
     cCategoryArray[5] = "Operating System".
     cCategoryArray[6] = "Program/Execution".
     cCategoryArray[7] = "Syntax".
     cEol = CHR(10).

     cMsgFile = GetMsgDataFileName(piMsgNum).

 IF (cMsgFile GT "") EQ TRUE THEN
 DO: /* Process Message File */
     INPUT FROM VALUE(cMsgFile) NO-ECHO.
     ASSIGN iPosition = piMsgNum
     iPosition = (piMsgNum MODULO 50) WHEN (piMsgNum MODULO 50) > 0.
 
     /* Skip messages until the one that we are interested in */
     DO iCount = 1 TO iPosition ON ENDKEY UNDO, LEAVE:
         IMPORT cMsgNumber cText cLine cCategory cKnowledgeBase.
         cCategoryIndex = LOOKUP(cCategory, cCategoryCodes).
    END.
 INPUT CLOSE. 

 IF (cText GT "") NE TRUE THEN RETURN "No message found to match the number".

 IF INTEGER(cMsgNumber) EQ piMsgNum AND 
    cText NE "Reserved for Seq " THEN DO: /* Process Description */
 iCount = 1.
 
 REPEAT:
 IF iCount LE 9 THEN DO:
     IF iCount EQ 1 THEN
     cDescription = cLine[iCount].
     ELSE
         cDescription = cDescription + cEol + cLine[iCount].
         iCount = iCount + 1.
     END.
 ELSE LEAVE.
 END. /* repeat */


 IF cLine[1] EQ "syserr" THEN
 cDescription = 
 "An unexpected system error has occurred. Please do the following:" + cEol +
 "1. If the error occurred while running an existing application or" + cEol +
 " during database admin functions, the error may be due to a" + cEol +
 " hardware/system problem, r-code corruption, or data corruption." + cEol +
 " Take not what was processing during the time the error occurred." + cEol +
 " Check the system error logs and Progress database log file for" + cEol +
 " additional errors."   + cEol +
 "2. If the error occurred while running a new application or procedure," + cEol +
 " try to reproduce and isolate the code that results in the error." + cEol +
 "3. Search the on-line SupportLink Knowledge Base for information on " + cEol +
 " the error via the Progress web site at:" + cEol +
 " https://knowledgebase.progress.com/" + cEol +
 "4. If the above does not lead to resolution, please contact the" + cEol +
 " dealer who sold you PROGRESS, or the Progress Technical" + cEol +
 " Support center for your region.".

 cDescription = cText + cEol + cEol + cDescription.

 /* Category */
 IF cCategoryIndex NE 0 THEN
 cDescription = cDescription + cEol + cEol + cCategoryArray[cCategoryIndex].

 /* Knowledge Base */
 IF (cKnowledgeBase GT "") EQ TRUE THEN
 cDescription = cDescription + cEol + cEol + cKnowledgeBase + ".".

 END. /* Process Description */
 END. /* Process Message File */

 RETURN cDescription.

END FUNCTION.

DEFINE VARIABLE msg-num AS INTEGER FORMAT ">>>9" LABEL "Msg Num" NO-UNDO.
DEFINE VARIABLE shortdescription AS CHARACTER FORMAT "x(80)" LABEL "Short Description" VIEW-AS FILL-IN SIZE 65 BY 1 NO-UNDO.
DEFINE VARIABLE description AS CHARACTER LABEL "Description" VIEW-AS EDITOR INNER-CHARS 70 INNER-LINES 12 SCROLLBAR-VERTICAL NO-UNDO.

DEFINE BUTTON b-close LABEL "&Close".

FORM msg-num
 HELP "Enter error number and use TAB or RETURN to view the corresponding description"
 shortdescription SKIP
 description SKIP
 b-close AT 65
 WITH FRAME xx THREE-D.

ON LEAVE OF msg-num OR RETURN OF msg-num DO:
 ASSIGN
 msg-num.
 description = getMsgDescription (msg-num).
 ASSIGN
 shortdescription = ENTRY(1,description, CHR(10)).
 DISPLAY
 msg-num shortdescription description WITH FRAME xx.
 APPLY "ENTRY" TO msg-num.
 RETURN NO-APPLY.
END.

ENABLE ALL WITH FRAME xx.
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW OR CHOOSE OF b-close.
Workaround
Notes
Last Modified Date11/20/2020 7:01 AM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.