09-29-2008 9:06 AM
I AM CREATING PURCHASE ORDER (ME21N) FROM BAPI ,
BAPI_PO_CREATE AND I AM GETTING FOLLOWING ERROR/
I have put 'U' in account assignment thats why it is showing 1st error and due to 1st error 2nd error is coming ..
when i am creating po manually then it is accepting 'U' but thru bapi it is throwing below error , plz help.
1 E ME069 Unknown account assignment not defined for use here
2 E 06010 Document contains no items
Thanks
09-29-2008 9:12 AM
You may need to assign these fields only:*
Fill bapiekko
ekko_b-doc_date = i_bedat.
ekko_b-doc_type = i_bsart.
ekko_b-co_code = i_bukrs.
ekko_b-pur_group = i_ekgrp.
ekko_b-purch_org = i_ekorg.
ekko_b-agreement = i_konnr.
ekko_b-vendor = i_lifnr.
ekko_b-suppl_plnt = i_reswk.
Account assignment would be pick from material master automatically.
Edited by: Ámit Güjärgoüd on Sep 29, 2008 10:13 AM
09-29-2008 9:08 AM
Hi
Can you pls let me know, how you are passing value to item table
Regards
MD
09-29-2008 9:09 AM
Hi Ankesh,
why don't you try with BAPI_PO_CREATE1.
Check a sample code below.
&----
*& Report YDM_PO_CREATE1 *
*& *
&----
*& *
*& *
&----
REPORT ydm_po_create1.
*-- Input File Declaration
TYPES: BEGIN OF ty_input_file,
column1 TYPE char50,
column2 TYPE char50,
column3 TYPE char50,
column4 TYPE char50,
column5 TYPE char50,
column6 TYPE char50,
column7 TYPE char50,
column8 TYPE char50,
column9 TYPE char50,
column10 TYPE char50,
column11 TYPE char50,
column12 TYPE char50,
column13 TYPE char50,
column14 TYPE char50,
column15 TYPE char50,
column16 TYPE char50,
column17 TYPE char50,
column18 TYPE char50,
END OF ty_input_file.
DATA: i_input_file TYPE STANDARD TABLE OF ty_input_file,
wa_input_file TYPE ty_input_file.
CONSTANTS: c_path TYPE char20 VALUE 'C:\',
c_mask TYPE char9 VALUE ',*.*,*.*.',
c_mode TYPE char1 VALUE 'O',
c_filetype TYPE char10 VALUE 'ASC',
c_x TYPE char01 VALUE 'X'.
PARAMETERS : p_fname LIKE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
*-- Browse Presentation Server
PERFORM f4_presentation_file.
START-OF-SELECTION..
*-- Read presentation server file
PERFORM f1003_upload_file.
IF NOT i_input_file[] IS INITIAL.
PERFORM split_data.
ENDIF.
*&----
*& Form f4_presentation_file
*&----
*& F4 Help for presentation server
*&----
FORM f4_presentation_file .
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_path = c_path
mask = c_mask
mode = c_mode
title = text-001
IMPORTING
filename = p_fname
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " f4_presentation_file
*&----
*& Form f1003_upload_file
*&----
*& Upload File
*&----
FORM f1003_upload_file .
DATA: lcl_filename TYPE string.
lcl_filename = p_fname.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lcl_filename
filetype = c_filetype
has_field_separator = c_x
TABLES
data_tab = i_input_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
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.
ENDFORM. " f1003_upload_file
&----
*& Form split_data
&----
Collect data for creating Purchase Order
----
FORM split_data .
DATA: i_poitem TYPE STANDARD TABLE OF bapimepoitem,
i_poitemx TYPE STANDARD TABLE OF bapimepoitemx,
i_poitem_sch TYPE STANDARD TABLE OF bapimeposchedule,
i_poitem_schx TYPE STANDARD TABLE OF bapimeposchedulx,
i_acct_ass TYPE STANDARD TABLE OF bapimepoaccount,
i_acct_assx TYPE STANDARD TABLE OF bapimepoaccountx,
i_services TYPE STANDARD TABLE OF bapiesllc ,
i_srvacc TYPE STANDARD TABLE OF bapiesklc,
i_return TYPE STANDARD TABLE OF bapiret2,
wa_header TYPE bapimepoheader,
wa_headerx TYPE bapimepoheaderx,
wa_poitem TYPE bapimepoitem,
wa_poitemx TYPE bapimepoitemx,
wa_poitem_sch TYPE bapimeposchedule,
wa_poitem_schx TYPE bapimeposchedulx,
wa_acct_ass TYPE bapimepoaccount,
wa_acct_assx TYPE bapimepoaccountx,
wa_services TYPE bapiesllc,
wa_srvacc TYPE bapiesklc,
wa_return TYPE bapiret2,
ws_po TYPE bapimepoheader-po_number.
wa_services-pckg_no = 10.
wa_services-line_no = 1.
wa_services-outl_no = '0'.
wa_services-outl_ind = c_x.
wa_services-subpckg_no = 20.
APPEND wa_services TO i_services.
wa_srvacc-pckg_no = 10.
wa_srvacc-line_no = 1.
wa_srvacc-serno_line = 01.
wa_srvacc-serial_no = 01.
wa_srvacc-percentage = 100.
APPEND wa_srvacc TO i_srvacc.
LOOP AT i_input_file INTO wa_input_file.
IF wa_input_file-column2 EQ 'HD'.
wa_header-doc_type = wa_input_file-column3.
wa_header-creat_date = sy-datum.
wa_header-created_by = sy-uname.
wa_header-vendor = wa_input_file-column4.
PERFORM conversion_output USING wa_header-vendor
CHANGING wa_header-vendor.
wa_header-comp_code = 'DE03'.
wa_header-purch_org = 'DE03'.
wa_header-pur_group = 'DE1'.
wa_header-vper_start = wa_input_file-column9.
wa_header-vper_end = wa_input_file-column10.
wa_headerx-comp_code = c_x.
wa_headerx-doc_type = c_x.
wa_headerx-creat_date = c_x.
wa_headerx-created_by = c_x.
wa_headerx-vendor = c_x.
wa_headerx-purch_org = c_x.
wa_headerx-pur_group = c_x.
wa_headerx-vper_start = c_x.
wa_headerx-vper_end = c_x.
ENDIF.
IF wa_input_file-column2 EQ 'IT'.
wa_poitem-po_item = wa_input_file-column3.
wa_poitem-short_text = wa_input_file-column6.
wa_poitem-plant = wa_input_file-column8.
wa_poitem-quantity = '1'.
wa_poitem-tax_code = 'V0'.
wa_poitem-item_cat = 'D'.
wa_poitem-acctasscat = 'K'.
wa_poitem-matl_group = wa_input_file-column7.
wa_poitem-pckg_no = '10'.
APPEND wa_poitem TO i_poitem .
wa_poitemx-po_item = wa_input_file-column3.
wa_poitemx-po_itemx = c_x.
wa_poitemx-short_text = c_x.
wa_poitemx-plant = c_x.
wa_poitemx-quantity = c_x.
wa_poitemx-tax_code = c_x.
wa_poitemx-item_cat = c_x.
wa_poitemx-acctasscat = c_x.
wa_poitemx-matl_group = c_x.
wa_poitemx-pckg_no = c_x.
APPEND wa_poitemx TO i_poitemx.
wa_poitem_sch-po_item = wa_input_file-column3.
wa_poitem_sch-delivery_date = sy-datum.
APPEND wa_poitem_sch TO i_poitem_sch.
wa_poitem_schx-po_item = wa_input_file-column3.
wa_poitem_schx-po_itemx = c_x.
wa_poitem_schx-delivery_date = c_x.
APPEND wa_poitem_schx TO i_poitem_schx.
wa_acct_ass-po_item = 10.
wa_acct_ass-serial_no = 01.
wa_acct_ass-gl_account = '0006360100'.
wa_acct_ass-co_area = '1000'.
wa_acct_ass-costcenter = 'KC010000'.
APPEND wa_acct_ass TO i_acct_ass.
wa_acct_ass-po_item = 10.
wa_acct_ass-serial_no = 02.
wa_acct_ass-gl_account = '0006360100'.
wa_acct_ass-co_area = '1000'.
wa_acct_ass-costcenter = 'KC010000'.
APPEND wa_acct_ass TO i_acct_ass.
wa_acct_assx-po_item = 10.
wa_acct_assx-serial_no = 01.
wa_acct_assx-po_itemx = c_x.
wa_acct_assx-serial_nox = c_x.
wa_acct_assx-gl_account = c_x.
wa_acct_assx-co_area = c_x.
wa_acct_assx-costcenter = c_x.
APPEND wa_acct_assx TO i_acct_assx.
wa_acct_assx-po_item = 10.
wa_acct_assx-serial_no = 02.
wa_acct_assx-po_itemx = c_x.
wa_acct_assx-serial_nox = c_x.
wa_acct_assx-gl_account = c_x.
wa_acct_assx-co_area = c_x.
wa_acct_assx-costcenter = c_x.
APPEND wa_acct_assx TO i_acct_assx.
wa_services-pckg_no = 20.
wa_services-line_no = 2.
wa_services-service = wa_input_file-column9.
wa_services-quantity = '100'.
wa_services-gr_price = '100'.
wa_services-userf1_txt = wa_input_file-column13.
APPEND wa_services TO i_services.
wa_srvacc-pckg_no = 20.
wa_srvacc-line_no = 1.
wa_srvacc-serno_line = 02.
wa_srvacc-serial_no = 02.
wa_srvacc-percentage = 100.
APPEND wa_srvacc TO i_srvacc.
ENDIF.
ENDLOOP.
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 = ws_po
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
return = i_return
poitem = i_poitem
poitemx = i_poitemx
POADDRDELIVERY =
poschedule = i_poitem_sch
poschedulex = i_poitem_schx
poaccount = i_acct_ass
POACCOUNTPROFITSEGMENT =
poaccountx = i_acct_assx
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
POLIMITS =
POCONTRACTLIMITS =
poservices = i_services
posrvaccessvalues = i_srvacc
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POEXPIMPITEM =
POEXPIMPITEMX =
POTEXTHEADER =
POTEXTITEM =
ALLVERSIONS =
POPARTNER =
.
break gbpra8.
LOOP AT i_return INTO wa_return.
ENDLOOP.
ENDFORM. " split_data
&----
*& Form conversion_output
&----
Conversion exit input
----
FORM conversion_output USING p_ip
CHANGING p_op.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = p_ip
IMPORTING
output = p_op.
ENDFORM. " conversion_output
Hope this helps.
Manish
09-29-2008 9:11 AM
I m passing data like this
********************
****HEADER DATA.
po_header-DOC_DATE = sy-datum.
po_header-DOC_TYPE = 'TRPO'.
*po_header-DOC_CAT =
po_header-CO_CODE = '1000'.
po_header-PURCH_ORG = '1000'.
po_header-PUR_GROUP = '402'.
po_header-VENDOR = 'JR00006'.
****HEADER ADDITIONAL DATA.
PO_HEADER_ADD_DATA-CURRENCY = 'INR'.
PO_HEADER_ADD_DATA-VPER_START = '20081001'.
PO_HEADER_ADD_DATA-VPER_END = '20081030'.
****ITEM LEVEL DETAILS
PO_ITEM-PO_ITEM = '00010'.
PO_ITEM-ACCTASSCAT = 'U'.
*PO_ITEM-ITEM_CAT = 'S'.
PO_ITEM-SHORT_TEXT = 'CEMENT'. " SHORT TEXT
PO_ITEM-MAT_GRP = '101001'. " MAT GRP
PO_ITEM-PLANT = '1100'. " PLANT
PO_ITEM-STORE_LOC = 'FG01'. " STORAGE LOCATION
PO_ITEM-TRACKINGNO = '41'. " DEPARTMENT CODE
PO_ITEM-UNIT = 'MT'.
PO_ITEM-DISP_QUAN = '50.000'.
APPEND PO_ITEM.
******LIMIT DATA
PO_LIMITS-LIMIT = '99999999'.
PO_LIMITS-EXP_VALUE = '99999999'.
APPEND PO_LIMITS.
*****TAX DATA
PO_SERVICES-TAX_CODE = 'V0'.
APPEND PO_SERVICES.
****DELIVERY SCDDULE DATA.
PO_ITEM_SCHEDULES-DEL_DATCAT = 'M'.
PO_ITEM_SCHEDULES-DELIV_DATE = '102008'.
APPEND PO_ITEM_SCHEDULES.
09-29-2008 9:12 AM
You may need to assign these fields only:*
Fill bapiekko
ekko_b-doc_date = i_bedat.
ekko_b-doc_type = i_bsart.
ekko_b-co_code = i_bukrs.
ekko_b-pur_group = i_ekgrp.
ekko_b-purch_org = i_ekorg.
ekko_b-agreement = i_konnr.
ekko_b-vendor = i_lifnr.
ekko_b-suppl_plnt = i_reswk.
Account assignment would be pick from material master automatically.
Edited by: Ámit Güjärgoüd on Sep 29, 2008 10:13 AM
09-29-2008 12:16 PM
you have not given account assignment and po item
see to it that you input these fieds.
or if you are using a report to drive this bapi then see to it that you have mapped it properly.....
09-29-2008 12:19 PM