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: 

Error msg in BAPI

former_member342013
Contributor
0 Kudos
111

Hi

this is my BAPI code..

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = bapimathead

CLIENTDATA = bapi_mara

CLIENTDATAX = bapi_marax

TABLES

MATERIALDESCRIPTION = it_bapi

RETURNMESSAGES = return .

commit work AND WAIT.

IF return-type = 'E'.

WRITE: /'ERROR',return-message, 'for material:',bapimathead-material.

ELSEIF return-type = 'S'.

WRITE: 'material is created successfully',bapimathead-material.

ENDIF.

my problm is if the material already exists i should get the error msg as "Material already Exists" other wise it should upload the material successfully....

Bt in my program if the material exists then alos it is uploading the same material once again....

how to do this?

Regards

Smitha

1 ACCEPTED SOLUTION

Former Member
0 Kudos
76

Dont commit after BAPI_SAVEDATA..

check for return type

IF return-type = 'E'.

WRITE: /'ERROR',return-message, 'for material:',bapimathead-material.

ELSEIF return-type = 'S'.

BAPI_TRANSACTION_COMMIT/commit work and wait.

endif.

3 REPLIES 3

Former Member
0 Kudos
77

Dont commit after BAPI_SAVEDATA..

check for return type

IF return-type = 'E'.

WRITE: /'ERROR',return-message, 'for material:',bapimathead-material.

ELSEIF return-type = 'S'.

BAPI_TRANSACTION_COMMIT/commit work and wait.

endif.

former_member438956
Active Participant
0 Kudos
76

Hi smitha,

The same function module can be used for extension of material also. so plz make sure that the input ur giving to the FM are plant specific and already exists.

Regards,

Anil N.

former_member342013
Contributor
0 Kudos
76

thank you