cancel
Showing results for 
Search instead for 
Did you mean: 

Display Massages from context within message manager

Former Member
0 Kudos

Hello,

i have got a bapireturn in my context with a node named "return" an some attributes like "type" and "message", .

If I run the Bapi this node get some infos like:

Type: E message: Error1

Type: W message: warning1

Type: W message: warning2

how could I get this messages and warnings into the Message manager?

If i implement the Message Manager with the code-wizard, i only get one Message with my own text, but I want every massage with the original text of the warning...

Is this possible?

Could you can give me some advise and code?

That would be really nice!!

Thank you for your help!

Edited by: john Thompson on May 20, 2008 12:53 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Your bapi would return the bapiret table as type Bapiret2_t i guess.

data : bapiret like line of bapiret2_t.

loop at bapiret2_t into bapiret.

call method l_message_manager->report_t100_message

exporting

msgid = bapiret-msgid

msgno = bapiret-msgno

msgty = bapiret-msgtyp .

endloop.

Regards,

Shruthi R

Former Member
0 Kudos

OK.

But now I have a problem with my Data-declaration.

My node has the name "et_return" and has the dictionary-structure of BAPIRET2. It has stored all the data which i want to display.

so what is the correct data-declaration of this node and the internal table, and how could i get the informations to display?

I tried some declarations, but every time I get a error.

If you need more information please say it.

Thank you for your help!

Former Member
0 Kudos

Hi,

Your context node should be of type BAPIRET2, with cardinality 0..n. When your API returns the errors, you need to bind them to the context node using bind_elements or bind_table.

Then, to display the messages using the message manager, you need to retrieve the data from the context using get_static_attributes_table. This will again return you a table of type BAPIRET2. Now you can use the above code to display the messages. The data declaration is as given in the code snippet, your work area should be of type BAPIRET2.

Can you post your existing code so that it would be easier to check what is incorrect.

Thanks,

Nithya

Former Member
0 Kudos

Thank you for your reply.

Your context node should be of type BAPIRET2, with cardinality 0..n. When your API returns the errors, you need to bind them to the context node using bind_elements or bind_table.

That is not the problem, it is already done

Then, to display the messages using the message manager, you need to retrieve the data from the context using get_static_attributes_table. This will again return you a table of type BAPIRET2.

Stop. This is the problem. If i want do declare this like you said. it will show me a message in my :

The method "get_Static_attributes_table" is unknown or protected or private.

How could I solve this problem?

Former Member
0 Kudos

If you use the code wizard (Ctrl + F7) to read your context node, the data declaration will be done by the wizard itself. The context node should be of type if_wd_context_node.

data: lo_node type ref to if_wd_context_node,

lt_bapiret type table of bapiret2.

lo_node = wd_context->get_child_node( node name ).

lo_node->get_static_attributes_table(

importing

table = lt_bapiret ).

This will work. If you still have issues, please paste your code.

Regards,

Nithya

Former Member
0 Kudos

Hi John,

data: lo_et_return type ref to if_wd_context_node,

bapiret_t type table of bapiret2.

lo_et_return = wd_context->get_child_node( et_return ).

lo_et_return ->get_static_attributes_table(

importing

table = bapiret_t ).

Now you can follow my code to loop and display the messages.

Shruthi

Former Member
0 Kudos

Thank you all for your help!

I just rewrote my code and it was all ok. It is working now like you mentioned.

But one little question: must I implement the "report_t100_message" or it is possible to raise the message with the "report_error_message" or others?

So the question behind this is: how could I select the messagetext in the line of table?

I know, i could do things like "loop at lt_bapiret into bapiret where type = 'S'.

So that I only have Sucess-Messages within this loop, but the line has more than only the type, so how could I select the Messagetext-column and pass the text to a variable?

If this would work, I would be very very happy!

Former Member
0 Kudos

Hi,

You can raise the message using the following methods:

REPORT_SUCCESS

REPORT_WARNING

REPORT_ERROR_MESSAGE

When you loop through your bapiret table, pass the message text to the above methods based on the message type and show the messages.

You just need to pass the message text to the MESSAGE_TEXT parameter in teh above methods.

loop at bapiret2_t into bapiret.

case msgtyp.

when 'S'.

call REPORT_SUCCESS..

whne 'E'.

call REPORT_ERROR_MESSAGE....

when 'W'.

call REPORT_WARNING.

endcase.

endloop.

Hope this answers your question

Shruthi

Edited by: Shruthi R on May 21, 2008 7:57 AM

Former Member
0 Kudos

Let's see..

I have this in my mehtod:


loop at bapiret2_t into bapiret.
case msgtyp.
when 'S'.
call REPORT_SUCCESS..
*message_text = bapiret-message*
...
whne 'E'.
call REPORT_ERROR_MESSAGE....
when 'W'.
call REPORT_WARNING.
endcase.
endloop.

but all i get is a Typeconflict in the method.

Message is char with 220 lenght. Why get I a Typeconflict?

Former Member
0 Kudos

Hi,

I think you are getting a type conflict because of different datatypes of bapiret-message and message_text. declare a variable of type message_text and pass the value of bapiret-message before displaying.

data : msg type CSEQUENCE.

loop at bapiret2_t into bapiret.

msg = bapiret-message.

case bapiret-msgtyp.

when 'S'.

call REPORT_SUCCESS..

message_text = msg

...

whne 'E'.

call REPORT_ERROR_MESSAGE....

when 'W'.

call REPORT_WARNING.

endcase.

endloop.

Former Member
0 Kudos

sometimes i should sleep a little bit more.

Thank You all for your help!!

Problem solved!

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Just loop at your bapiret table and using the message manager just report the error. All the errors are displayed in the message manager.

data: l_current_controller type ref to if_wd_controller,

l_message_manager type ref to if_wd_message_manager.

l_current_controller ?= wd_this->wd_get_api( ).

call method l_current_controller->get_message_manager

receiving

message_manager = l_message_manager.

loop at bapiret.

call method l_message_manager->report_t100_message

exporting

msgid = bapiret-msgid

msgno = bapiret-msgno

msgty = bapiret-msgtyp .

endloop.

Regards,

Shruthi

Former Member
0 Kudos

OK, Thank you for your help!

But - shame on me - how could I loop at my bapiret table?

Could you explain it to me?