Calling BAPIs from ABAP
This report uses the service BAPI BapiService.MessageGetDetail(), to display the short text and the long text of error messages.
*------------------------------------------------------------------------*
* read a message short and long text using the BAPI *
* BAPI_MESSAGE_GETDETAIL of the object BapiService. *
*------------------------------------------------------------------------*
* Data declaration
DATA : MY_ID LIKE BAPIRET2-ID,
MY_NUMBER LIKE BAPIRET2-NUMBER,
MY_TEXTFORMAT LIKE BAPITGA-TEXTFORMAT,
MY_MESSAGE_V1 LIKE BAPIRET2-MESSAGE_V1,
MY_MESSAGE LIKE BAPIRET2-MESSAGE,
MY_RETURN TYPE BAPIRET2.
DATA : BEGIN OF MY_TEXT OCCURS 1.
INCLUDE STRUCTURE BAPITGB.
DATA : END OF MY_TEXT.
* Enter values in object
MOVE 'FI' TO MY_ID. "message id of message to read
MOVE '024' TO MY_NUMBER. "message number of message to read
MOVE 'ASC' TO MY_TEXTFORMAT. "text format, here ASCII
MOVE '0001' TO MY_MESSAGE_V1. "text to fill into message
*BAPI call
CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'
EXPORTING
ID = MY_ID
NUMBER = MY_NUMBER
* LANGUAGE = SY-LANGU
TEXTFORMAT = MY_TEXTFORMAT
MESSAGE_V1 = MY_MESSAGE_V1
* MESSAGE_V2 =
* MESSAGE_V3 =
* MESSAGE_V4 =
IMPORTING
MESSAGE = MY_MESSAGE
RETURN = MY_RETURN
TABLES
TEXT = MY_TEXT.
* Print results
WRITE : / 'Input' COLOR 5.
WRITE : / 'my_id...........:', MY_ID.
WRITE : / 'my_number.......:', MY_NUMBER.
WRITE : / 'my_textformat...:', MY_TEXTFORMAT.
WRITE : / 'my_message_v1...:', MY_MESSAGE_V1.
WRITE : / 'Output' COLOR 5.
WRITE : / 'my_message........:', MY_MESSAGE.
WRITE : / 'my_return.........:', MY_RETURN.
WRITE : / 'Text output' COLOR 5.
LOOP AT MY_TEXT.
WRITE : / MY_TEXT.
ENDLOOP.