Posted: Fri Oct 05, 2007 9:41 am Post subject: Using BAPI for purchase requisition creation and deletion
What is required to be done is to populate the values into the tables that is present in the BAPI before calling it. In the sample code passed values for tables Requisition items only. You may be required to populate other fields in the different tables in the BAPI as per your requirement.
Code:
report z_req_create.
DATA : T_REQUISITION_ITEMS LIKE BAPIEBANC OCCURS 0 WITH HEADER LINE,
T_RETURN LIKE BAPIRETURN OCCURS 0 WITH HEADER LINE .
IF NOT E_NUMBER IS INITIAL .
WRITE:/ 'REQ NO:' , E_NUMBER , 'CREATED'.
ELSE.
LOOP AT T_RETURN.
WRITE T_RETURN-MESSAGE.
ENDLOOP.
ENDIF.
Set deletion indicator.
Code:
report Z_REQUISITION_DELETE.
tables: eban.
data: gt_BAPIEBAND type BAPIEBAND occurs 0 with header line,
gt_return type bapiret2 occurs 0 with header line,
error_occured.
PARAMETERS: p_banfn like eban-banfn.
start-of-selection.
select * from eban where banfn eq p_banfn.
move: eban-bnfpo to gt_BAPIEBAND-PREQ_ITEM,
'X' to gt_BAPIEBAND-DELETE_IND,
'X' to gt_BAPIEBAND-CLOSED.
append gt_BAPIEBAND.
endselect.
end-of-selection.
CALL FUNCTION 'BAPI_REQUISITION_DELETE'
EXPORTING
NUMBER = p_banfn
TABLES
REQUISITION_ITEMS_TO_DELETE = gt_BAPIEBAND
RETURN = gt_return.
if gt_return[] is not initial.
loop at gt_return.
MESSAGE
ID gt_return-id
TYPE gt_return-type
NUMBER gt_return-number
WITH gt_return-message_v1
gt_return-message_v2
gt_return-message_v3
gt_return-message_v4.
case gt_return-type.
when 'E' or 'A'.
exit.
endcase.
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.