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: 

bapiret2 message not showing

former_member670450
Participant

Hi, im actually doing bapiret2 in Class, below are the following code i inserted for bapiret.

the system field sy-msgv1 it seems like it is not working as the message is Empty (check screenshot)

Anything have i miseed?

capture.png

ES_BAPIRET2	Exporting	Type	BAPIRET2                                                                                                                          
DATA: lv_type TYPE sy-msgty.
DATA: lv_id TYPE sy-msgid.
DATA: lv_no TYPE sy-msgno.
DATA: lv_v1 TYPE sy-msgv1.
DATA: lv_v2 TYPE sy-msgv2.


es_bapiret2-type = lv_type.
es_bapiret2-id = lv_id.
es_bapiret2-number = lv_no.
es_bapiret2-message_v1 = lv_v1.
es_bapiret2-message_v2 = lv_v2.

IF IV_MAX_ROWS GT 0.
es_bapiret2-type = 'S'.
es_bapiret2-id = 'Input rows found'.
es_bapiret2-message_v1 = 'Record with input rows found'.

select mandt ebeln bedat bsart lifnr waers knumv
FROM ekko into CORRESPONDING FIELDS OF table it_zheader UP TO IV_MAX_ROWS ROWS.
1 ACCEPTED SOLUTION

michael_piesche
Active Contributor

1. Where do the message variables get filled (lv_type, lv_id, lv_no, lv_v1, lv_v2)? It’s not shown in your coding.

  • Are the values coming from actual custom or standard defined messages, meaning, do the values that you insert in lv_id, lv_no exist in ABAP repository?
"...                                                                                                                         
DATA: lv_type TYPEsy-msgty.
DATA: lv_id TYPEsy-msgid.
DATA: lv_no TYPEsy-msgno.
DATA: lv_v1 TYPEsy-msgv1.
DATA: lv_v2 TYPEsy-msgv2.

es_bapiret2-type = lv_type.
es_bapiret2-id = lv_id.
es_bapiret2-number = lv_no.
es_bapiret2-message_v1 = lv_v1.
es_bapiret2-message_v2 = lv_v2.

"...

2. In this part, you fill the message variables „manually“ and they are not based on existing ABAP repository messages.

  • ID is not a real message Id code, instead you are misusing it as message content.
  • MESSAGE_V1 is misused as ‚further‘ message content when instead it should be in general a Dynamic value that is replaced for a placeholder in a static message content to give detailed info about the error, e.g. a material number, a order number, a Field Name, and so on.
  • ES_BAPIRET2 is also not cleared before filling it with new values, leading to „mixed“ messages.
  • MESSAGE is not set in your case of setting message content manually, e.g. not based on ABAP repository message.
"...
IF IV_MAX_ROWS GT0.
  es_bapiret2-type ='S'.
  es_bapiret2-id ='Input rows found'.
  es_bapiret2-message_v1 ='Record with input rows found'.

  select mandt ebeln bedat bsart lifnr waers knumv FROM ekko into
  CORRESPONDING FIELDS OF table it_zheader UP TO IV_MAX_ROWS ROWS.
"...

3. if you want to replace placeholders in ABAP repository messages, you can use the MESSAGE statement or the FM BALW_BAPIRETURN_GET1

4. Have a look at this tutorial to learn a lot more about how to create custom message classes and messages as well as placeholders and how to replace those with dynamic values; and how to use all of this in coding:

5. Search also for other question and answers about bapiret2 structures, how to fill them and use them:

4 REPLIES 4

Sandra_Rossi
Active Contributor

MESSAGE is empty because you don't fill it.

If you want to fill it:

MESSAGE ID lv_id TYPE lv_type NUMBER lv_no WITH lv_v1 lv_v2
    INTO es_bapiret2-message.

teshanappadoo
Participant

To properly use BAPIRET2 messages;

TYPE - Type of message (S, E, A, X, I, W)

ID - Message class containing your message

NUMBER - Message number in message class used

MESSAGE - Actual Message

MESSAGE_V1 = Message variable 1

MESSAGE_V2 = Message variable 2

MESSAGE_V3 = Message variable 3

MESSAGE_V4 = Message variable 4

Then you can fill your BAPIRET2 like this:

MESSAGE ID lv_id 
   TYPE lv_type
 NUMBER lv_no 
   WITH lv_v1 lv_v2
   INTO es_bapiret2-message.

michael_piesche
Active Contributor

1. Where do the message variables get filled (lv_type, lv_id, lv_no, lv_v1, lv_v2)? It’s not shown in your coding.

  • Are the values coming from actual custom or standard defined messages, meaning, do the values that you insert in lv_id, lv_no exist in ABAP repository?
"...                                                                                                                         
DATA: lv_type TYPEsy-msgty.
DATA: lv_id TYPEsy-msgid.
DATA: lv_no TYPEsy-msgno.
DATA: lv_v1 TYPEsy-msgv1.
DATA: lv_v2 TYPEsy-msgv2.

es_bapiret2-type = lv_type.
es_bapiret2-id = lv_id.
es_bapiret2-number = lv_no.
es_bapiret2-message_v1 = lv_v1.
es_bapiret2-message_v2 = lv_v2.

"...

2. In this part, you fill the message variables „manually“ and they are not based on existing ABAP repository messages.

  • ID is not a real message Id code, instead you are misusing it as message content.
  • MESSAGE_V1 is misused as ‚further‘ message content when instead it should be in general a Dynamic value that is replaced for a placeholder in a static message content to give detailed info about the error, e.g. a material number, a order number, a Field Name, and so on.
  • ES_BAPIRET2 is also not cleared before filling it with new values, leading to „mixed“ messages.
  • MESSAGE is not set in your case of setting message content manually, e.g. not based on ABAP repository message.
"...
IF IV_MAX_ROWS GT0.
  es_bapiret2-type ='S'.
  es_bapiret2-id ='Input rows found'.
  es_bapiret2-message_v1 ='Record with input rows found'.

  select mandt ebeln bedat bsart lifnr waers knumv FROM ekko into
  CORRESPONDING FIELDS OF table it_zheader UP TO IV_MAX_ROWS ROWS.
"...

3. if you want to replace placeholders in ABAP repository messages, you can use the MESSAGE statement or the FM BALW_BAPIRETURN_GET1

4. Have a look at this tutorial to learn a lot more about how to create custom message classes and messages as well as placeholders and how to replace those with dynamic values; and how to use all of this in coding:

5. Search also for other question and answers about bapiret2 structures, how to fill them and use them:

matt
Active Contributor

I also doubt that 'Input rows found' is a valid message class.