10-11-2007 7:31 AM
Hi,
I need to capture the information messages from a table and display it to the user.
The messages are captured in the return parameter ETK_RETURN of associated type BAPIRET2.
This table can contain messages. In the case of E_SUBRC <> 0 it contains error messages, in the case of E_SUBRC = 0 it can contain information messages.
When Im trying to loop through this table and display the messages using the foll code;
LOOP AT lt_msg_log.
MESSAGE i000(zmsg) WITH lt_msg_log-message.
ENDLOOP.
The problem is, the messages do get displayed, but the messages are TRUNCATED since all the messages cannot be displayed in the same window.
The requirement is the whole messages/text have to be displayed when the user clicks on the long text.
Rgds
Syam
10-11-2007 7:36 AM
SAP has developped tools to report protocol, look at function groups SBAL and SBAL_DISPLAY.
Sample :
FORM display_log TABLES p_return STRUCTURE bapiret2.
DATA:
l_log_handle TYPE balloghndl,
l_s_log TYPE bal_s_log,
l_s_msg TYPE bal_s_msg,
l_msgno TYPE symsgno,
l_s_display_profile TYPE bal_s_prof.
* Application Log: Global: Export memory
CALL FUNCTION 'BAL_GLB_MEMORY_EXPORT'.
* Application Log: Global: (Partially) reset memory
CALL FUNCTION 'BAL_GLB_MEMORY_REFRESH'
EXPORTING
i_refresh_all = 'X'
EXCEPTIONS
not_authorized = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Application Log: Log: Create with header data
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = l_s_log
IMPORTING
e_log_handle = l_log_handle
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Map field (there should be a fm for that ?)
LOOP AT p_return.
l_s_msg-msgid = p_return-id.
l_s_msg-msgno = p_return-number.
l_s_msg-msgty = p_return-type.
l_s_msg-msgv1 = p_return-message_v1.
l_s_msg-msgv2 = p_return-message_v2.
l_s_msg-msgv3 = p_return-message_v3.
l_s_msg-msgv4 = p_return-message_v4.
IF l_s_msg-msgty = 'E'.
l_s_msg-probclass = '1'.
ELSEIF l_s_msg-msgty = 'W'.
l_s_msg-probclass = '2'.
ELSE.
l_s_msg-probclass = '3'.
ENDIF.
* Application Log: Log: Message: Add
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_log_handle = l_log_handle
i_s_msg = l_s_msg
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
* Application Log: Display profile: Display without tree (popup)
CALL FUNCTION 'BAL_DSP_PROFILE_POPUP_GET'
IMPORTING
e_s_display_profile = l_s_display_profile
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Application Log: Fullscreen log output
l_s_display_profile-use_grid = ' '.
l_s_display_profile-title = text-004.
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
EXPORTING
i_s_display_profile = l_s_display_profile
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Application Log: Global: Import and insert memory
CALL FUNCTION 'BAL_GLB_MEMORY_IMPORT'
EXPORTING
i_complete_overwrite = 'X'.
ENDFORM. " display_log
Regards
10-11-2007 7:36 AM
SAP has developped tools to report protocol, look at function groups SBAL and SBAL_DISPLAY.
Sample :
FORM display_log TABLES p_return STRUCTURE bapiret2.
DATA:
l_log_handle TYPE balloghndl,
l_s_log TYPE bal_s_log,
l_s_msg TYPE bal_s_msg,
l_msgno TYPE symsgno,
l_s_display_profile TYPE bal_s_prof.
* Application Log: Global: Export memory
CALL FUNCTION 'BAL_GLB_MEMORY_EXPORT'.
* Application Log: Global: (Partially) reset memory
CALL FUNCTION 'BAL_GLB_MEMORY_REFRESH'
EXPORTING
i_refresh_all = 'X'
EXCEPTIONS
not_authorized = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Application Log: Log: Create with header data
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = l_s_log
IMPORTING
e_log_handle = l_log_handle
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Map field (there should be a fm for that ?)
LOOP AT p_return.
l_s_msg-msgid = p_return-id.
l_s_msg-msgno = p_return-number.
l_s_msg-msgty = p_return-type.
l_s_msg-msgv1 = p_return-message_v1.
l_s_msg-msgv2 = p_return-message_v2.
l_s_msg-msgv3 = p_return-message_v3.
l_s_msg-msgv4 = p_return-message_v4.
IF l_s_msg-msgty = 'E'.
l_s_msg-probclass = '1'.
ELSEIF l_s_msg-msgty = 'W'.
l_s_msg-probclass = '2'.
ELSE.
l_s_msg-probclass = '3'.
ENDIF.
* Application Log: Log: Message: Add
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_log_handle = l_log_handle
i_s_msg = l_s_msg
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
* Application Log: Display profile: Display without tree (popup)
CALL FUNCTION 'BAL_DSP_PROFILE_POPUP_GET'
IMPORTING
e_s_display_profile = l_s_display_profile
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Application Log: Fullscreen log output
l_s_display_profile-use_grid = ' '.
l_s_display_profile-title = text-004.
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
EXPORTING
i_s_display_profile = l_s_display_profile
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Application Log: Global: Import and insert memory
CALL FUNCTION 'BAL_GLB_MEMORY_IMPORT'
EXPORTING
i_complete_overwrite = 'X'.
ENDFORM. " display_log
Regards
10-11-2007 8:30 AM