‎2006 Sep 20 4:11 AM
i hve written foll code to crate PO using BAPI. but i get a runtime error:
"Type conflict when calling a function module (field length)."
the code is as follows:
REPORT z_h_d_bapi_1 .
DATA : bapiekko like bapiekko,
po_header LIKE bapiekko OCCURS 0 WITH HEADER LINE,
po_items LIKE bapiekpo OCCURS 0 WITH HEADER LINE,
po_item_schedules like bapieket occurs 0 with header line,
return LIKE bapireturn OCCURS 0 WITH HEADER LINE.
*POPULATE HEADER DATA FOR PO
CLEAR po_header.
REFRESH po_header.
po_header-po_number = '4500000000' .
po_header-created_on = '06/05/2006' .
po_header-purch_org = '1000' .
po_header-pur_group = '026' .
po_header-vendor = '420' .
po_header-sales_pers = 'Mr. rahul' .
APPEND po_header.
*POPULATE ITEM DATA.
CLEAR po_items.
REFRESH po_items.
po_items-po_item = '00030'.
po_items-material = 'T-M15D06'.
po_items-plant = '1000'.
po_items-store_loc = '0001'.
po_items-quantity = '1000'.
po_items-unit = '10'.
po_items-net_price = '1000000'.
po_items-price_unit = '67000'.
APPEND po_items.
*POPULATE SCHEDULES DATA
clear po_item_schedules.
refresh po_item_schedules.
po_item_schedules-po_item = '00030'.
po_item_schedules-deliv_date = sy-datum.
po_item_schedules-quantity = '1000'.
append po_item_schedules.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
po_header = bapiekko
PO_HEADER_ADD_DATA = po_header
HEADER_ADD_DATA_RELEVANT = '1'
PO_ADDRESS =
SKIP_ITEMS_WITH_ERROR = 'X'
ITEM_ADD_DATA_RELEVANT = '1'
HEADER_TECH_FIELDS =
IMPORTING
PURCHASEORDER =
tables
po_items = po_items
PO_ITEM_ADD_DATA =
po_item_schedules = po_item_schedules
PO_ITEM_ACCOUNT_ASSIGNMENT =
PO_ITEM_TEXT =
RETURN = return
PO_LIMITS =
PO_CONTRACT_LIMITS =
PO_SERVICES =
PO_SRV_ACCASS_VALUES =
PO_SERVICES_TEXT =
PO_BUSINESS_PARTNER =
EXTENSIONIN =
POADDRDELIVERY =
.
LOOP AT return.
WRITE / return-message.
ENDLOOP.
‎2006 Sep 20 4:14 AM
Hi,
The PO header structure should be BAPIEKKOC..And it shouldn't be internal table ..Structure is enough...
For the PO items the structure should be BAPIEKPOC instead of BAPIEKPO..
THanks,
Naren
‎2006 Sep 20 4:14 AM
Hi,
The PO header structure should be BAPIEKKOC..And it shouldn't be internal table ..Structure is enough...
For the PO items the structure should be BAPIEKPOC instead of BAPIEKPO..
THanks,
Naren
‎2006 Sep 20 4:22 AM
yaah....but the 'return' message i got says:
"Enter Purchasing Org. "
Regards
Nirav
‎2006 Sep 20 4:25 AM
Hi,
TO the PO_HEADER parameter pass the structure PO_HEADER instead of BAPIEKKO..
THanks,
Naren
‎2006 Sep 20 5:06 AM
yes...i have done tht. now the code is somewhat like this
REPORT z_h_d_bapi_1 .
DATA : po_header LIKE bapiekkoc,
po_items LIKE bapiekpoc OCCURS 0 WITH HEADER LINE,
po_item_schedules like bapieket occurs 0 with header line,
return LIKE bapireturn OCCURS 0 WITH HEADER LINE.
purOrder like bapiekkoc-purchase
*POPULATE ITEM DATA.
CLEAR po_items.
REFRESH po_items.
po_items-po_item = '00030'.
po_items-material = 'T-M15D06'.
po_items-plant = '1000'.
po_items-store_loc = '0001'.
*po_items-quantity = '1000'.
po_items-unit = '10'.
po_items-net_price = '1000000'.
po_items-price_unit = '67000'.
APPEND po_items.
*POPULATE SCHEDULES DATA
clear po_item_schedules.
refresh po_item_schedules.
po_item_schedules-po_item = '00030'.
po_item_schedules-deliv_date = sy-datum.
po_item_schedules-quantity = '1000'.
append po_item_schedules.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
po_header = po_header
PO_HEADER_ADD_DATA = po_header
HEADER_ADD_DATA_RELEVANT = '1'
PO_ADDRESS =
SKIP_ITEMS_WITH_ERROR = 'X'
ITEM_ADD_DATA_RELEVANT = '1'
HEADER_TECH_FIELDS =
IMPORTING
PURCHASEORDER =
tables
po_items = po_items
PO_ITEM_ADD_DATA =
po_item_schedules = po_item_schedules
PO_ITEM_ACCOUNT_ASSIGNMENT =
PO_ITEM_TEXT =
RETURN = return
PO_LIMITS =
PO_CONTRACT_LIMITS =
PO_SERVICES =
PO_SRV_ACCASS_VALUES =
PO_SERVICES_TEXT =
PO_BUSINESS_PARTNER =
EXTENSIONIN =
POADDRDELIVERY =
.
LOOP AT return.
WRITE / return-message.
ENDLOOP.
Return message tht i get is " enter purchas org"
btw. thanx for ur replies
‎2006 Sep 20 5:11 AM
Hi,
You still have to populate the PO_HEADER structure..
<b>po_header-created_on = '06/05/2006' .
po_header-purch_org = '1000' .
po_header-pur_group = '026' .
po_header-vendor = '420' .
po_header-sales_pers = 'Mr. rahul' .</b>
I think by mistake you removed the above code..
THanks,
Naren
‎2006 Sep 20 5:34 AM
return message m getting now is
"No Master Record exists for vendor 420"
But an entry with vendor no 420 exists in the ekko table.
‎2006 Sep 20 5:41 AM
<b>po_header-vendor = '0000000420'</b> .
here u have to pass complete number.
<b>check vendor + Purchase Org Combinations +Company COde in EKKO .</b>
Regards
Prabhu
‎2006 Sep 20 5:54 AM
‎2006 Sep 20 6:01 AM
Check in table LFM1 if vendor 420 is defined for purhase org '026' and LOEVM eq SPACE.
Kind Regards
Eswar
‎2006 Sep 20 6:03 AM
hi,
for us we are not passing the vendor . You can try that !
Regards
Nishant
‎2006 Sep 20 6:07 AM
‎2006 Sep 20 6:40 AM
hi nirav,
chk this.
DATA: BEGIN OF po_header OCCURS 0.
INCLUDE STRUCTURE BAPIEKKOC.
DATA: END OF po_header.
DATA: BEGIN OF po_iteam OCCURS 10.
INCLUDE STRUCTURE BAPIEKPOC.
DATA: END OF po-items.
DATA: BEGIN OF PO_ITEM_SCHEDULES OCCURS 0.
INCLUDE STRUCTURE BAPIEKET.
DATA: END OF PO_ITEM_SCHEDULES.
DATA: BEGIN OF I_BAPIRETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRETURN.
DATA: END OF I_BAPIRETURN.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
PO_HEADER = PO_HEADER
SKIP_ITEMS_WITH_ERROR = 'X'
TABLES
PO_ITEMS = PO_ITEMS
PO_ITEM_SCHEDULES = PO_ITEM_SCHEDULES
RETURN = I_BAPIRETURN
EXCEPTIONS
OTHERS = 1.
chnage ur code like this.
chk the structures declared inside the header,item and schedule.
rgds
anver
if hlped mark points
‎2006 Sep 20 8:50 AM
‎2006 Sep 20 10:39 AM
‎2006 Sep 20 10:43 AM
Hiral,
Check the below code for creating PO using the BAPI BAPI_PO_CREARE.
Check u have used conversion input (CONVERSION_EXIT_ALPHA_INPUT) for the vendor. Also check in table <b>lfa1</b> that the given vendor is present or not.
&----
*& Report YPRA_SAMPLE08 *
*& *
&----
*& *
*& *
&----
REPORT ypra_sample08.
Create Service PO
DATA: wa_po_header TYPE bapiekkoc,
wa_po_add_header TYPE bapiekkoa,
ws_po_number TYPE bapiekkoc-po_number,
ws_po_number1 TYPE bapimepoheader-po_number,
ws_pack_no TYPE packno,
i_poitems TYPE bapiekpoc OCCURS 0 WITH HEADER LINE,
i_poitems_sch TYPE bapieket OCCURS 0 WITH HEADER LINE,
i_acct_ass TYPE bapiekkn OCCURS 0 WITH HEADER LINE,
i_return TYPE bapireturn OCCURS 0 WITH HEADER LINE,
i_return1 TYPE bapiret2 OCCURS 0 WITH HEADER LINE,bapiret2,
i_services TYPE bapiesllc OCCURS 0 WITH HEADER LINE,
bapi_esll TYPE bapiesllc OCCURS 0 WITH HEADER LINE,
i_srv_accass TYPE bapiesklc OCCURS 0 WITH HEADER LINE,
i_po_limits TYPE bapiesuhc OCCURS 0 WITH HEADER LINE,
i_po_contract_limits TYPE bapiesucc OCCURS 0 WITH HEADER LINE.
DATA: serial_no LIKE bapiesknc-serial_no,
line_no LIKE bapiesllc-line_no,
pack_no LIKE bapiesllc-line_no.
wa_po_header-doc_date = sy-datum.
wa_po_header-doc_type = 'ZES3'.
wa_po_header-co_code = 'SP01'.
wa_po_header-purch_org = 'SP01'.
wa_po_header-pur_group = 'ES1'.
wa_po_header-vendor = '0001000025'.
wa_po_header-created_by = sy-uname.
wa_po_header-langu = sy-langu.
i_poitems-po_item = 10.
i_poitems-item_cat = '9'.
i_poitems-acctasscat = 'K'.
i_poitems-plant = 'SP01'.
i_poitems-short_text = '007002046'.
i_poitems-disp_quan = '1'.
*i_poitems-mat_grp = 'ZES1'.
*i_poitems-pckg_no = '0000000265'.
*i_poitems-line_no = 1.
i_poitems-pckg_no = 10.
APPEND i_poitems.
i_poitems_sch-po_item = 10.
i_poitems_sch-deliv_date = sy-datum.
APPEND i_poitems_sch.
i_acct_ass-po_item = 10.
i_acct_ass-serial_no = 01.
*i_acct_ass-g_l_acct = '0007910100'.
i_acct_ass-co_area = '1000'.
i_acct_ass-cost_ctr = '0000012000'.
APPEND i_acct_ass.
i_acct_ass-po_item = 10.
i_acct_ass-serial_no = 02.
i_acct_ass-co_area = '1000'.
i_acct_ass-cost_ctr = '0000012000'.
APPEND i_acct_ass.
i_acct_ass-po_item = 10.
i_acct_ass-serial_no = 03.
i_acct_ass-co_area = '1000'.
i_acct_ass-cost_ctr = '0000012000'.
APPEND i_acct_ass.
*i_acct_ass-po_item = 10.
*i_acct_ass-serial_no = 04.
*i_acct_ass-co_area = '1000'.
*i_acct_ass-cost_ctr = '0000012000'.
*APPEND i_acct_ass.
bapi_esll-pckg_no = 10.
bapi_esll-line_no = 1.
bapi_esll-outl_no = '0'.
bapi_esll-outl_ind = 'X'.
bapi_esll-subpckg_no = 20.
bapi_esll-from_line = 1.
bapi_esll-to_line = 3.
APPEND bapi_esll.
bapi_esll-pckg_no = 20.
bapi_esll-line_no = 2.
bapi_esll-service = '000000000003000018'.
bapi_esll-quantity = '317946.000'.
bapi_esll-gr_price = '21111.0000'.
bapi_esll-price_unit = '10000'.
APPEND bapi_esll.
*bapi_esll-pckg_no = 30.
*bapi_esll-line_no = 1.
*bapi_esll-outl_no = '0'.
*bapi_esll-outl_ind = 'X'.
*bapi_esll-subpckg_no = 40.
*APPEND bapi_esll.
bapi_esll-pckg_no = 20.
bapi_esll-line_no = 3.
bapi_esll-service = '000000000003000017'.
bapi_esll-quantity = '317946.000'.
bapi_esll-gr_price = '21111.0000'.
bapi_esll-price_unit = '10000'.
APPEND bapi_esll.
i_srv_accass-pckg_no = 10.
i_srv_accass-line_no = 1.
i_srv_accass-serno_line = 01.
i_srv_accass-serial_no = 01.
i_srv_accass-percentage = 100.
APPEND i_srv_accass.
i_srv_accass-pckg_no = 20.
i_srv_accass-line_no = 2.
i_srv_accass-serno_line = 02.
i_srv_accass-serial_no = 02.
i_srv_accass-percentage = 100.
i_srv_accass-quantity = '1'.
APPEND i_srv_accass.
i_srv_accass-pckg_no = 20.
i_srv_accass-line_no = 3.
i_srv_accass-serno_line = 03.
i_srv_accass-serial_no = 03.
i_srv_accass-percentage = 100.
i_srv_accass-quantity = '1'.
APPEND i_srv_accass.
*i_srv_accass-pckg_no = 40.
*i_srv_accass-line_no = 3.
*i_srv_accass-serno_line = 03.
*i_srv_accass-serial_no = 03.
*i_srv_accass-percentage = 100.
*i_srv_accass-quantity = '1'.
*APPEND i_srv_accass.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
po_header = wa_po_header
po_header_add_data = wa_po_add_header
HEADER_ADD_DATA_RELEVANT =
PO_ADDRESS =
skip_items_with_error = 'X'
ITEM_ADD_DATA_RELEVANT =
HEADER_TECH_FIELDS =
IMPORTING
purchaseorder = ws_po_number
TABLES
po_items = i_poitems
PO_ITEM_ADD_DATA =
po_item_schedules = i_poitems_sch
po_item_account_assignment = i_acct_ass
PO_ITEM_TEXT =
return = i_return
po_limits = i_po_limits
po_contract_limits = i_po_contract_limits
po_services = bapi_esll
po_srv_accass_values = i_srv_accass
PO_SERVICES_TEXT =
PO_BUSINESS_PARTNER =
EXTENSIONIN =
POADDRDELIVERY =
.
IF NOT ws_po_number IS INITIAL.
ws_po_number1 = ws_po_number.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = '2'.
WRITE: / ws_po_number.
ENDIF.
break gbpra8.
LOOP AT i_return.
ENDLOOP.
Regards,
Prakash.
‎2006 Sep 20 6:08 PM