on 11-29-2010 9:48 AM
Hi,
My Requirement is to display the BAPI Return Messages in a pop up window.
On click of a button i will be calling a BAPI and the return messages from the BAPI have to be displayed in a POP UP Window.
I have placed a Message Area UI in the view embedded in the window to be used for Pop Up.
In the below code instead of calling a BAPI i have populated the return messages.
On click of the button the return messages are getting displayed both in Main view and inside the Pop Up window also. I need the messages to be displayed only inside pop up window.
method ONACTIONPOP .
data: it_return type table of bapiret2.
data: wa_return type bapiret2.
***Populating return messages
wa_return-type = 'S'.
wa_return-message = 'Success Message'.
APPEND wa_return to it_return.
wa_return-type = 'E'.
wa_return-message = 'Error Message'.
APPEND wa_return to it_return.
***Code to print return message based on the message type returned by the BAPI
DATA lo_api_controller TYPE REF TO if_wd_controller.
DATA lo_message_manager TYPE REF TO if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager.
loop at it_return into wa_return.
if wa_return-type = 'S'.
CALL METHOD lo_message_manager->report_success
EXPORTING
message_text = wa_return-message.
ELSEIF wa_return-type = 'E'.
CALL METHOD lo_message_manager->report_error_message
EXPORTING
message_text = wa_return-message.
ELSEIF wa_return-type = 'E'.
CALL METHOD lo_message_manager->report_warning
EXPORTING
message_text = wa_return-message.
ENDIF.
clear: wa_return.
ENDLOOP.
****code to open pop up window
DATA lo_window_manager TYPE REF TO if_wd_window_manager.
DATA lo_api_component TYPE REF TO if_wd_component.
DATA lo_window TYPE REF TO if_wd_window.
lo_api_component = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
lo_window = lo_window_manager->create_window(
window_name = 'W_POP'
title = 'Pop Up Window Demo'
* close_in_any_case = abap_true
message_display_mode = if_wd_window=>co_msg_display_mode_selected
* close_button = abap_true
button_kind = if_wd_window=>co_buttons_ok
message_type = if_wd_window=>co_msg_type_none
default_button = if_wd_window=>co_button_ok
).
lo_window->open( ).
endmethod.
Regards,
Bala Baskaran.S
Hi,
In Main View i have placed only a Button UI element, On click of the button the action "method onactionpop" is triggered where i populate message and open the pop up view.
In Pop up view i have placed only a Message area UI element to capture the messages.
In main view the webdynnpro framework by default captures the messages on top of the view even if we dont place a
message area UI element.
Regards,
Bala Baskaran.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I just tried with your code. It works fine for me. THese are the steps which I followed.
1. Create a node of RETURNMSG of BAPIRETURN in compoent controller.
2. In main view, map the context node from component controller. Create a button in layout and then create an action for the same.
3.Create another view by name POPUP. Map the context node from component controller.
4.In the popup view, create a table and bind the datasource to the node RETURNMSG and then create binding for the fields.
5.Create a separate window POP_UP for popup view and then embed the POPUP view in it. Other than that, window pertains to main view should be available.
6.Now copy paste the code in the onclick method of the button in Main view.
method ONACTIONONCLICK .
data: it_return type table of bapiret2.
data: wa_return type bapiret2.
data: lo_nd_return type REF TO if_wd_context_node.
data: it_messages type wd_this->elements_returnmsg,
wa_message type wd_this->element_returnmsg.
***populating messages instead of calling BAPI/RFC
wa_return-type = 'S'.
wa_return-message = 'Success Message'.
append wa_return to it_return.
wa_return-type = 'E'.
wa_return-message = 'Error Message'.
append wa_return to it_return.
***if return table has messages
***code to open pop up window
if it_return is not initial.
lo_nd_return = wd_context->get_child_node( name = 'RETURNMSG' ).
loop at it_return into wa_return.
wa_message-type = wa_return-type.
wa_message-message = wa_return-message.
append wa_message to it_messages.
clear wa_message.
endloop.
****Appending the table contents to the returnmsg node
lo_nd_return->bind_table( it_messages ).
DATA lo_window_manager TYPE REF TO if_wd_window_manager.
DATA lo_api_component TYPE REF TO if_wd_component.
DATA lo_window TYPE REF TO if_wd_window.
lo_api_component = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
lo_window = lo_window_manager->create_window(
window_name = 'POP_UP'
title = 'POPUP'
* close_in_any_case = abap_true
message_display_mode = if_wd_window=>co_msg_display_mode_selected
* close_button = abap_true
button_kind = if_wd_window=>co_buttons_ok
message_type = if_wd_window=>co_msg_type_none
default_button = if_wd_window=>co_button_ok
).
lo_window->open( ).
endif.
endmethod.
7.Now create an webdynpro application and execute it.
Check this link. In this, I am explaining how to display Table and ALV grid in pop up window.
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/906dbcfe-edc6-2d10-3e88-b05488ba3787
Hello Jaya,
Ya, you are absolutely right, but this can be done by very ease. Myself and (I Hope)Bala was asking something different, we need to show the error messages by using report_success, report_error_message and report_warning. i.e., if i use these methods then i will be able to display the message with the error icons as well and also in a structured manner and not with the table.
Hope we are clear with the requirement. Please help us to achieve the above.
Regards
Nizamudeen SM
Hallo,
I have tried for a while and i am able to display messages in POPUP the way Nizamudeen and BALA wanted.
The trick is to supply the view name. Then you will get message only in that view.
do 10 times.
lo_message_manager->report_success(
message_text = 'Test message'
* params =
* msg_user_data =
* is_permanent = ABAP_FALSE
* scope_permanent_msg = CO_MSG_SCOPE_CONTROLLER
view = 'V_POPUP'
* show_as_popup =
* controller_permanent_msg =
* msg_index =
* cancel_navigation =
* enable_message_navigation =
).
enddo
Hi Bala Baskaran
I need to do exactely the same thing.
But i have a problem when i bind my table to the return context and i call the bapi.
The binded table isn't populated with the returned messages from the bapi.
Can you help me please or tell me if their is a special code to insert or something else.
Thanks.
Azmi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Baskaran,
Thank you very much. Problem is resolved.
Regards,
Bala Baskaran.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I removed the code from pop up view wddoinit method and also changed the pop up view lifecycle to default frameworkcontroller itself.
The returnmsg node is created in component controller and mapped to main view and popupview.
In Main view button click action itself i appended the return messages to the node. In pop up view only message area UI element is placed to display the messages.
Now also messages are getting displayed in both view.
Regards,
Bala Baskaran.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Remove the text view or the UI element which shows the message from the main view. Since you have mapped the table to the node which is common for both theviews, there should not be any mapping to the node which is common to both the views in main view.
Otherwise, tell me whatever are the elements in your main view and in which exactly the message comes. Tell whether do you marked any datasource for that.
Hi,
Created a Node ReturnMsg in component controller.
ReturnMsg (0..n) DictionaryStruct: Bapiret2
Type
Message
Mapped the node to Main View and Pop Up view.
In Main View button click action the below code is written:
method onactionpop .
data: it_return type table of bapiret2.
data: wa_return type bapiret2.
data: lo_nd_return type REF TO if_wd_context_node.
data: it_messages type wd_this->elements_returnmsg,
wa_message type wd_this->element_returnmsg.
***populating messages instead of calling BAPI/RFC
wa_return-type = 'S'.
wa_return-message = 'Success Message'.
append wa_return to it_return.
wa_return-type = 'E'.
wa_return-message = 'Error Message'.
append wa_return to it_return.
***if return table has messages
***code to open pop up window
if it_return is not initial.
lo_nd_return = wd_context->get_child_node( name = 'RETURNMSG' ).
loop at it_return into wa_return.
wa_message-type = wa_return-type.
wa_message-message = wa_return-message.
append wa_message to it_messages.
clear wa_message.
endloop.
****Appending the table contents to the returnmsg node
lo_nd_return->bind_table( it_messages ).
***opening the pop up
data lo_window_manager type ref to if_wd_window_manager.
data lo_api_component type ref to if_wd_component.
data lo_window type ref to if_wd_window.
lo_api_component = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
lo_window = lo_window_manager->create_window(
window_name = 'W_POP'
title = 'POP UP'
close_in_any_case = abap_true
message_display_mode = '1'
close_button = abap_true
button_kind = 4
message_type = if_wd_window=>co_msg_type_none
default_button = if_wd_window=>co_button_yes
).
lo_window->open( ).
endif.
endmethod.
In Pop Up view WDDoInit method the below code is written and the lifecycle of popup view is changed to "When Visible" so that WDDoInit gets triggered whenever pop up view is opened, else if it is framework controlled then doinit will be called only once during the lifecycle.
method WDDOINIT .
DATA lo_nd_returnmsg TYPE REF TO if_wd_context_node.
DATA lo_el_returnmsg TYPE REF TO if_wd_context_element.
DATA lt_return TYPE wd_this->elements_returnmsg.
data wa_return type wd_this->element_returnmsg.
* navigate from <CONTEXT> to <RETURNMSG> via lead selection
lo_nd_returnmsg = wd_context->get_child_node( name = 'RETURNMSG' ).
CALL METHOD lo_nd_returnmsg->get_static_attributes_table
EXPORTING
from = 1
to = 2147483647
IMPORTING
table = lt_return.
if lt_return is not INITIAL.
***Print messages based on the message type
data lo_api_controller type ref to if_wd_controller.
data lo_message_manager type ref to if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
call method lo_api_controller->get_message_manager
receiving
message_manager = lo_message_manager.
loop at lt_return into wa_return.
if wa_return-type = 'S'.
call method lo_message_manager->report_success
exporting
message_text = wa_return-message.
elseif wa_return-type = 'E'.
call method lo_message_manager->report_error_message
exporting
message_text = wa_return-message.
elseif wa_return-type = 'E'.
call method lo_message_manager->report_warning
exporting
message_text = wa_return-message.
endif.
clear: wa_return.
endloop.
ENDIF.
endmethod.
Now also the messages are displayed in both main view and pop up view. I am not able to supress the message display in main view.
Regards,
Bala Baskaran.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bala,
HAve you tried the following.
ONACTIONPOP
check if there is a message to be displayed (BAIRET2) then open popup.
in the pop up loop through your BAPIRET2 and display your message.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try binding the it_return table to the context node of the popup view.
Check this link. In this, I am explaining how to display Table and ALV grid in pop up window.
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/906dbcfe-edc6-2d10-3e88-b05488ba3787
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Experts please provide some suggestion to solve this issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.