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: 

Populating error messages return from bapi return parameter

Former Member
0 Kudos

Hi All..,

I am calling Bapi if its successfull ok . some times if it returns error messages those will be stored in return parameter type bapiret2.

if i want to display the message i am looping it and printing wa-type,wa-id,wa-msg_log_no,wa-message_v1,wa-message etc..

but its displyaing only error type(E) and id(IO/VL) msg_log_no(229/213) something like that.. but i want the description of that error type which is stored in table T100. how can achieve..???

ex: E 213 contains serial no already assigned..

i tried like this.....

loop at it_return into wa_return.

write:/ wa_return-type,wa_return-id,wa_return-msg_log_no,wa_return-message.

endloop.

its displaying E IO 229 00000.

i can check the same in se91 by giving id IO and number 229 .. which is stored in table T100.. the same i want to display through the program..

Please help.......

Thanks

Anand

1 ACCEPTED SOLUTION

awin_prabhu
Active Contributor

Try FM FORMAT_MESSAGE.


DATA: l_msg_str(100).

loop at it_return into wa_return.
 CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
      id        = wa_return-id
      lang      = sy-langu
      no        = wa_return-number
      v1        = message_v1
      v2        = message_v2
      v3        = message_v3
      v4        = message_v4
    IMPORTING
      msg       = l_msg_str   " Message text
    EXCEPTIONS
      not_found = 1
      OTHERS    = 2.
endloop.

10 REPLIES 10

awin_prabhu
Active Contributor

Try FM FORMAT_MESSAGE.


DATA: l_msg_str(100).

loop at it_return into wa_return.
 CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
      id        = wa_return-id
      lang      = sy-langu
      no        = wa_return-number
      v1        = message_v1
      v2        = message_v2
      v3        = message_v3
      v4        = message_v4
    IMPORTING
      msg       = l_msg_str   " Message text
    EXCEPTIONS
      not_found = 1
      OTHERS    = 2.
endloop.

0 Kudos

i tried Formate_message.. but the result is same...like my write statement from it_return loop

its not getting the message from the table T100

0 Kudos

Have u passed right parameters to the FM. Better paste ur code.

Have you tried like below code.


DATA: l_msg_str(100).
 
loop at it_return into wa_return.
 CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
      id        = wa_return-id
      lang      = sy-langu
      no        = wa_return-number
      v1        = wa_return-message_v1
      v2        = wa_return-message_v2
      v3        = wa_return-message_v3
      v4        = wa_return-message_v4
    IMPORTING
      msg       = l_msg_str   " Message text
    EXCEPTIONS
      not_found = 1
      OTHERS    = 2.
write:/ l_msg_str.
endloop.
 

0 Kudos

Hi thank you for helping..

i passed correctly even i checked in debugging mode those parameters doesn't contain any data....

any other FM?

0 Kudos

Also try FM BAPI_MESSAGE_GETDETAIL which returns long text also

0 Kudos

Never mind. SAPFAN is on it.

Edited by: Sampath Kumar on May 9, 2011 10:54 AM

0 Kudos

ok fine..

dont mind..

Did you got my point.. i want to get the message from standard message table T100 based on error number from bapi return parameter. because bapi return internal table doesn't have message test nothing..it just showing empty all the message variables..

0 Kudos

Alright here is more details

Following BAPI can be used to get the message for any message id, Message no and/or for message variables that comes from BAPI in the form of BAPIRET2 structure or in fact any form as long as you have the Message ID/no and language.

For example:

call function 'BAPI_MESSAGE_GETDETAIL'

exporting

id = msgid

number = msgno

language = sy-langu

textformat = 'NON'

message_v1 = msgv1

message_v2 = msgv2

message_v3 = msgv3

message_v4 = msgv4

importing

message = message

return = wa_return.

What the above BAPI does is simple. for example, if you get just message id(V0) and number(010) in IT_BAPIRET2 - (Obviously, you should loop the internal table to work area) - BAPI selects message text from message class V0 and number 001 and gives you the formatted message (System: More than 9 windows open: system limit reached) . You can see the same in SE91 .

If you get any message variables in IT_BAPIRET2 for example ID(Message class) = V0 and number 040 and MSGV1 = 'xxxx' and MSGV2 = '8'

Then the same bapi would return the message Data backup table 'XXXX' with RC= 8

This is as simple as selecting messages from error table T100 for Language/application area (message class/id) and message number but the only difference is the bapi formats the data based on message variable and you dont need to code it.

If you dont see any data in IT_BAPIRET2 then that is fine.

0 Kudos

Its working verywell with u r ans..

I gave u full points

Jelena
Active Contributor
0 Kudos

Usually I had no problem using MESSAGE field in the BAPI return table. Are you saying this field is not getting populated? Strange...