05-14-2008 7:17 AM
hi all,
Can anyone suggest how to use BAPI_REQUISITION_CREATE.
please provide code if available.
it would b a great help.
05-14-2008 7:26 AM
Hi
Hope it will help you.
Reward if help.
CALL FUNCTION 'BAPI_REQUISITION_CREATE'
EXPORTING
SKIP_ITEMS_WITH_ERROR =
AUTOMATIC_SOURCE = 'X'
IMPORTING
NUMBER =
TABLES
requisition_items =
REQUISITION_ACCOUNT_ASSIGNMENT =
REQUISITION_ITEM_TEXT =
REQUISITION_LIMITS =
REQUISITION_CONTRACT_LIMITS =
REQUISITION_SERVICES =
REQUISITION_SRV_ACCASS_VALUES =
RETURN =
REQUISITION_SERVICES_TEXT =
REQUISITION_ADDRDELIVERY =
EXTENSIONIN =
.
05-14-2008 7:27 AM
Hi,
Check the sample code
codeREPORT ZV1_BAPI_PR .
data:wa_eban like eban.
DATA: BEGIN OF itab OCCURS 0,
bsart(4),
."Purchase requisition document type
werks(4),
Plant
txz01(40),
."Short text
menge(13),
."Purchase requisition quantity
meins(3),
."Purchase requisition unit of measure
eeind(10),
."Item delivery date
wgbez(9),
."Material Group
name1(4),
."Plant
ekgrp(3),
."Purchasing Group
afnam(12),
."Name of requisitioner/requester
bednr(10),
."Requirement Tracking Number
knttp(1),
."Account assignment category
sakto(10),
."G/L Account Number
ps_posid(8),
."Work Breakdown Structure Element (WBS Element)
editor(132),
."Text line
END OF itab.
DATA: itab_bapiebanc LIKE bapiebanc OCCURS 0 WITH HEADER LINE.
DATA: itab_bapiebkn LIKE bapiebkn OCCURS 0 WITH HEADER LINE.
DATA: itab_bapiebantx LIKE bapiebantx OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF errmsg OCCURS 10.
INCLUDE STRUCTURE bapiret2.
DATA: END OF errmsg.
DATA: errflag.
select single * from eban
into wa_eban.
if sy-subrc = 0.
move-corresponding wa_eban to itab.
append itab.
clear itab.
endif.
*CALL FUNCTION 'UPLOAD'
EXPORTING
filename = 'C:\Documents and Settings\sap\Desktop\New Text Document (2).txt'
filetype = 'DAT'
TABLES
data_tab = itab.
*
.
*if sy-subrc 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
exit.
*endif.
LOOP AT itab.
itab_bapiebanc-doc_type = itab-bsart.
itab_bapiebanc-short_text = itab-txz01.
itab_bapiebanc-quantity = itab-menge.
itab_bapiebanc-unit = itab-meins.
if not itab-eeind is initial.
itab_bapiebanc-deliv_date = itab-eeind.
else.
itab_bapiebanc-deliv_date = sy-datum + 30.
endif.
itab_bapiebanc-plant = itab-werks.
itab_bapiebanc-pur_group = itab-ekgrp.
itab_bapiebanc-preq_name = itab-afnam.
itab_bapiebanc-trackingno = itab-bednr.
itab_bapiebanc-mat_grp = itab-wgbez.
itab_bapiebanc-acctasscat = itab-knttp.
itab_bapiebanc-acctasscat = 'A'.
itab_bapiebkn-g_l_acct = itab-sakto.
itab_bapiebkn-wbs_elem = itab-ps_posid.
itab_bapiebantx-text_line = itab-editor.
itab_bapiebantx-text_line = 'Test for Purchase requisiton'.
APPEND itab_bapiebkn.
APPEND itab_bapiebanc.
APPEND itab_bapiebantx.
ENDLOOP.
*
CALL FUNCTION 'BAPI_REQUISITION_CREATE'
TABLES
requisition_items = itab_bapiebanc
requisition_account_assignment = itab_bapiebkn
requisition_item_text = itab_bapiebantx
return = errmsg.
LOOP AT errmsg.
IF errmsg-type EQ 'E'.
WRITE:/'Error in function', errmsg-message.
errflag = 'X'.
ELSE.
WRITE:/ errmsg-message.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
*
*loop at itab_bapiebanc.
*write:/ itab_bapiebanc-doc_type,
itab_bapiebanc-short_text,
itab_bapiebanc-quantity,
itab_bapiebanc-unit ,
itab_bapiebanc-deliv_date,
itab_bapiebanc-plant,
itab_bapiebanc-pur_group,
itab_bapiebanc-preq_name,
itab_bapiebanc-trackingno,
itab_bapiebanc-mat_grp,
100 itab_bapiebanc-acctasscat.
*
*endloop.
*
*loop at itab_bapiebkn.
write:/ itab_bapiebkn-g_l_acct,
itab_bapiebkn-wbs_elem.
*
*endloop.
**
*
*loop at itab_bapiebantx.
*write:/ itab_bapiebantx-text_line.
*endloop.
**[/code]
Regards,
Raj.
05-14-2008 7:35 AM
Hi ,
CALL FUNCTION 'BAPI_REQUISITION_CREATE'
EXPORTING
automatic_source = 'X'
IMPORTING
number = l_preq_no
TABLES
requisition_items = i_item
requisition_account_assignment = i_acc_assign
requisition_limits = i_limits
requisition_services = i_services
requisition_srv_accass_values = i_serv_acc
return = li_return
requisition_addrdelivery = i_address.
fill the internal table with the corresponding data
move item details into the internal table i_item
move account assignment detials into i_acc_assing
move limits detials into i_limits
services details into i_services
address details into i_address
and post the bapi, once the bapi posting is successfull the PREQ number will be exported to l_preq_no, and if any errors occured while posting the bapi, the errors captured into the internal table li_return.
Please Reward the points if useful