2008 Mar 14 12:02 PM
Hi,gurus,
Is there any BAPI to create PO.Pl send to me along with the sample code.
Gratefull answeres will be awarded.
Regards,
Venkatesh
9892 895847
2008 Mar 14 12:12 PM
Hi,
Use the Fm for BAPI Creation.
Fm is BAPI_PO_CREATE
Pass The parameter according to the Function Module Documentation.
Sample Code
FUNCTION ZBAPI_PO_CREATE_ASYNC.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(PO_HEADER) TYPE ZBAPI_PO_HEADER
*" VALUE(BYPASS_BAPI) TYPE CHAR1 OPTIONAL
- 8 -
*" TABLES
*" PO_ITEMS STRUCTURE ZBAPI_PO_DETAIL
*"----------------------------------------------------------------------
DATA: BAPI_PO_HEADER LIKE BAPIEKKOC,
BAPI_PO_ITEMS LIKE BAPIEKPOC OCCURS 0 WITH HEADER LINE,
BAPI_PO_SCHEDULES LIKE BAPIEKET OCCURS 0 WITH HEADER LINE,
RANDOM_PO LIKE DATATYPE-INTEGER4,
PURCHASEORDER LIKE BAPIEKKOC-PO_NUMBER.
if BYPASS_BAPI ne ''.
CALL FUNCTION 'RANDOM_I4'
EXPORTING
RND_MIN = 0
RND_MAX = 1000000000
IMPORTING
RND_VALUE = RANDOM_PO
.
move RANDOM_PO to PURCHASEORDER.
else.
* Below are use to call BAPI_PO_CREATE
move-corresponding PO_HEADER to BAPI_PO_HEADER.
loop at PO_ITEMS.
move-corresponding PO_ITEMS to BAPI_PO_ITEMS.
append BAPI_PO_ITEMS.
move-corresponding PO_ITEMS to BAPI_PO_SCHEDULES.
append BAPI_PO_SCHEDULES.
endloop.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
PO_HEADER = BAPI_PO_HEADER
* PO_HEADER_ADD_DATA =
* HEADER_ADD_DATA_RELEVANT =
* PO_ADDRESS =
* SKIP_ITEMS_WITH_ERROR = 'X'
* ITEM_ADD_DATA_RELEVANT =
IMPORTING
PURCHASEORDER = PURCHASEORDER
TABLES
PO_ITEMS = BAPI_PO_ITEMS
* PO_ITEM_ADD_DATA =
PO_ITEM_SCHEDULES = BAPI_PO_SCHEDULES
* PO_ITEM_ACCOUNT_ASSIGNMENT =
* PO_ITEM_TEXT =
* RETURN =
* PO_LIMITS =
* PO_CONTRACT_LIMITS =
* PO_SERVICES =
* PO_SRV_ACCASS_VALUES =
* PO_SERVICES_TEXT =
* PO_BUSINESS_PARTNER =
* EXTENSIONIN =
* POADDRDELIVERY =
CALL FUNCTION 'ZBAPI_PO_SEND_RESP_XI_ASYNC'
in background task
destination 'RFC2XR3'
exporting
PO_NUMBER = PURCHASEORDER
VENDOR_NUMBER = PO_HEADER-VENDOR.
commit work.
endif.
ENDFUNCTION.
Revert Back In case Of any help.
regards
Sandipan
Hi,gurus,
Is there any BAPI to create PO.Pl send to me along with the sample code.
Gratefull answeres will be awarded.
Regards,
Venkatesh
9892 895847
2008 Mar 14 12:12 PM
Hi,
Use the Fm for BAPI Creation.
Fm is BAPI_PO_CREATE
Pass The parameter according to the Function Module Documentation.
Sample Code
FUNCTION ZBAPI_PO_CREATE_ASYNC.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(PO_HEADER) TYPE ZBAPI_PO_HEADER
*" VALUE(BYPASS_BAPI) TYPE CHAR1 OPTIONAL
- 8 -
*" TABLES
*" PO_ITEMS STRUCTURE ZBAPI_PO_DETAIL
*"----------------------------------------------------------------------
DATA: BAPI_PO_HEADER LIKE BAPIEKKOC,
BAPI_PO_ITEMS LIKE BAPIEKPOC OCCURS 0 WITH HEADER LINE,
BAPI_PO_SCHEDULES LIKE BAPIEKET OCCURS 0 WITH HEADER LINE,
RANDOM_PO LIKE DATATYPE-INTEGER4,
PURCHASEORDER LIKE BAPIEKKOC-PO_NUMBER.
if BYPASS_BAPI ne ''.
CALL FUNCTION 'RANDOM_I4'
EXPORTING
RND_MIN = 0
RND_MAX = 1000000000
IMPORTING
RND_VALUE = RANDOM_PO
.
move RANDOM_PO to PURCHASEORDER.
else.
* Below are use to call BAPI_PO_CREATE
move-corresponding PO_HEADER to BAPI_PO_HEADER.
loop at PO_ITEMS.
move-corresponding PO_ITEMS to BAPI_PO_ITEMS.
append BAPI_PO_ITEMS.
move-corresponding PO_ITEMS to BAPI_PO_SCHEDULES.
append BAPI_PO_SCHEDULES.
endloop.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
PO_HEADER = BAPI_PO_HEADER
* PO_HEADER_ADD_DATA =
* HEADER_ADD_DATA_RELEVANT =
* PO_ADDRESS =
* SKIP_ITEMS_WITH_ERROR = 'X'
* ITEM_ADD_DATA_RELEVANT =
IMPORTING
PURCHASEORDER = PURCHASEORDER
TABLES
PO_ITEMS = BAPI_PO_ITEMS
* PO_ITEM_ADD_DATA =
PO_ITEM_SCHEDULES = BAPI_PO_SCHEDULES
* PO_ITEM_ACCOUNT_ASSIGNMENT =
* PO_ITEM_TEXT =
* RETURN =
* PO_LIMITS =
* PO_CONTRACT_LIMITS =
* PO_SERVICES =
* PO_SRV_ACCASS_VALUES =
* PO_SERVICES_TEXT =
* PO_BUSINESS_PARTNER =
* EXTENSIONIN =
* POADDRDELIVERY =
CALL FUNCTION 'ZBAPI_PO_SEND_RESP_XI_ASYNC'
in background task
destination 'RFC2XR3'
exporting
PO_NUMBER = PURCHASEORDER
VENDOR_NUMBER = PO_HEADER-VENDOR.
commit work.
endif.
ENDFUNCTION.
Revert Back In case Of any help.
regards
Sandipan
2008 Mar 14 1:18 PM
Hi Sandipan,
Thanx for the answer.
I would appreciate if u help me solving the below problems.
Once PO is created I need to do GR using TCODE MIGO.
I have created the recording for this using SHDB while recording for tcode MIGO i need to enter the Serial numbers for
each material the right most tab below the number of serial numbers = quantity of material.
when i am recording using dummy material of qty 2 then i can enter only two serial numbers in recording these two steps are
recorded as
perform bdc_field using 'GOSERIAL-SERIALNO(01)'
'venkytest001'.
perform bdc_field using 'GOSERIAL-SERIALNO(02)'
'venkytest002'.
but when i run the same bdc for other material with qty more than 2....the BDC is going fail.
I need serial numbers field to be dynamic......so that i can have n number of serial numbers for different materials.
pl help me it's urgent.
2) Is there any user exit/BADI after saving invoice so that i can populate information like invoice no,material,qty etc in z*table.
Awaiting ur reply ASAP.
2008 Mar 14 3:10 PM
Hi
Use the bapi: bapi_po_create1 for creating the purchase order.
Pass the parameters like below:
header-comp_code = p_comp.
header-doc_type = p_dtype.
header-creat_date = sy-datum.
header-item_intvl = '10'.
header-vendor = p_lifnr.
header-langu = ws_langu .
header-pmnttrms = p_pmnt.
header-purch_org = p_porg.
header-pur_group = p_pgroup.
header-currency = 'INR'.
headerx-comp_code = c_x.
headerx-doc_type = c_x.
headerx-creat_date = c_x.
headerx-item_intvl = c_x .
headerx-vendor = c_x.
headerx-langu = c_x.
headerx-pmnttrms = c_x .
headerx-purch_org = c_x.
headerx-pur_group = c_x.
LOOP AT it_final2 INTO wa_final2.
p_int = p_int + 10.
wa_item-po_item = p_int.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = wa_final2-matnr
IMPORTING
output = wa_final2-matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
wa_item-material = wa_final2-matnr.
wa_item-plant = p_werks.
wa_item-quantity = wa_final2-kwmeng.
wa_item-tax_code = 'V0'.
APPEND wa_item TO it_item.
wa_itemx-po_item = p_int.
wa_itemx-material = c_x.
wa_itemx-plant = c_x .
wa_itemx-stge_loc = c_x .
wa_itemx-quantity = c_x .
wa_itemx-tax_code = c_x .
wa_itemx-item_cat = c_x .
wa_itemx-acctasscat = c_x .
wa_itemx-tax_code = c_x .
APPEND wa_itemx TO it_itemx.
ENDLOOP.
p_pono = ' '.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = header
poheaderx = headerx
IMPORTING
exppurchaseorder = p_pono
TABLES
return = return
poitem = it_item
poitemx = it_itemx.
For better understanding see the function module documentation of the bapi: bapi_po_create1.
If it is helpful rewards points
Regards
Pratap.M
2011 May 15 9:35 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |