Posted: Sun Oct 14, 2007 9:49 pm Post subject: Delete Sales Order Item using BAPI
Author: Jelena
Here is a very quick test example of the line deletion:
Code:
PARAMETERS: p_vbeln TYPE vbeln,
p_posnr TYPE posnr.
DATA: s_order_header_in LIKE bapisdh1.
DATA: s_order_header_inx LIKE bapisdh1x.
DATA: BEGIN OF i_order_item_in OCCURS 0.
INCLUDE STRUCTURE bapisditm.
DATA: END OF i_order_item_in.
DATA: BEGIN OF i_order_item_inx OCCURS 0.
INCLUDE STRUCTURE bapisditmx.
DATA: END OF i_order_item_inx.
DATA: BEGIN OF it_return OCCURS 0.
INCLUDE STRUCTURE bapiret2.
DATA: END OF it_return.
LOOP AT it_return.
MESSAGE
ID it_return-id
TYPE 'I'
NUMBER it_return-number
WITH
it_return-message_v1
it_return-message_v2
it_return-message_v3
it_return-message_v4.
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
Possible causes for the line not being deleted:
1. BAPI_TRANSACTION_COMMIT is missing
2. BAPI fields are populated incorrectly
3. A subsequent document (e.g. an outbound delivery) exists for the line item. Such line items can not be deleted.
Usually the message table returned by BAPI (it_return) should provide a clue. I'm using a hardcoded message type 'I' in this test to display all the messages. Sometimes the message type returned by BAPI does not make much sense (e.g. some messages that should really be errors are returned with type W or S). Also don't bother checking SY-SUBRC - it's almost always 0.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.