GRC
HR
SCM
CRM
BI


Article

 

Obtaining Additional Documentation for BAPI Error Messages

by Thomas G. Schuessier | SAPinsider

June 1, 2000

by Thomas G. Schuessier SAPinsider - 2000 (Volume 1), June (Issue 1)
 

As of Release 4.5A, there is a new feature related to error handling. As you know, each well-behaved BAPI has a Return parameter. This parameter can be based on different structures.

The frequently used structure BAPIRETURN1 is shown in Figure 1.

Field Name Data Type Description
TYPE Character 1

Message type:

'S' or blank: Success
'E': Error
'W': Warning
'I': Information
'A': Abort

ID Character 20 Application Area
NUMBER Numerical Character 3 Message Number
MESSAGE Character 220 Message Text
LOG_NO Character 20 Application log: log number
LOG_MSG_NO Numerical Character 6 Application log: message serial number
MESSAGE_V1 Character 50 Message variable 1
MESSAGE_V2 Character 50 Message variable 2
MESSAGE_V3 Character 50 Message variable 3
MESSAGE_V4 Character 50 Message variable 4
Figure 1 The BAPIREDURN1 Structure for Error Handling

     Sometimes the message text in field MESSAGE does not contain enough information for a user. Most SAP messages have additional documentation that an SAP GUI user can easily access. Starting with Release 4.5A, we are now capable of offering the same service to users of our BAPI-enabled applications by using the BapiService.MessageGetDetail BAPI. Figure 2 is a screen shot¹ showing this BAPI.

Figure 2 The BapiService.MessageGetDetail BAPI

Parameter Name Data Type Import/Export Description
Id Character 20 Import Application Area
Number Numerical Character 3 Import Message Number
TextFormat Character 3 Import

Text Format:

'HTM': HTML
'RTF': Rich Text Format
'SCR': SAPscript
'ASC': ASCII

Return Structure BAPIRET2 Export Return Information
Text Table BAPITGB Export Text Lines
Figure 3 Important Parameters for Retreiving Message Documentation As Plain Text

      Figure 3 lists the parameters that we need to use in order to retrieve the message documentation as plain text.

     In order to retrieve the complete documentation for a message returned by an application BAPI, in parameters Id and Number we simply pass the appropriate data from the Return parameter. Parameter TextFormat allows us to choose the format of the text returned in table parameter Text. Listing 1 (see below) shows sample code invoking BapiService.MessageGetDetail in Visual Basic using SAP DCOM Connector.


Public Function GetMessageDetail	(ByVal ApplicationArea As String, _
ByVal MessageNumber As Long) As String
Dim rsReturn As Recordset
Dim rsText As Recordset
Dim s As String
	On Error GoTo EH
	oBapiService.BapiMessageGetDetail Id:=ApplicationArea, _
Number:=MessageNumber, _
TextFormat:="ASC", _
Return:=rsReturn, _
Text:=rsText
	If rsReturn("TYPE") <> "" Then
		GetMessageDetail = ""
		Exit Function
	End If
	Do While Not rsText.EOF
		s = s & rsText(0) & vbCrLf
		rsText.MoveNext
	Loop
	GetMessageDetail = s
	Exit Function
EH:
	Err.Raise Err.Number, ERRSOURCE, _
		ERRSOURCE & ".GetMessageDetail (Line " & CStr(Erl) & ")" & _
		vbCrLf & Err.Description
End Function
Listing 1 Sample Code for BapiService.MessageGetDetail

     If the TYPE field in the Return parameter is not empty, then there is no additional documentation for this message, and we return an empty string. Otherwise, we concatenate all rows of table Text, inserting vbCrLf (carriage return/line feed) after each row.

     Figure 4 shows a screen shot displaying the documentation for an error message.

Figure 4 Testing GetMessage Detail

Summary

BapiService.MessageGetDetail lets us improve the user-friendliness of our BAPI-enabled applications significantly. If the original message text is not sufficient, we can retrieve additional documentation and display it in several different formats.

¹ This screen shot was created using the improved BAPI Explorer in 4.6. Yet another reason to upgrade.


Thomas G. Schuessler is the founder of ARAsoft, a company offering products, consulting, custom development, and training to a worldwide base of customers. The company specializes in integration between SAP and non-SAP components and applications. ARAsoft offers various products for BAPI-enabled programs on the Windows and Java platforms. These products facilitate the development of desktop and Internet applications that communicate with R/3. Thomas is the author of SAP's CA925 "Programming with BAPIs in Visual Basic" class, which he teaches in Germany and in English-speaking countries. His book on the same subject will be published soon. Thomas is a regularly featured speaker at SAP TechEd and SAPPHIRE conferences. Prior to founding ARAsoft in 1993, he worked with SAP AG and SAP America for seven years. Thomas can be contacted at thomas.schuessler@sap.com or at arasoft@t-online.de.

An email has been sent to:






More from SAPinsider



COMMENTS

Please log in to post a comment.

No comments have been submitted on this article. Be the first to comment!


SAPinsider
FAQ