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: 

BDC and BAPI

Former Member
0 Kudos

Hi,

Can anyone explain how we can trap error in BDC if we are using BAPI Function Module. And also how the errors trapped are displayed in a flat file. Can anyone help me out with an example.

Thanks in Advance,

Regards

Rijish

4 REPLIES 4

naimesh_patel
Active Contributor
0 Kudos

Hello,

In BAPI, you can check the RETURN table parameter of the BAPI. So, check this table parameter.

Regards,

Naimesh

Former Member
0 Kudos

Hello,

BDC using BAPI is handled by calling the BAPI by passing the import parameters and getting the export parameters of the FM.

After execution of the BAPI, check the return Parameter BAPIRET2.

If BAPIRET2-TYPE field is 'S' its success.

Possible values for TYPE>>

S = success message

E = error message

W = warning message

I = information message

A = termination message (abort)

Some fields in BAPIRET2 are described as below:

ID(CHAR 20): Message ID The structure BAPIRET2 takes into account the name space extension for the message class as of Release 4.0. If you want messages to be compatible with earlier R/3 Releases, use the message classes before Release 4.0.

NUMBER: Message number

MESSAGE(CHAR 220)Full message text from the message table. All variables (in fields Message_V1 to Message_V4) have been replaced with text.

There are some more fields you can use refer : http://help.sap.com/saphelp_nw04/helpdata/en/a5/3ec9f74ac011d1894e0000e829fbbd/content.htm

Now after checking the status/TYPE in BAPIRET2, you can update the file. May be create an additional Column in your internal table and keep updating the same about SUCCESS/FAIL and DOWNLOAD the ITAB to file or create dataset from ITAB.

Regards,

Vishal

**Reward if helpful

Former Member
0 Kudos

hi rijish,

in BDC...

u can use the FM FORMAT_MESSAGE..

CALL TRANSACTION 'FK01' USING IT_BDCDATA MODE 'A'

UPDATE 'S'

MESSAGES INTO IT_MESSAGES.

WRITe:/ SY-SUBRC.

PERFORM FORMAT_MESSAGES.

form FORMAT_MESSAGES .

DATA: L_MSG(100).

LOOP AT IT_MESSAGES.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = IT_MESSAGES-MSGID

LANG = SY-LANGU

NO = IT_MESSAGES-MSGNR

V1 = IT_MESSAGES-MSGV1

V2 = IT_MESSAGES-MSGV2

V3 = IT_MESSAGES-MSGV3

V4 = IT_MESSAGES-MSGV4

IMPORTING

MSG = L_MSG

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2

.

write:/ l_msg.

endloop.

endform.

IN BAPI..

u can check the parameter RETURN..

hope this helps,

priya.

Former Member
0 Kudos

Hi ,

After BAPI call loop thru return table for message type 'E' or 'A' , then you will get all error messages or abend messages.

call BAPI.

if not return_table is initial.
loop at return_table where type = 'E' or type 'A'.
write:/ return_table-message.
endloop.
endif

.

Regards,

Raghav