cancel
Showing results for 
Search instead for 
Did you mean: 

Embedded component with message view

matt
Active Contributor
0 Kudos
92

I've created a component with a message view. In the WDDOINIT method I have:

  data: lr_wd_message_area    type ref to if_wd_message_area,
        lr_current_controller type ref to if_wd_window_controller.

* Set up message controller
  lr_current_controller ?= wd_this->wd_get_api( ).
  lr_wd_message_area = lr_current_controller->get_message_area( ).
  lr_wd_message_area->set_display_attributes( i_show_only_current = ' '
                                              i_for_all_instances = ' '
                                              i_use_toggle_area   = ' ' ).

When I call the component as a standalone application it works fine. lr_wd_message_area is instantiated. When I embed the component in the window of another application, I get a dump, as lr_wd_message_area is NOT instantiated. In the other application, the component is embedded directly in a window, which is called as a popup.

 ...  lr_popup = lr_window_manager->create_window(
  modal               = abap_true
  window_name         = 'W_LOG'
  title               = 'Errors log'
  close_button        = abap_true
  button_kind         = if_wd_window=>co_buttons_close
  message_type        = if_wd_window=>co_msg_type_error
  close_in_any_case   = abap_true
  message_display_mode = if_wd_window=>co_msg_display_mode_all ).

  lr_popup->open( ).

When I test the program, it dumps at line lr_wd_message_area = lr_current_controller->get_message_area( ). (in the first code fragment), as lr_current_controller isn't instantiated. When I call the component directly, the lr_current_controller is instantiated.

What could be causing this lack of instantiation?

matt

Edited by: Matt on Mar 1, 2011 11:45 AM

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

I guess lr_current_controller will not be initial.

but instead it will be missing some values like view id etc when you are using the window as embeded view.

so in this case it wont give you the message area

using lr_current_controller->get_message_area( ).

could you elaborate on what is the actual requirement in this case.

may be we can do some work around.

thanks

sarbjeet singh

matt
Active Contributor
0 Kudos

lr_controller is instantiated, yes.

The component (ERRLOG) displays a process chain log. I has an interface method (and window default method), that takes as parameter the logid of the process chain log. The structure of the process chain log is RS_T_MSG (line type BAL_S_MSG).

In WDDOMODIFYVIEW of the (only) view, I use

    loop at rs_t_msg into ls_msg.
      lr_message_manager->report_t100_message(
                 msgid     = ls_msg-msgid
                 msgno     = ls_msg-msgno
                 msgty     = ls_msg-msgty
                 p1        = ls_msg-msgv1
                 p2        = ls_msg-msgv2
                 p3        = ls_msg-msgv3
                 p4        = ls_msg-msgv4
                 msg_index = sy-tabix ).
    endloop.

This gets the messages into the message manager. When I run the application as it stands, and give it the logid, it works fine.

Now I want to use this component in another application. This application has a window, with a view containing information about a process chain run, and a logid. The view has a button. When I click on the button, I display window W_LOG as a popup. I've embedded ERRLOG in W_LOG.

So the requirement is - click on button in main application, display the error log in a popup.

As I understand it, the message area is unique to a window. However, I note the sap help says:

Reusable Components and the Message Area

If you use reusable components, make sure that your components contain simple elements that really can be reused.

With components that you want to use in several applications you should never use the MessageArea UI element, since each window is allowed to contain only one visible MessageArea at the most.

Example

Example of a component that can be both stand-alone and reusable:

You create two views. The first view contains only elements that are not going to be reused, for example, UI elements: Header, MessageArea, and ViewContainer. Your second view contains only the core application that can be embedded and reused. In your component you create two windows. The first is the default window for the application that runs stand-alone.

Here you embed your first view. The second view you put in the ViewContainer. The second window, which is the interface view, is then used to simply to embed the second view.

Trouble is, I've read this a few times and don't understand what it means! I'm not sure it applies, as the window of ERRLOG oncly contains one visible message area.

Former Member
0 Kudos

Hi Matt,

I think if you follow the principles appended in your last post.

There are two possibilities.

1. You could create 2 views and two windows.

One view(A) which actually displays the message (WDDOMODIFY view ).

Another view (B)with your DoInit code (Getting the Message area and setting display attributes ), and a ViewUIElementContainer.

In one window(A) Embed the view(A) and init embed view -B. Your standalone application can call this interface view.

In another window(B) Just embed only View(B) which is the reusable view for external applications.

2. You create 1 view(A) and two windows(A&B)

Move your views doInit method Message area logic to the window-A doinit method.

Embed the view in both windows. Window-A is for stand alone application, window-B for reusable interface view.

matt
Active Contributor
0 Kudos

I've tried that, and it doesn't work - the standalone is fine, but the component doesn't display anything. What I'm running into, I think, is

With components that you want to use in several applications you should never use the MessageArea UI element, since each window is allowed to contain only one visible MessageArea at the most.

I think I'll have to use some kind of ALV instead of the messageArea, which is a shame. I'll leave the question open, in case there are other ideas.

Former Member
0 Kudos

HI,

Exactly, you should not use MessageArea in the reusable view assembly.

So in the approach 1. You could have the view-b with message area. view-a which is reusable view should not have the messageArea.

Approach 2, should not have MessageArea at all.

In our company, we do not include MessageArea at all. Exceptional cases have to be solved in a order as i described above.

Answers (0)