Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

You could display up to 200 characters long message using SE91 message class short text. Let us define the following messages in SE91:

There are 3 messages 018, 019 and 021 defined above. The messages 018 and 019 end up with the continuation string, in ##<MsgNo> format, that points to the next message to be appended. The '##019' string at the end of the message 018 indicates that the message 019 should be appended at the end of the message 018. The '##021' string at the end of the message 019 indicates that the message 021 should be appended at the end of the message 019.

Additionally, the '|' character is used as the line break.

Let us write the ZAWB_TEST_MESSAGE test program as shown in the following table:

REPORT  zawb_test_message.INCLUDE zflc_error_m.PARAMETERS:  p_func  TYPE char20 DEFAULT 'zabc_sohdr_get1' LOWER CASE,  p_vbeln TYPE vbeln  DEFAULT '4981'.DATA:  gr_vbak TYPE vbak,  gr_msg  TYPE bapiret2.START-OF-SELECTION.  CASE p_func.    WHEN 'zabc_sohdr_get1'.      PERFORM zawb_sohdr_get1 USING p_vbeln gr_vbak gr_msg.    WHEN 'zabc_sohdr_get2'.      CALL FUNCTION 'ZAWB_SOHDR_GET2'        EXPORTING          uc_vbeln       = p_vbeln        IMPORTING          xr_vbak        = gr_vbak        EXCEPTIONS          invalid_so_num = 1          OTHERS         = 2.      IF sy-subrc <>

0.

        zflc_on_error_sy_set gr_msg.

      ENDIF.

  ENDCASE.

  zflc_error_popup gr_msg 'EW'.

*&----


*

*&      Form  zawb_sohdr_get1

*&----


*

FORM

   zawb_sohdr_get1 " get sales order header record

USING

  uc_vbeln  TYPE vbeln     " sales order number

  xr_vbak   TYPE vbak      " sale order header record

  xr_msg    TYPE bapiret2. " message record

*----


*

  SELECT SINGLE * INTO xr_vbak FROM vbak WHERE vbeln = uc_vbeln.

  IF sy-subrc <> 0.

zflc_error_set xr_msg 'E' 'ZAWB' 18 uc_vbeln '' '' ''.

ENDIF.

ENDFORM. "zabc_sohdr_get1

The above program tries to retrieve the sales order header record using ZAWB_SOHDER_GET1 ABAP Form or ZAWB_SOHDR_GET2 Function Module shown in the following table:

FUNCTION zawb_sohdr_get2.

*"----

-


""Local Interface:

*"  IMPORTING

*"     REFERENCE(UC_VBELN) TYPE  VBELN

*"  EXPORTING

*"     REFERENCE(XR_VBAK) TYPE  VBAK

*"  EXCEPTIONS

*"      INVALID_SO_NUM

*"----

-


  SELECT SINGLE *

         INTO xr_vbak

         FROM vbak

         WHERE vbeln = uc_vbeln.

  IF sy-subrc <> 0.

MESSAGE ID 'ZAWB' TYPE 'E' NUMBER 18 WITH uc_vbeln

RAISING invalid_so_num.

ENDIF.

ENDFUNCTION.

 If sales order is not found, the ZAWB_SOHDER_GET2 Function Module raises exception. The calling program converts SY structure error parameters to gr_msg BAPIRET2 structure calling ZFLC_ON_ERROR_SY_SET macro as shown in the following table:

   ...        WHEN 'zabc_sohdr_get2'.      CALL FUNCTION 'ZAWB_SOHDR_GET2'        EXPORTING          uc_vbeln       = p_vbeln        IMPORTING          xr_vbak        = gr_vbak        EXCEPTIONS          invalid_so_num = 1          OTHERS         = 2.      IF sy-subrc <> 0.        zflc_on_error_sy_set gr_msg.      ENDIF.    ...  

The ZFLC_ON_ERROR_SY_SET macro source code defined in ZFLC_ERROR_M include is shown in the following table:

DEFINE

   zflc_on_error_sy_set. " sets system message

*PARAMETERS

  • &1              " BAPIRET2^ message object; e.g.,  lr_msg

*SOURCE

  if sy-subrc <> 0.

call function 'ZFLC_ERROR_SET'

exporting

us_msgtyp = sy-msgty

us_msgid = sy-msgid

ui_msgno = sy-msgno

us_msgtxt = ''

us_msgv1 = sy-msgv1

us_msgv2 = sy-msgv2

us_msgv3 = sy-msgv3

us_msgv4 = sy-msgv4

changing

xr_msg = &1.

endif.

END-OF-DEFINITION.

The ZAWB_SOHDER_GET1 ABAP Form is shown in the following table:

*&----


*

*&      Form  zawb_sohdr_get1

*&----


*

FORM

   zawb_sohdr_get1 " get sales order header record

