Application Development and Automation 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: 
Read only

Call Bapi - 'BAPI_MESSAGE_GETDETAIL'

Former Member
0 Likes
6,094

I have a problem when I want to call de BAPI 'BAPI_MESSAGE_GETDETAIL'.

I have a table it_idoc with the necesary fields for the bapi. but I want to put the result of the bapi in the field i_idoc - message for every case in the it_idoc.

I don't have any idea how I can write the message on the field idoc-message.

thanks..

loop at it_idoc.

read table it_bapi with key docnum = it_idoc-docnum.

move-corresponding it_bapi to it_idoc.

modify it_idoc.

CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL' destination 'NONE'

EXPORTING

ID = it_idoc-stamid

NUMBER = it_idoc-stamno

  • LANGUAGE = SY-LANGU

TEXTFORMAT = 'ASC'

  • LINKPATTERN =

MESSAGE_V1 = it_idoc-stapa1

MESSAGE_V2 = it_idoc-stapa2

MESSAGE_V3 = it_idoc-stapa3

MESSAGE_V4 = it_idoc-stapa4

  • IMPORTING

  • MESSAGE =

RETURN = ?????????

  • TABLES

  • TEXT =

modify it_idoc.

endloop.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,483

Hello

The BAPI returns the message in its entirety in parameter <b>MESSAGE</b> (220 Char). The long text, if available, is return line by line in the TABLES parameter <b>TEXT</b>.

Parameter <b>RETURN</b> puts the individual parts of the message together in the standard structure BAPIRET2 (Note: RETURN-MESSAGE = MESSAGE parameter).

DATA: 
  ld_idx     TYPE i,
  ld_msg   TYPE bapi_msg,
  ls_idoc   LIKE LINE OF it_idoc.

LOOP AT it_idoc INTO ls_idoc.
  ld_idx = syst-tabix.

* Call the BAPI 
ALL FUNCTION 'BAPI_MESSAGE_GETDETAIL' 
EXPORTING
ID = ls_doc-stamid
NUMBER = ls_idoc-stamno
* LANGUAGE = SY-LANGU
TEXTFORMAT = 'ASC'
* LINKPATTERN =
MESSAGE_V1 = ls_idoc-stapa1
MESSAGE_V2 = ls_idoc-stapa2
MESSAGE_V3 = ls_idoc-stapa3
MESSAGE_V4 = ls_idoc-stapa4
IMPORTING
  MESSAGE = ld_msg.

  ls_idoc-message = ld_msg.  " if types are not compatible
 
  MODIFY it_idoc FROM ls_idoc INDEX ld_idx
    TRANSPORTING message.
ENDLOOP.

Regards

Uwe

1 REPLY 1
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,484

Hello

The BAPI returns the message in its entirety in parameter <b>MESSAGE</b> (220 Char). The long text, if available, is return line by line in the TABLES parameter <b>TEXT</b>.

Parameter <b>RETURN</b> puts the individual parts of the message together in the standard structure BAPIRET2 (Note: RETURN-MESSAGE = MESSAGE parameter).

DATA: 
  ld_idx     TYPE i,
  ld_msg   TYPE bapi_msg,
  ls_idoc   LIKE LINE OF it_idoc.

LOOP AT it_idoc INTO ls_idoc.
  ld_idx = syst-tabix.

* Call the BAPI 
ALL FUNCTION 'BAPI_MESSAGE_GETDETAIL' 
EXPORTING
ID = ls_doc-stamid
NUMBER = ls_idoc-stamno
* LANGUAGE = SY-LANGU
TEXTFORMAT = 'ASC'
* LINKPATTERN =
MESSAGE_V1 = ls_idoc-stapa1
MESSAGE_V2 = ls_idoc-stapa2
MESSAGE_V3 = ls_idoc-stapa3
MESSAGE_V4 = ls_idoc-stapa4
IMPORTING
  MESSAGE = ld_msg.

  ls_idoc-message = ld_msg.  " if types are not compatible
 
  MODIFY it_idoc FROM ls_idoc INDEX ld_idx
    TRANSPORTING message.
ENDLOOP.

Regards

Uwe