Hi SAP Technical Guru,
i have to create Purchase Order through screen(module porgramming) using bapi_po_create1 after pressing standard save button . but it not creating PO.
i have given part of my code below. i am not able to create PO by pressing save button. please suggest me whree i went wrong.
WHEN 'SAVE'.
IF sy-subrc EQ 0.
wa_header-ekorg = ekko-ekorg.
wa_header-purch_org = ekko-ekorg.
wa_header-pur_group = ekko-ekgrp.
wa_header-comp_code = ekko-bukrs.
wa_header-currency = ekko-waers.
wa_header-pmnttrms = ekko-zterm.
wa_header-incoterms1 = ekko-inco1.
wa_header-incoterms2 = ekko-inco2.
wa_header-vendor = ekko-lifnr.
APPEND wa_header TO it_header.
bapimepoheader-bedat = ekko-bedat.
wa_headerx-purch_org = 'X'.
wa_headerx-pur_group = 'X'.
wa_headerx-comp_code = 'X'.
wa_headerx-comp_code = 'X'.
wa_headerx-currency = 'X'.
wa_headerx-pmnttrms = 'X'.
wa_headerx-incoterms1 = 'X'.
wa_headerx-incoterms2 = 'X'.
wa_headerx-vendor = 'X'.
APPEND wa_headerx TO it_headerx.
ENDIF.
IF it_item[] IS NOT INITIAL.
LOOP AT it_item INTO wa_item.
wa_item-po_item = ekpo-ebelp.
wa_item-material = ekpo-matnr.
wa_item-item_cat = ekpo-pstyp.
wa_item-quantity = ekpo-menge.
wa_item-po_unit = ekpo-meins.
wa_item-delivery_date = ekpo-aedat.
wa_item-net_price = ekpo-netpr.
wa_item-plant = ekpo-werks.
wa_item-stge_loc = ekpo-lgort.
wa_item-preq_no = ekpo-banfn.
wa_item-preq_item = ekpo-bnfpo.
APPEND wa_item TO it_item.
CLEAR wa_item.
*scheduled data
wa_sch-delivery_date = ekpo-aedat.
APPEND wa_sch TO it_sch.
CLEAR wa_sch.
wa_itemx-po_item = 'X'.
wa_itemx-material = 'X'.
wa_itemx-item_cat = 'X'.
wa_itemx-quantity = 'X'.
wa_itemx-po_unit = 'X'.
*wa_item-
wa_itemx-net_price = 'X'.
wa_itemx-plant = 'X'.
wa_itemx-stge_loc = 'X'.
wa_itemx-preq_no = 'X'.
wa_itemx-preq_item = 'X'.
APPEND wa_itemx TO it_itemx.
CLEAR wa_itemx.
*scheduledx data
wa_schx-delivery_date = 'X'.
APPEND wa_schx TO it_schx.
CLEAR wa_schx.
APPEND
ENDLOOP.
ENDIF.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = wa_header
poheaderx = wa_headerx
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
POEXPIMPHEADER =
POEXPIMPHEADERX =
VERSIONS =
NO_MESSAGING =
NO_MESSAGE_REQ =
NO_AUTHORITY =
NO_PRICE_FROM_PO =
IMPORTING
EXPPURCHASEORDER =
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
return = it_return
poitem = it_item
poitemx = it_itemx
POADDRDELIVERY =
poschedule = it_sch
poschedulex = it_schx
POACCOUNT =
POACCOUNTPROFITSEGMENT =
POACCOUNTX =
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
POLIMITS =
POCONTRACTLIMITS =
POSERVICES =
POSRVACCESSVALUES =
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POEXPIMPITEM =
POEXPIMPITEMX =
POTEXTHEADER =
POTEXTITEM =
ALLVERSIONS =
POPARTNER =
POCOMPONENTS =
POCOMPONENTSX =
POSHIPPING =
POSHIPPINGX =
POSHIPPINGEXP =
.
*
IF sy-subrc EQ 0.
*
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
RETURN =
.
ELSE.
DELETE i_return WHERE type = 'S'.
DELETE i_return WHERE type = 'I'.
DELETE i_return WHERE type = 'W'.
WRITE:/ 'Following Errors occured in PO Creation:'.
SKIP.
WRITE :/ wa_header.
LOOP AT it_return WHERE type = 'E' OR type = 'S'.
WRITE:/ it_return-message.
ENDLOOP.
MESSAGE i101 WITH 'Data Not Saved Logic Missing'.
SET SCREEN 100.
LEAVE SCREEN .
CALL SCREEN 100.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDIF.
regards,