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

BAPI Message Handeling

Former Member
0 Likes
2,210

In BAPI even after collecting of return parameters and looping into 'FORMAT_MESSAGE' i am not able to get the success messages in the outpot?

can any one give me how to do this ?

1 ACCEPTED SOLUTION
Read only

former_member761936
Active Participant
0 Likes
1,446

Hi Krishna,

Are you sure you are getting sucess messages form BAPI, If you got message then it will diffinitely store in BApi return table .Read the table with message type as S and Send that to Format_message .Here is the sample code for using ffunction module FORMAT_MESSAGE.

LOOP AT MESSTAB.

MOVE-CORRESPONDING MESSTAB TO MESSAGES.

MESSAGES-PLNUM = PLAN-PLNUM.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = MESSTAB-MSGID

LANG = MESSTAB-MSGSPRA

NO = MESSTAB-MSGNR

V1 = MESSTAB-MSGV1

V2 = MESSTAB-MSGV2

V3 = MESSTAB-MSGV3

V4 = MESSTAB-MSGV4

IMPORTING

MSG = MESSAGES-TEXT.

APPEND MESSAGES.

ENDLOOP.

4 REPLIES 4
Read only

former_member761936
Active Participant
0 Likes
1,447

Hi Krishna,

Are you sure you are getting sucess messages form BAPI, If you got message then it will diffinitely store in BApi return table .Read the table with message type as S and Send that to Format_message .Here is the sample code for using ffunction module FORMAT_MESSAGE.

LOOP AT MESSTAB.

MOVE-CORRESPONDING MESSTAB TO MESSAGES.

MESSAGES-PLNUM = PLAN-PLNUM.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = MESSTAB-MSGID

LANG = MESSTAB-MSGSPRA

NO = MESSTAB-MSGNR

V1 = MESSTAB-MSGV1

V2 = MESSTAB-MSGV2

V3 = MESSTAB-MSGV3

V4 = MESSTAB-MSGV4

IMPORTING

MSG = MESSAGES-TEXT.

APPEND MESSAGES.

ENDLOOP.

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,446

Hello Krishna

Regarding the messages returned by BAPIs you can only be sure that if an error occurred you will receive an error message (of type A(bort), E(error) or X(dump)).

However, in case of a successful BAPI call you may get a S(uccess) message or not. Some BAPIs do not return anything if they succeeded.

Thus, I usually evaluate the result of a BAPI call like this:


" Call BAPI, messages are returned as TABLES parameter RETURN and stored in itab LT_RETURN:

LOOP AT lt_return TRANSPORTING NO FIELDS
              WHERE ( type CA 'AEX' ).
  EXIT.
ENDLOOP.
" BAPI failed
IF ( syst-subrc = 0 ).


" BAPI succeeded
ELSE.

ENDIF.

Regards

Uwe

Read only

Former Member
0 Likes
1,446

Hi,

Every BAPI is having the return table with the name of (RETURN) to handle error messages.. it refers the structure BAPIRET2 structure..

this are the main fields in structure BAPIRET2..

TYPE Message type

ID Message Class

MESSAGE Message Text

MESSAGE_V1 Message Variable

MESSAGE_V2 Message Variable

MESSAGE_V3 Message Variable

MESSAGE_V4 Message Variable

PARAMETER Parameter Name

base on TYPE field u can find where the message is error / successed one...

hope helpful

Raghunath.S

Read only

Former Member
0 Likes
1,446

vghjg