Add message in BAPIRET2 table

Add message in BAPIRET2 table


FORM add_message      USING pw_type TYPE sy-msgty
                            pw_id   TYPE sy-msgid
                            pw_num  TYPE sy-msgno
                            pw_v1   "TYPE sy-msgv1
                            pw_v2   "TYPE sy-msgv2
                            pw_v3   "TYPE sy-msgv3
                            pw_v4.  "TYPE sy-msgv4.

  DATA ls_bapiret2 TYPE bapiret2.

  ls_bapiret2-type       = pw_type .
  ls_bapiret2-id         = pw_id   .
  ls_bapiret2-number     = pw_num  .
  ls_bapiret2-message_v1 = pw_v1   .
  ls_bapiret2-message_v2 = pw_v2   .
  ls_bapiret2-message_v3 = pw_v3   .
  ls_bapiret2-message_v4 = pw_v4   .

  IF ls_bapiret2-type IS INITIAL.
    ls_bapiret2-type = 'S'.
  ENDIF.

  IF ls_bapiret2-id IS INITIAL.
    ls_bapiret2-id     = '0H'.
  ENDIF.

  IF ls_bapiret2-number IS INITIAL.
    ls_bapiret2-number = '000'.
  ENDIF.


  MESSAGE    ID ls_bapiret2-id
           TYPE ls_bapiret2-type
         NUMBER ls_bapiret2-number
           WITH ls_bapiret2-message_v1
                ls_bapiret2-message_v2
                ls_bapiret2-message_v3
                ls_bapiret2-message_v4
           INTO ls_bapiret2-message.

  APPEND ls_bapiret2 TO gi_user_message.

ENDFORM.

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

2 Comments so far

VíctorPosted on2:38 pm - Aug 11, 2020

You are a legend my friend

FrankkesiaPosted on12:28 am - Jul 13, 2021

Very great post. I simply stumbled upon your blog and wished to say that I have really enjoyed browsing your blog posts. In any case I will be subscribing to your rss feed and I hope you write again soon!

Leave a Reply