Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Passing BAPIRETURN Values to MESSAGE_STORE FM

amber_garg
Active Participant
0 Kudos

Hi all,

I have a bapi which returns error messages in an internal table of BAPIRETURN. Since there can be multiple messages of S and E type simultaneously , I want to display all the messages together to the user together at the same time in module pool.

I found on net a FM MESSAGE_STORE which displays the error/success messages with traffic lights . But when i checked the parameters of the function module I am unable to find what to pass in ARBGB (MESSAGE ID)  and TXTNR (MESSAGE Number) as I dont have these fields in my BAPIRETURN. Also in my BAPIRETURN I have the field called MESSAGE which has the actually message to be displayed but corresponding field I can't see in MESSAGE_STORE.

Regards

Amber

1 ACCEPTED SOLUTION

gabmarian
Active Contributor
0 Kudos

In order to store a message you need to pass th message ID, number, type and message parameters in the interface of MESSAGE_STORE.

Structure BAPIRETURN has a 5 character length field name CODE where the first 2 character represents the message class and the last 3 is the message number.

BR,

Gábor

6 REPLIES 6

gabmarian
Active Contributor
0 Kudos

In order to store a message you need to pass th message ID, number, type and message parameters in the interface of MESSAGE_STORE.

Structure BAPIRETURN has a 5 character length field name CODE where the first 2 character represents the message class and the last 3 is the message number.

BR,

Gábor

0 Kudos

Thanks for your reply.

The field of Message ID in MESSAGE_STORE is ARBGB which is 20 characters and the description in domain for ARBGB is shown as Application Area.

So what I have to pass to this field is still not clear to me

gabmarian
Active Contributor
0 Kudos

DATA :
   ls_return TYPE bapireturn,
   lt_return TYPE STANDARD TABLE OF bapireturn,
   ls_smesg  TYPE smesg.


LOOP AT lt_return INTO ls_return.

     ls_smesg-arbgb = ls_return-code(2).
     ls_smesg-msgty = ls_return-type.
     ls_smesg-msgv1 = ls_return-message_v1.
     ls_smesg-msgv2 = ls_return-message_v2.
     ls_smesg-msgv3 = ls_return-message_v3.
     ls_smesg-msgv4 = ls_return-message_v4.
     ls_smesg-txtnr = ls_return-code+2(3).

     CALL FUNCTION 'MESSAGE_STORE'
       EXPORTING
         arbgb  ls_smesg-arbgb
         msgty  ls_smesg-msgty
         msgv1  ls_smesg-msgv1
         msgv2  ls_smesg-msgv2
         msgv3  ls_smesg-msgv3
         msgv4  ls_smesg-msgv4
         txtnr  ls_smesg-txtnr
       EXCEPTIONS
         OTHERS = 0.

   ENDLOOP.

Former Member
0 Kudos

Just create your own table/structure instead and do a loop in BAPIRETURN table. From there get all the error/success message details. Pass all the details to your created structure/table.

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

You can use R/3 Central Basis Development: Application Log

Have a look at program SBAL_DEMO_CONTROL_SIMPLE .

When using  CALL FUNCTION 'BAL_CNTL_CREATE' .

You can specify i_container that can be cl_gui_custom_container .

Some code:

FORM at_pbo .

  STATICS: control_handle TYPE balcnthndl .

  IF ob_gui_custom_container_1 IS INITIAL .

    CREATE OBJECT ob_gui_custom_container_1

      EXPORTING

        container_name              = 'OB_GUI_CUSTOM_CONTAINER_1'

      EXCEPTIONS

        cntl_error                  = 1

        cntl_system_error           = 2

        create_error                = 3

        lifetime_error              = 4

        lifetime_dynpro_dynpro_link = 5

        OTHERS                      = 6.

    IF sy-subrc NE 0 .

    ENDIF.

    DATA: st_display_profile TYPE bal_s_prof.

    CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'

      IMPORTING

        e_s_display_profile = st_display_profile.

    CALL FUNCTION 'BAL_CNTL_CREATE'

      EXPORTING

        i_container          = ob_gui_custom_container_1

        i_s_display_profile  = st_display_profile

      IMPORTING

        e_control_handle     = control_handle

      EXCEPTIONS

        profile_inconsistent = 1

        internal_error       = 2

        OTHERS               = 3.

    IF sy-subrc NE 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

  ELSE .

    CALL FUNCTION 'BAL_CNTL_REFRESH'

      EXPORTING

        i_control_handle  = control_handle

      EXCEPTIONS

        control_not_found = 1

        internal_error    = 2

        OTHERS            = 3.

    IF sy-subrc NE 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

  ENDIF .

ENDFORM .                    "at_pbo

Result:

Regards.

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

See if this will do the job.

CALL FUNCTION 'PTRM_TEST_MESSAGES_SHOW_PAI'

    CHANGING

      it_return = it_bapiret.

Regards.