USING

  uc_vbeln  TYPE vbeln     " sales order number

  xr_vbak   TYPE vbak      " sale order header record

  xr_msg    TYPE bapiret2. " message record

*----


*

  SELECT SINGLE * INTO xr_vbak FROM vbak WHERE vbeln = uc_vbeln.

  IF sy-subrc <> 0.

zflc_error_set xr_msg 'E' 'ZAWB' 18 uc_vbeln '' '' ''.

ENDIF.

ENDFORM. "zabc_sohdr_get1

 If sales order is not found, the ZAWB_SOHDER_GET1 ABAP Form sets the error message in xr_msg BAPIRET2 structure using ZFLC_ERROR_SET macro  defined in ZFLC_ERROR_M include and shown in the following table:

DEFINE

   zflc_error_set. " sets message

*PARAMETERS

  • &1              " BAPIRET2^ message object; e.g.,  lr_msg

  • &2              " message type; e.g.,    E

  • &3              " message id; e.g.,      ZOIM

  • &4              " message number

  • &5              " message parameter 1

  • &6              " message parameter 2

  • &7              " message parameter 3

  • &8              " message parameter 4

*SOURCE

  call function 'ZFLC_ERROR_SET'

    exporting

      us_msgtyp = &2

      us_msgid  = &3

      ui_msgno  = &4

      us_msgtxt = ''

      us_msgv1  = &5

      us_msgv2  = &6

      us_msgv3  = &7

      us_msgv4  = &8

    changing

      xr_msg    = &1.

END-OF-DEFINITION.

The ZFLC_ERROR_SET macro calls ZFLC_ERROR_SET function module that formats message processing message extension strings ##<MsgNo>. The function module source code is shown in the following table:

FUNCTION ZFLC_ERROR_SET.

*"----

-


""Local Interface:

*"  IMPORTING

*"     REFERENCE(US_MSGTYP) TYPE  ANY

*"     REFERENCE(US_MSGID) TYPE  ANY

*"     REFERENCE(UI_MSGNO) TYPE  ANY

*"     REFERENCE(US_MSGTXT) TYPE  ANY

*"     REFERENCE(US_MSGV1) TYPE  ANY

*"     REFERENCE(US_MSGV2) TYPE  ANY

*"     REFERENCE(US_MSGV3) TYPE  ANY

*"     REFERENCE(US_MSGV4) TYPE  ANY

*"  CHANGING

*"     REFERENCE(XR_MSG) TYPE  BAPIRET2

*"----

-


  DATA:

    li_subrc  TYPE sysubrc,

    ls_msgno  TYPE char3,

    ls_msgno2 TYPE char3,

    li_pos    TYPE i,

    lr_t100   TYPE t100,

    ls_msgv1  TYPE symsgv,

    ls_msgv2  TYPE symsgv,

    ls_msgv3  TYPE symsgv,

    ls_msgv4  TYPE symsgv.

  FIELD-SYMBOLS:

    The error message is displayed by ZFLC_ERROR_POPUP macro defined in ZFLC_ERROR_M  include and shown in the following table:

DEFINE

   zflc_error_popup. " display msg of types in popup window

*PARAMETERS

  • &1              " BAPIRET2^ message object; e.g.,  lr_msg

  • &2              " consider message types e.g.,   EW

*SOURCE

  if not &1-type is initial and &2 cs &1-type.

    sy-title = '[P][P]( (P))'.

    replace '[P]' with:

      &1-type   into sy-title,

      &1-number into sy-title,

      &1-id     into sy-title.

    condense sy-title no-gaps.

    concatenate 'Message:' sy-title into sy-title

                separated by space.

    clear:

      sy-winsl,

      sy-entry,

      sy-rtitl,

      sy-xcode.

    split &1-message at '|' into sy-winsl

                                 sy-entry

                                 sy-rtitl

                                 sy-xcode.

    call function 'POPUP_TO_INFORM'

      exporting

        titel = sy-title

        txt1  = sy-winsl

        txt2  = sy-entry

        txt3  = sy-rtitl

        txt4  = sy-xcode.

  endif.

END-OF-DEFINITION.

Now let us execute the ZAWB_TEST_MESSAGE test program as shown on the following screen:

 Click on the Execute button. The following popup window appears:

The same popup window will appear if we would change Function Module/ABAP Form Name parameter from ZAWB_SOHDR_GET1 ABAP Form name to* ZAWB_SOHDR_GET2* Function Module name.

As described in this paper, the message was formatted by ZFLC error macros and ZFLC_ERROR_SET function module from messages, with special formatting strings, defined in SE91 message class:

!https://weblogs.sdn.sap.com/weblogs/images/5188/SE91Messages.JPG|height=284|alt=image|width=652|src=...!</body>

10 Comments