PO item characteristic using BAPI_PO_CREATE1
Dear All,
I am uploading open purchase order using BAPI_PO_CREATE1. everything is working fine. but for Semi-finished products i have to upload Individual length. i.e. in characterstics of purchase order item.
kindly help
Hi
Please go through the documentation in SE37 for the FM.. It is very clear on how you need to work on this BAPI. It is given with examples.
Regards,
Vishwa.
Similar Messages
-
Proble in Creating Multiple Item PO using BAPI_PO_CREATE1
Hi All..
I am creating PO using BAPI_PO_CREATE1. I have successfully created with single line item but when i tried to create with multiple line items it gives me error in partners(vendors) which i have used in table POPARTNER.
One more thing, I have created using BAPI with same partner roles with single line item but it gives me error in 2 or more line items.
So, Can Anybody help me in this..
Regards,
Meet Gohel
[email protected]Hi ,
U can use this code n check
*& Report ZPOBAPITRIAL
REPORT ZPOBAPITRIAL.
*DATA DECLARATION
CONSTANTS : C_X VALUE 'X'.
*Structures to hold PO header data
DATA : HEADER LIKE BAPIMEPOHEADER ,
HEADERX LIKE BAPIMEPOHEADERX .
*Internal Tables to hold PO ITEM DATA
DATA : ITEM LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,
ITEMX LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,
*Internal table to hold messages from BAPI call
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
data : w_header(40) value 'PO Header'.
DATA : it_item type standard table of BAPIMEPOITEM.
DATA : wa_item like BAPIMEPOITEM occurs 0 with header line.
DATA : it_itemx type standard table of BAPIMEPOITEMX.
DATA : wa_itemx like BAPIMEPOITEMX occurs 0 with header line.
data : ws_langu like sy-langu.
*text-001 = 'PO Header' - define as text element
selection-screen begin of block b1 with frame title text-001.
parameters : company like header-comp_code default '0103' ,
doctyp like HEADER-DOC_TYPE default 'NB' ,
item_int like header-item_intvl default '10' ,
cdate like HEADER-CREAT_DATE default sy-datum ,
vendor like HEADER-VENDOR default '0000500001',
pmnttrms like header-pmnttrms default '0007' ,
pur_org like HEADER-PURCH_ORG default '9000' ,
pur_grp like HEADER-PUR_GROUP default '401' ,
currency like header-currency default 'INR' .
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-002.
parameters : item_num like ITEM-PO_ITEM default '10',
material like ITEM-MATERIAL default '000000000300000014' ,
plant like ITEM-PLANT default '7640' ,
quantity like ITEM-QUANTITY default 10.
selection-screen end of block b2.
START-OF-SELECTION.
*DATA POPULATION
ws_langu = sy-langu. "Language variable
*POPULATE HEADER DATA FOR PO
HEADER-COMP_CODE = company .
HEADER-DOC_TYPE = doctyp .
*HEADER-CREAT_DATE = cdate .
header-item_intvl = item_int .
HEADER-VENDOR = vendor .
HEADER-LANGU = ws_langu .
header-pmnttrms = pmnttrms .
HEADER-PURCH_ORG = pur_org .
HEADER-PUR_GROUP = pur_grp .
header-currency = currency .
*POPULATE HEADER FLAG.
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.
*HEADERX-doc_date = c_x.
*POPULATE ITEM DATA.
wa_ITEM-PO_ITEM = item_num.
wa_ITEM-MATERIAL = material.
wa_ITEM-PLANT = plant.
wa_ITEM-QUANTITY = quantity.
append wa_item to it_item.
wa_ITEM-PO_ITEM = '20'.
wa_ITEM-MATERIAL = '000000000300000020'.
wa_ITEM-PLANT = plant.
wa_ITEM-QUANTITY = quantity.
append wa_item to it_item.
*APPEND ITEM.
*POPULATE ITEM FLAG TABLE
wa_ITEMX-PO_ITEM = item_num.
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 .
append wa_itemx to it_itemx.
*APPEND ITEMX.
wa_ITEMX-PO_ITEM = '20'.
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 .
append wa_itemx to it_itemx.
*BAPI CALL
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = HEADER
POHEADERX = HEADERX
POADDRVENDOR =
TESTRUN =
IMPORTING
EXPPURCHASEORDER =
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = RETURN
POITEM = it_ITEM
POITEMX = it_ITEMX.
*Confirm the document creation by calling database COMMIT
*CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
end-of-selection.
*Output the messages returned from BAPI call
LOOP AT RETURN.
WRITE: /001 return-type,
/001 return-message.
ENDLOOP.
award points if helpfull -
How to add new line item to PO using BAPI_PO_CREATE1
Hi,
I have a purchase order with 2 line items, now i want to add new line item to the same PO using BAPI_PO_CREATE1.
Here new line item should be created with reference PR line item.But this PR line item is Dynamic it get generated once the Sales order line item get changed.
Please let me know how can i pass the PR doc no, PR line item no as reference to create the new PO line item.
Thanks
BhuvanaHi,
I think you need to use BAPI: BAPI_PO_GETDETAIL, then BAPI:BAPI_PO_CHANGE.
BAPI_PO_CREATE1 equals ME21N, but adding new line item needs to be done in ME22N.
Cheers, -
Error while creating a Service PO using BAPI_PO_CREATE1
Hi,
Im facing Error as "In case of account assignment, please enter acc. assignment data for item" while creating Service PO using BAPI_PO_CREATE1.
Header Data
w_poheader-comp_code = w_src-bukrs. "Company Code
w_poheader-doc_type = w_src-bsart. "Document type
w_poheader-delete_ind = w_src-vrtkz. "Deletion Indicator
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = w_src-aedat
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
w_poheader-creat_date = lv_date. "Creation Date
w_poheader-created_by = sy-uname. "Creator Name
w_poheader-vendor = w_src-lifnr. "Vendor
w_poheader-pmnttrms = w_src-zterm. "Payment Terms
w_poheader-purch_org = w_src-ekorg. "Purchase Organization
w_poheader-pur_group = w_src-ekgrp. "Purchase Group
w_poheader-ref_1 = w_src-ihrez. "OLD PO
w_poheaderx-comp_code = 'X'. "Company Code
w_poheaderx-doc_type = 'X'. "Document type
w_poheaderx-delete_ind = 'X'. "Deletion Indicator
w_poheaderx-creat_date = 'X'. "Creation Date
w_poheaderx-created_by = 'X'.
w_poheaderx-vendor = 'X'.
w_poheaderx-pmnttrms = 'X'. "Payment Terms
w_poheaderx-purch_org = 'X'. "Purchase Organization
w_poheaderx-pur_group = 'X'. "Purchase Group
w_poheaderx-ref_1 = 'X'.
Item Data
w_poitem-po_item = w_src-ebelp.
IF NOT w_src-elikz IS INITIAL.
w_poitem-delete_ind = w_src-elikz.
ENDIF.
IF NOT w_src-txz01 IS INITIAL.
w_poitem-short_text = w_src-txz01.
ENDIF.
IF NOT w_src-werks IS INITIAL.
w_poitem-plant = w_src-werks.
ENDIF.
Material group
IF NOT w_src-matkl IS INITIAL.
w_poitem-matl_group = w_src-matkl.
ENDIF.
Open or Partial Qty
IF w_src-opqty IS NOT INITIAL.
w_poitem-quantity = w_src-opqty.
ELSEIF NOT w_src-paqty IS INITIAL.
w_poitem-quantity = w_src-paqty.
ENDIF.
IF NOT w_src-meins IS INITIAL.
w_poitem-po_unit = w_src-meins. "Base Unit of Measure
ENDIF.
IF NOT w_src-netpr IS INITIAL.
w_poitem-net_price = w_src-netpr. "Net Price
ENDIF.
IF NOT w_src-mwskz IS INITIAL.
w_poitem-tax_code = w_src-mwskz.
ENDIF.
IF NOT w_src-pstyp IS INITIAL.
w_poitem-item_cat = w_src-pstyp.
ENDIF.
IF NOT w_src-knttp IS INITIAL.
w_poitem-acctasscat = w_src-knttp.
ENDIF.
IF NOT w_src-vrtkz IS INITIAL.
w_poitem-distrib = w_src-vrtkz.
ENDIF.
Package No
IF NOT w_src-packno IS INITIAL.
w_poitem-pckg_no = w_src-packno. "Package no
ENDIF.
IF w_poitem-delete_ind IS INITIAL AND
w_poitem-short_text IS INITIAL AND
w_poitem-plant IS INITIAL AND
w_poitem-matl_group IS INITIAL AND
w_poitem-quantity IS INITIAL AND
w_poitem-po_unit IS INITIAL AND
w_poitem-net_price IS INITIAL AND
w_poitem-tax_code IS INITIAL.
CLEAR lv_item.
ELSE.
APPEND w_poitem TO i_poitem.
CLEAR: w_poitem.
lv_item = 'X'.
ENDIF.
w_poitemx-po_item = w_src-ebelp.
w_poitemx-delete_ind = 'X'.
w_poitemx-short_text = 'X'.
w_poitemx-plant = 'X'.
w_poitemx-matl_group = 'X'.
w_poitemx-quantity = 'X'.
w_poitemx-po_unit = 'X'.
w_poitemx-net_price = 'X'.
w_poitemx-tax_code = 'X'.
w_poitemx-item_cat = 'X'.
w_poitemx-acctasscat = 'X'.
w_poitemx-distrib = 'X'.
IF NOT w_src-packno IS INITIAL.
w_poitemx-pckg_no = 'X'.
ENDIF.
IF lv_item = 'X'.
APPEND w_poitemx TO i_poitemx.
CLEAR: w_poitemx,
lv_item.
ENDIF.
PO Deliery Address
w_poaddrdelivery-po_item = w_src-ebelp.
IF NOT w_src-adrn2 IS INITIAL.
w_poaddrdelivery-addr_no = w_src-adrn2.
APPEND w_poaddrdelivery TO i_poaddrdelivery.
CLEAR w_poaddrdelivery.
ENDIF.
POschedule
w_poschedule-po_item = w_src-ebelp.
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = w_src-eindt
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF NOT lv_date IS INITIAL.
w_poschedule-del_datcat_ext = 'D'. "Delivery Date in Day Format
w_poschedule-delivery_date = lv_date.
w_poschedule-quantity = w_src-menge.
APPEND w_poschedule TO i_poschedule.
CLEAR w_poschedule.
lv_schd = 'X'.
ENDIF.
w_poschedulex-po_item = w_src-ebelp.
w_poschedulex-del_datcat_ext = 'X'.
w_poschedulex-delivery_date = 'X'.
w_poschedulex-quantity = 'X'.
IF lv_schd = 'X'.
APPEND w_poschedulex TO i_poschedulex.
CLEAR : w_poschedulex,
lv_schd.
ENDIF.
PO Account Assignment
w_poaccount-po_item = w_src-ebelp.
w_poaccount-serial_no = w_src-zekkn.
Distribution Indicator is 1
IF w_src-vrtkz EQ '1'.
w_poaccount-distr_perc = w_src-vproz.
IF NOT w_src-menge IS INITIAL.
CLEAR lv_menge.
lv_menge = w_src-menge.
ENDIF.
lv_acct_qty = lv_menge * w_src-vproz / 100.
Get Round value of Quanity
frac = FRAC( lv_acct_qty ).
IF frac EQ 0.
lv_acct_qty = FLOOR( lv_acct_qty ).
ELSE.
lv_acct_qty = CEIL( lv_acct_qty ).
ENDIF.
w_poaccount-quantity = lv_acct_qty.
ELSEIF w_src-vrtkz IS INITIAL.
w_poaccount-quantity = w_src-menge.
ENDIF.
w_poaccount-gl_account = w_src-saknr.
w_poaccount-costcenter = w_src-kostl.
w_poaccount-asset_no = w_src-anln1.
w_poaccount-wbs_element = w_src-wbs.
w_poaccount-network = w_src-nplnr.
w_poaccount-tax_code = w_src-mwskz.
w_poaccount-activity = w_src-vornr.
APPEND w_poaccount TO i_poaccount.
CLEAR w_poaccount.
w_poaccountx-po_item = w_src-ebelp.
w_poaccountx-serial_no = w_src-zekkn.
IF w_src-vrtkz EQ '1'.
w_poaccountx-distr_perc = 'X'.
ENDIF.
w_poaccountx-quantity = 'X'.
w_poaccountx-gl_account = 'X'.
w_poaccountx-costcenter = 'X'.
w_poaccountx-wbs_element = 'X'.
w_poaccountx-network = 'X'.
w_poaccountx-tax_code = 'X'.
w_poaccountx-activity = 'X'.
APPEND w_poaccountx TO i_poaccountx.
CLEAR w_poaccountx.
PO Services
w_poservices-pckg_no = w_src-packno. "Package no
w_poservices-line_no = w_src-srv_line_no. "Line item
w_poservices-ext_line = w_src-extrow. "External line
w_poservices-outl_level = 0.
w_poservices-outl_ind = 'X'.
w_poservices-subpckg_no = w_src-sub_packno. "Sub package no
w_poservices-quantity = w_src-srqty. "Service Quantity
w_poservices-base_uom = w_src-srmeins. "Service Basic unit of Measure
w_poservices-price_unit = '1'.
w_poservices-from_line = '1'.
w_poservices-gr_price = w_src-brtwr. "GR Price
w_poservices-short_text = w_src-sh_text1. "Service Short Text
w_poservices-matl_group = w_src-matkl. "Material Group
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Service Access values
w_posrvacc-pckg_no = w_src-packno. "Package no
w_posrvacc-line_no = w_src-srv_line_no. "Line item
w_posrvacc-serno_line = w_src-zekkn. "'01'..
IF w_src-vproz IS INITIAL.
w_posrvacc-percentage = '100.0'.
ENDIF.
w_posrvacc-serial_no = w_src-zekkn. "'01'.
w_posrvacc-quantity = w_src-srqty. "Service Quantity
w_posrvacc-net_value = w_src-srqty. "Net value
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
ENDIF.
***Create a NEW PO
AT END OF ihrez.
Call BAPI
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_poheader
poheaderx = w_poheaderx
IMPORTING
exppurchaseorder = gv_ebeln
TABLES
return = i_return
poitem = i_poitem[]
poitemx = i_poitemx[]
poaddrdelivery = i_poaddrdelivery[]
poschedule = i_poschedule[]
poschedulex = i_poschedulex[]
poaccount = i_poaccount[]
poaccountx = i_poaccountx[]
poservices = i_poservices[]
posrvaccessvalues = i_posrvacc[]
extensionin = i_extensionin[].
Commit the Transaction
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
Regards,
Deepthi.1. If we get error as "In case of account assignment, please enter acc. assignment data for item" than First cehck whetaher u have authorization to Tcode ME23n or not. In my case, I din't had authorization to Me23n tcode.
2. If we get Error as "Please Mainatain Services or Limits". Please create a Service PO in the following Order.
*& Internal Table Declaration
DATA : i_intern TYPE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE,
i_poitem TYPE STANDARD TABLE OF bapimepoitem,
i_poitemx TYPE STANDARD TABLE OF bapimepoitemx,
i_poaddrdelivery TYPE STANDARD TABLE OF bapimepoaddrdelivery,
i_poschedule TYPE STANDARD TABLE OF bapimeposchedule,
i_poschedulex TYPE STANDARD TABLE OF bapimeposchedulx,
i_poaccount TYPE STANDARD TABLE OF bapimepoaccount,
i_poaccountx TYPE STANDARD TABLE OF bapimepoaccountx,
i_poservices TYPE STANDARD TABLE OF bapiesllc,
i_posrvacc TYPE STANDARD TABLE OF bapiesklc,
i_extensionin TYPE STANDARD TABLE OF bapiparex,
i_return TYPE STANDARD TABLE OF bapiret2.
*& Work Area Declaration
DATA:
w_poheader TYPE bapimepoheader,
w_poheaderx TYPE bapimepoheaderx,
w_poitem TYPE bapimepoitem,
w_poitemx TYPE bapimepoitemx,
w_poaddrdelivery TYPE bapimepoaddrdelivery,
w_poschedule TYPE bapimeposchedule,
w_poschedulex TYPE bapimeposchedulx,
w_poaccount TYPE bapimepoaccount,
w_poaccountx TYPE bapimepoaccountx,
w_poservices TYPE bapiesllc,
w_posrvacc TYPE bapiesklc,
w_extensionin TYPE bapiparex,
w_return TYPE bapiret2.
START-OF-SELECTION.
Header Data
w_poheader-comp_code = '5791'. "Company Code
w_poheader-doc_type = 'Z0CM'. "Document type
w_poheader-creat_date = sy-datum. "lv_date. "Creation Date
w_poheader-created_by = sy-uname. "Creator Name
w_poheader-vendor = '0005012343'. "Vendor
w_poheader-pmnttrms = 'Z004'. "Payment Terms
w_poheader-purch_org = 'P000'. "Purchase Organization
w_poheader-pur_group = '001'. "Purchase Group
w_poheader-ref_1 = '004500007671'. "OLD PO
w_poheaderx-comp_code = 'X'. "Company Code
w_poheaderx-doc_type = 'X'. "Document type
w_poheaderx-creat_date = 'X'. "Creation Date
w_poheaderx-created_by = 'X'.
w_poheaderx-vendor = 'X'.
w_poheaderx-pmnttrms = 'X'. "Payment Terms
w_poheaderx-purch_org = 'X'. "Purchase Organization
w_poheaderx-pur_group = 'X'. "Purchase Group
w_poheaderx-ref_1 = 'X'.
Item Data
w_poitem-po_item = '000010'.
w_poitem-short_text = 'Z0CM - Default Appr. Test '.
w_poitem-plant = '5368'.
Trackign no
w_poitem-trackingno = ''.
Material group
w_poitem-matl_group = '119'.
w_poitem-po_unit = 'EA'. "Base Unit of Measure
w_poitem-net_price = '17500.00'. "Net Price
w_poitem-tax_code = 'I0'.
w_poitem-item_cat = '9'.
w_poitem-acctasscat = 'K'.
w_poitem-distrib = space.
Package must be given in item to create Service PO
w_poitem-pckg_no = 0000000001.
APPEND w_poitem TO i_poitem.
CLEAR: w_poitem.
w_poitemx-po_item = '000010'.
w_poitemx-delete_ind = 'X'.
w_poitemx-short_text = 'X'.
w_poitemx-plant = 'X'.
w_poitemx-trackingno = 'X'.
w_poitemx-matl_group = 'X'.
w_poitemx-quantity = 'X'.
w_poitemx-po_unit = 'X'.
w_poitemx-net_price = 'X'.
w_poitemx-tax_code = 'X'.
w_poitemx-item_cat = 'X'.
w_poitemx-acctasscat = 'X'.
w_poitemx-distrib = 'X'.
w_poitemx-pckg_no = 'X'.
APPEND w_poitemx TO i_poitemx.
CLEAR: w_poitemx.
PO Deliery Address
w_poaddrdelivery-po_item = '000010'.
w_poaddrdelivery-addr_no = '0000061208'.
APPEND w_poaddrdelivery TO i_poaddrdelivery.
CLEAR w_poaddrdelivery.
POschedule
w_poschedule-po_item = '000010'..
DATA : LV_DATE TYPE SY-DATUM,
lv_schd.
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = '12/2/2009'
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF NOT lv_date IS INITIAL.
w_poschedule-del_datcat_ext = 'D'. "Delivery Date in Day Format
w_poschedule-delivery_date = lv_date.
w_poschedule-quantity = '1.000'.
APPEND w_poschedule TO i_poschedule.
CLEAR w_poschedule.
lv_schd = 'X'.
ENDIF.
w_poschedulex-po_item = '000010'.
w_poschedulex-del_datcat_ext = 'X'.
w_poschedulex-delivery_date = 'X'.
w_poschedulex-quantity = 'X'.
IF lv_schd = 'X'.
APPEND w_poschedulex TO i_poschedulex.
CLEAR : w_poschedulex,
lv_schd.
ENDIF.
PO Account Assignment
w_poaccount-po_item = '000010'.
w_poaccount-serial_no = '01'.
w_poaccount-distr_perc = ''.
w_poaccount-quantity = '1.000'.
w_poaccount-gl_account = '0000603064'.
w_poaccount-costcenter = '0053680100'.
w_poaccount-asset_no = ''.
w_poaccount-wbs_element = ''.
w_poaccount-network = ''.
w_poaccount-tax_code = 'I0'.
w_poaccount-activity = ''.
APPEND w_poaccount TO i_poaccount.
CLEAR w_poaccount.
w_poaccountx-po_item = '000010'.
w_poaccountx-serial_no = '01'.
w_poaccountx-distr_perc = 'X'.
w_poaccountx-quantity = 'X'.
w_poaccountx-gl_account = 'X'.
w_poaccountx-costcenter = 'X'.
w_poaccountx-wbs_element = 'X'.
w_poaccountx-network = 'X'.
w_poaccountx-tax_code = 'X'.
w_poaccountx-activity = 'X'.
w_poaccountx-cmmt_item = 'X'.
APPEND w_poaccountx TO i_poaccountx.
CLEAR w_poaccountx.
Extension for ZZSub
w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTING'.
w_extensionin-valuepart1+0(5) = '00010'..
w_extensionin-valuepart1+5(2) = '01'.
w_extensionin-valuepart1+28(5) = ''.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTINGX'.
w_extensionin-valuepart1+0(5) = '00010'.
w_extensionin-valuepart1+5(2) = '01'.
w_extensionin-valuepart1+11(1) = 'X'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
Extension to add Expense Type only
w_extensionin-structure = 'BAPI_TE_MEPOHEADER'.
w_extensionin-valuepart1+10(4) = '0131'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
w_extensionin-structure = 'BAPI_TE_MEPOHEADERX'.
w_extensionin-valuepart1+10(4) = 'X'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
EXPORT i_extensionin[] TO MEMORY ID 'SUB'.
PO Services
PO Services( One Line Iem)
Assign the dummy no as Pacakage no
w_poservices-pckg_no = 0000000001. "(assign package no as a dummy number)
w_poservices-line_no = 0000000001. "Line item
w_poservices-outl_ind = 'X'.
Assign Dummy no as sub package no
w_poservices-subpckg_no = 0000000003. "(Dummy No.) "Sub package no
w_poservices-from_line = '1'.
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Services(Second Line Item )
Assign the same sub package dummy no which is mentioned above
w_poservices-pckg_no = 0000000003. "(Dummy No.) "Sub package no
w_poservices-line_no = 0000000002.
w_poservices-ext_line = '0000000010'. "External line
w_poservices-quantity = '17500.0'. "Service Quantity
w_poservices-base_uom = 'EA'. "Service Basic unit of Measure
w_poservices-price_unit = '1'.
w_poservices-gr_price = '1'. "GR Price
w_poservices-short_text = 'Z0CM - Default Appr. T'. "Service Short Text
w_poservices-matl_group = '119'. "w_src-matkl. "Material Group
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Service Access values
w_posrvacc-pckg_no = 0000000003. "w_src-sub_packno. "Sub package no
w_posrvacc-line_no = 0000000002. "w_src-srv_line_no. "Line item
w_posrvacc-serno_line = '01'.
w_posrvacc-percentage = '100.0'.
w_posrvacc-serial_no = '01'.
w_posrvacc-quantity = '17500.0'. "w_src-srqty. "Service Quantity
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
DATA : gv_ebeln TYPE ebeln.
Call BAPI
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_poheader
poheaderx = w_poheaderx
IMPORTING
exppurchaseorder = gv_ebeln
TABLES
return = i_return
poitem = i_poitem[]
poitemx = i_poitemx[]
poaddrdelivery = i_poaddrdelivery[]
poschedule = i_poschedule[]
poschedulex = i_poschedulex[]
poaccount = i_poaccount[]
poaccountx = i_poaccountx[]
poservices = i_poservices[]
posrvaccessvalues = i_posrvacc[]
extensionin = i_extensionin[].
Commit the Transaction
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WRITE:/5 gv_ebeln COLOR 5.
SKIP 2.
DATA : lv_msg TYPE string.
LOOP AT i_return INTO w_return WHERE type = 'E'.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = w_return-id
lang = 'EN'
no = w_return-number
v1 = w_return-message_v1
v2 = w_return-message_v2
v3 = w_return-message_v3
v4 = w_return-message_v4
IMPORTING
msg = lv_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
WRITE:/10 lv_msg.
ENDLOOP. -
Error in : Purchase order Creation using BAPI_PO_CREATE1
Hell guys,
I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
I want the new PO to have all the characteristics of an existing PO. whose PO # is stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in the std FM - MEPO_DOC_ITEM_GET . It raises an exception of failure. I am trying to create many new PO's in the loop below. If there is just one row, sometimes, it creates the PO even with the exception failure ( which is pretty weird).
Am i making any mistake while filling the header or item or schedule lines for the BAPI_PO_CREATE1 ? Any tips or clues why I am getting a dump ?
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
* Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
* Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 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 .
* Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
* Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
* Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
* Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa[].
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
poitem = i_bpoi[]
poitemx = i_bpoix[]
poschedule = i_bpos[]
poschedulex = i_bposx[].
i_order = i_new_ebeln .
SHIFT i_order LEFT DELETING LEADING '0' .
i_return-errortype = c_char_i .
i_return-workarea = c_zsw .
i_return-message = '064' .
i_return-variable1 = i_order .
loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
append i_bapiretn to t_bapi_return .
endloop .
if t_bapi_return[] is initial .
i_create_order = c_char_x .
CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
EXPORTING
act_return = i_return. "Popup with new PO no.
ENDCASE . " Docind
ENDIF .
ENDLOOP.Hi Shareen,
I think in the following parts of the code,
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa[].
Error in : Purchase order Creation using BAPI_PO_CREATE1
Posted: Mar 20, 2006 7:39 PM Reply E-mail this post
Hell guys,
I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
I want the new PO to have all the characteristics of an existing PO. whose PO # is stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in the std FM - MEPO_DOC_ITEM_GET . It raises an exception of failure. I am trying to create many new PO's in the loop below. If there is just one row, sometimes, it creates the PO even with the exception failure ( which is pretty weird).
Am i making any mistake while filling the header or item or schedule lines for the BAPI_PO_CREATE1 ? Any tips or clues why I am getting a dump ?
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 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 .
Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = <b>i_ekpa[].</b>
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
<b> poitem = i_bpoi[]
poitemx = i_bpoix[]
poschedule = i_bpos[]
poschedulex = i_bposx[].</b>
it should be only i_bpoi, i_bpoix, i_bpos, i_bposx but not i_bpoi[], i_bpoix[], i_bpos[], i_bposx[].
CHange the code as follows:
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 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 .
Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa.
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
poitem = i_bpoi
poitemx = i_bpoix
poschedule = i_bpos
poschedulex = i_bposx.
i_order = i_new_ebeln .
SHIFT i_order LEFT DELETING LEADING '0' .
i_return-errortype = c_char_i .
i_return-workarea = c_zsw .
i_return-message = '064' .
i_return-variable1 = i_order .
loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
append i_bapiretn to t_bapi_return .
endloop .
if t_bapi_return[] is initial .
i_create_order = c_char_x .
CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
EXPORTING
act_return = i_return. "Popup with new PO no.
ENDCASE . " Docind
ENDIF .
ENDLOOP. -
Service PO for Multiple Acct Assig is not created using BAPI_PO_CREATE1
Hi,
Im unable to create the Service po with multiple acct assiignment using BAPI_PO_CREATE1
Header Data
w_poheader-comp_code = w_src-bukrs. "Company Code
w_poheader-doc_type = w_src-bsart. "Document type
w_poheader-delete_ind = w_src-vrtkz. "Deletion Indicator
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = w_src-aedat
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
w_poheader-creat_date = lv_date. "Creation Date
w_poheader-created_by = sy-uname. "Creator Name
w_poheader-vendor = w_src-lifnr. "Vendor
w_poheader-pmnttrms = w_src-zterm. "Payment Terms
w_poheader-purch_org = w_src-ekorg. "Purchase Organization
w_poheader-pur_group = w_src-ekgrp. "Purchase Group
w_poheader-ref_1 = w_src-ihrez. "OLD PO
w_poheaderx-comp_code = 'X'. "Company Code
w_poheaderx-doc_type = 'X'. "Document type
w_poheaderx-delete_ind = 'X'. "Deletion Indicator
w_poheaderx-creat_date = 'X'. "Creation Date
w_poheaderx-created_by = 'X'.
w_poheaderx-vendor = 'X'.
w_poheaderx-pmnttrms = 'X'. "Payment Terms
w_poheaderx-purch_org = 'X'. "Purchase Organization
w_poheaderx-pur_group = 'X'. "Purchase Group
w_poheaderx-ref_1 = 'X'.
Item Data
w_poitem-po_item = w_src-ebelp.
IF NOT w_src-elikz IS INITIAL.
w_poitem-delete_ind = w_src-elikz.
ENDIF.
IF NOT w_src-txz01 IS INITIAL.
w_poitem-short_text = w_src-txz01.
ENDIF.
IF NOT w_src-werks IS INITIAL.
w_poitem-plant = w_src-werks.
ENDIF.
Material group
IF NOT w_src-matkl IS INITIAL.
w_poitem-matl_group = w_src-matkl.
ENDIF.
Open or Partial Qty
IF w_src-opqty IS NOT INITIAL.
w_poitem-quantity = w_src-opqty.
ELSEIF NOT w_src-paqty IS INITIAL.
w_poitem-quantity = w_src-paqty.
ENDIF.
IF NOT w_src-meins IS INITIAL.
w_poitem-po_unit = w_src-meins. "Base Unit of Measure
ENDIF.
IF NOT w_src-netpr IS INITIAL.
w_poitem-net_price = w_src-netpr. "Net Price
ENDIF.
IF NOT w_src-mwskz IS INITIAL.
w_poitem-tax_code = w_src-mwskz.
ENDIF.
IF NOT w_src-pstyp IS INITIAL.
w_poitem-item_cat = w_src-pstyp.
ENDIF.
IF NOT w_src-knttp IS INITIAL.
w_poitem-acctasscat = w_src-knttp.
ENDIF.
w_src-vrtkz = '2'. "Added
IF NOT w_src-vrtkz IS INITIAL.
w_poitem-distrib = w_src-vrtkz.
ENDIF.
Package No
IF w_src-srv_line_no EQ '2'.
w_poitem-pckg_no = 0000000001. "Assign dummy package no "w_src-packno. "Package no
ELSEIF w_src-srv_line_no EQ '3'.
w_poitem-pckg_no = 0000000004. "Assign dummy package no "w_src-packno. "Package no
ENDIF.
IF w_poitem-delete_ind IS INITIAL AND
w_poitem-short_text IS INITIAL AND
w_poitem-plant IS INITIAL AND
w_poitem-matl_group IS INITIAL AND
w_poitem-quantity IS INITIAL AND
w_poitem-po_unit IS INITIAL AND
w_poitem-net_price IS INITIAL AND
w_poitem-tax_code IS INITIAL.
CLEAR lv_item.
ELSE.
APPEND w_poitem TO i_poitem.
CLEAR: w_poitem.
lv_item = 'X'.
ENDIF.
w_poitemx-po_item = w_src-ebelp.
w_poitemx-delete_ind = 'X'.
w_poitemx-short_text = 'X'.
w_poitemx-plant = 'X'.
w_poitemx-matl_group = 'X'.
w_poitemx-quantity = 'X'.
w_poitemx-po_unit = 'X'.
w_poitemx-net_price = 'X'.
w_poitemx-tax_code = 'X'.
w_poitemx-item_cat = 'X'.
w_poitemx-acctasscat = 'X'.
w_poitemx-distrib = 'X'.
w_poitemx-pckg_no = 'X'.
IF lv_item = 'X'.
APPEND w_poitemx TO i_poitemx.
CLEAR: w_poitemx,
lv_item.
ENDIF.
PO Deliery Address
w_poaddrdelivery-po_item = w_src-ebelp.
IF NOT w_src-adrn2 IS INITIAL.
w_poaddrdelivery-addr_no = w_src-adrn2.
APPEND w_poaddrdelivery TO i_poaddrdelivery.
CLEAR w_poaddrdelivery.
ENDIF.
POschedule
w_poschedule-po_item = w_src-ebelp.
w_poschedule-SCHED_LINE = w_src-
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = w_src-eindt
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF NOT lv_date IS INITIAL.
w_poschedule-del_datcat_ext = 'D'. "Delivery Date in Day Format
w_poschedule-delivery_date = lv_date.
w_poschedule-quantity = w_src-menge.
APPEND w_poschedule TO i_poschedule.
CLEAR w_poschedule.
lv_schd = 'X'.
ENDIF.
w_poschedulex-po_item = w_src-ebelp.
w_poschedule-SCHED_LINE = 'X'.
w_poschedulex-del_datcat_ext = 'X'.
w_poschedulex-delivery_date = 'X'.
w_poschedulex-quantity = 'X'.
IF lv_schd = 'X'.
APPEND w_poschedulex TO i_poschedulex.
CLEAR : w_poschedulex,
lv_schd.
ENDIF.
PO Account Assignment
w_poaccount-po_item = w_src-ebelp.
w_poaccount-serial_no = w_src-zekkn.
Distribution Indicator is 1
IF w_src-vrtkz EQ '1'.
w_poaccount-distr_perc = w_src-vproz.
IF NOT w_src-menge IS INITIAL.
CLEAR lv_menge.
lv_menge = w_src-menge.
ENDIF.
lv_acct_qty = lv_menge * w_src-vproz / 100.
Get Round value of Quanity
frac = FRAC( lv_acct_qty ).
IF frac EQ 0.
lv_acct_qty = FLOOR( lv_acct_qty ).
ELSE.
lv_acct_qty = CEIL( lv_acct_qty ).
ENDIF.
w_poaccount-quantity = lv_acct_qty.
ELSEIF w_src-vrtkz IS INITIAL.
w_poaccount-quantity = w_src-menge.
ENDIF.
w_poaccount-quantity = w_src-menge. "added
w_poaccount-gl_account = w_src-saknr.
w_poaccount-costcenter = w_src-kostl.
w_poaccount-asset_no = w_src-anln1.
w_poaccount-wbs_element = w_src-wbs.
w_poaccount-network = w_src-nplnr.
w_poaccount-tax_code = w_src-mwskz.
w_poaccount-activity = w_src-vornr.
APPEND w_poaccount TO i_poaccount.
CLEAR w_poaccount.
w_poaccountx-po_item = w_src-ebelp.
w_poaccountx-serial_no = w_src-zekkn.
IF w_src-vrtkz EQ '1'.
w_poaccountx-distr_perc = 'X'.
ENDIF.
w_poaccountx-quantity = 'X'.
w_poaccountx-gl_account = 'X'.
w_poaccountx-costcenter = 'X'.
w_poaccountx-wbs_element = 'X'.
w_poaccountx-network = 'X'.
w_poaccountx-tax_code = 'X'.
w_poaccountx-activity = 'X'.
w_poaccountx-cmmt_item = 'X'.
APPEND w_poaccountx TO i_poaccountx.
CLEAR w_poaccountx.
Extension for ZZSub
IF NOT w_src-zzsub IS INITIAL.
w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTING'.
w_extensionin-valuepart1+0(5) = w_src-ebelp.
w_extensionin-valuepart1+5(2) = '01'.
w_extensionin-valuepart1+28(5) = w_src-zzsub.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTINGX'.
w_extensionin-valuepart1+0(5) = w_src-ebelp.
w_extensionin-valuepart1+5(2) = '01'.
w_extensionin-valuepart1+11(1) = 'X'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
ENDIF.
Extension to add Expense Type only
IF NOT w_src-zzexptype IS INITIAL.
w_extensionin-structure = 'BAPI_TE_MEPOHEADER'.
w_extensionin-valuepart1+10(4) = w_src-zzexptype.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
w_extensionin-structure = 'BAPI_TE_MEPOHEADERX'.
w_extensionin-valuepart1+10(4) = 'X'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
ENDIF.
EXPORT i_extensionin[] TO MEMORY ID 'SUB'.
PO Services( One Line Iem)
IF w_src-srv_line_no EQ '2'.
w_poservices-pckg_no = 0000000001. "w_src-packno. "(assign package no as a dummy number)
w_poservices-line_no = 0000000001. "w_src-srv_line_no. "Line item
w_poservices-outl_ind = 'X'.
w_poservices-subpckg_no = 0000000003. "w_src-sub_packno. "(Dummy No.) "Sub package no
w_poservices-quantity = w_src-srqty. "Service Quantity
w_poservices-base_uom = w_src-srmeins. "Service Basic unit of Measure
w_poservices-price_unit = '1'.
w_poservices-from_line = '1'.
w_poservices-gr_price = w_src-brtwr. "GR Price
w_poservices-short_text = w_src-sh_text1. "Service Short Text
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Services(Second Line Item )
w_poservices-pckg_no = 0000000003. "w_src-sub_packno. "(Dummy No.) "Sub package no
w_poservices-line_no = 0000000002.
w_poservices-ext_line = w_src-extrow. "External line
w_poservices-quantity = w_src-srqty. "Service Quantity
w_poservices-base_uom = w_src-srmeins. "Service Basic unit of Measure
w_poservices-price_unit = '1'.
w_poservices-gr_price = w_src-brtwr. "GR Price
w_poservices-short_text = w_src-sh_text1. "Service Short Text
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Service Access values
w_posrvacc-pckg_no = 0000000003. "w_src-sub_packno. "Sub package no
w_posrvacc-line_no = 0000000002. "w_src-srv_line_no. "Line item
w_posrvacc-serno_line = w_src-zekkn. "'01'.
IF w_src-vproz IS INITIAL.
w_posrvacc-percentage = '100.0'.
ENDIF.
w_posrvacc-serial_no = '01'.
w_posrvacc-quantity = w_src-srqty. "Service Quantity
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
ELSEIF w_src-srv_line_no EQ '3'.
PO Services
if w_src-srv_line_no EQ '2'.
w_poservices-pckg_no = 0000000004. "(assign package no as a dummy number)
w_poservices-line_no = 0000000001. "Line item
w_poservices-outl_ind = 'X'.
w_poservices-subpckg_no = 0000000005. "(Dummy No.) "Sub package no
w_poservices-from_line = '1'.
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
w_poservices-pckg_no = 0000000005. "w_src-sub_packno. "(Dummy No.) "Sub package no
w_poservices-line_no = 0000000002.
w_poservices-ext_line = w_src-extrow. "External line
w_poservices-quantity = w_src-srqty. "Service Quantity
w_poservices-base_uom = w_src-srmeins. "Service Basic unit of Measure
w_poservices-price_unit = '1'.
w_poservices-gr_price = w_src-brtwr. "GR Price
w_poservices-short_text = w_src-sh_text1. "Service Short Text
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
endif.
if w_src-srv_line_no EQ '3'.
w_poservices-pckg_no = 0000000005. "w_src-sub_packno. "(Dummy No.) "Sub package no
w_poservices-line_no = 0000000003.
w_poservices-ext_line = w_src-extrow. "External line
w_poservices-quantity = w_src-srqty. "Service Quantity
w_poservices-base_uom = w_src-srmeins. "Service Basic unit of Measure
w_poservices-price_unit = '1'.
w_poservices-gr_price = w_src-brtwr. "GR Price
w_poservices-short_text = w_src-sh_text1. "Service Short Text
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
endif.
PO Service Access values
if w_src-srv_line_no EQ '2'.
w_posrvacc-pckg_no = 0000000005. "w_src-sub_packno. "Sub package no
w_posrvacc-line_no = 0000000002. "w_src-srv_line_no. "Line item
w_posrvacc-serno_line = '01'.
w_posrvacc-percentage = '100.0'.
w_posrvacc-serial_no = '01'. "w_src-zekkn.
w_posrvacc-quantity = w_src-srqty. "Service Quantity
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
endif.
if w_src-srv_line_no EQ '3'.
w_posrvacc-pckg_no = 0000000005. "w_src-sub_packno. "Sub package no
w_posrvacc-line_no = 0000000003. "w_src-srv_line_no. "Line item
w_posrvacc-serno_line = '01'.
w_posrvacc-percentage = '100.0'.
w_posrvacc-serial_no = '02'. "w_src-zekkn. "'01'.
w_posrvacc-quantity = w_src-srqty. "Service Quantity
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
endif.
ENDIF.
ENDIF.
***Create a NEW PO
Call BAPI
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_poheader
poheaderx = w_poheaderx
TESTRUN = ' '
IMPORTING
exppurchaseorder = gv_ebeln
TABLES
return = i_return
poitem = i_poitem[]
poitemx = i_poitemx[]
poaddrdelivery = i_poaddrdelivery[]
poschedule = i_poschedule[]
poschedulex = i_poschedulex[]
poaccount = i_poaccount[]
poaccountx = i_poaccountx[]
poservices = i_poservices[]
posrvaccessvalues = i_posrvacc[]
extensionin = i_extensionin[].
Commit the Transaction
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
Regards,
Deepthi.it is solved
-
Short dump while using BAPI_PO_CREATE1
Hi all,
I am facing this short dump while executing my program that uses BAPI_PO_CREATE1.
The error is 'Exception condition "failure" raised'.
The trigger location of runtime error is
Program : CL_HANDLE_MANAGER_MM====================CP
Include: CL_HANDLE_MANAGER_MM=====================CM005
Module name: GET
Source code:
Method GET.
If my_manager is initial.
Call method get_manager.
endif.
call method my_manager-> search EXporting im_id = im_id
Importing ex_handle = ex_handle
Exceptions failure = 01.
If sy-subrc <>0.
raise failure.
endif.
I am a beginner in ABAP. Plz help.Hi ,
I faced the similar situation once , in my case when i passed the Delivery indicator value in the Item Table as well as Itemx Table , i was facing this error .
what i suggest you is to pass it at the Item table only , not at the itemx Table.
it worked for me .
try this and reply for the same. -
Creating Service PO using BAPI_PO_CREATE1
Hi gurus,
I am trying to create a PO with service lines using BAPI_PO_CREATE1 but am getting the following errror even though i have passed values to the structures POSERVICES POSRVACCESSVALUES and POACCOUNT along with item and header details:
Please maintain services or limits
Please suggest what are the basic details that need to be passed to the structures for creating a PO with service lines.Hi,
You need to use Package Number to link the services with the item. Check the tables like ESKN to know how the linking works with your existing data.
There are lot of posts related to this. Please do a search to get detailed answers. Thanks for your patience!!
Regards,
Yogesh -
Creation of PO using BAPI_PO_CREATE1 without info record
Hi,
I am making a progrma to create the PO using BAPI_PO_CREATE1 but for the materials for which info record is create din the system it is creating the PO properly but for the materials for which info record is no there even I am giving the Price and tax cod ein th eBAPI item table system is not creating th PO, so is info record mandatory for this.
regards,
zafarHi,
I have use the BAPI as per given note ref. I am taking the PO price from Info record for this I am not giving the item price in the BAPI items, but I want that the header discount should from the user input, but when I ma giving the header discount codnition system is giving error PO header fault, but along with this If i given the items value to in the net price then it is creating the PO, so is it possible to get the items value from the info record and header codnition discount value from user input, we dont want to maintain discount at info record.
regards,
zafar -
PO Upload using BAPI_PO_CREATE1
Hello All,
I m developing PO upload program using BAPI_PO_CREATE1.
It gives me massages like this:
Error transferring ExtensionIn data for enhancement CI_EKPODB.
PO held under the number 4800000109.
But no PO exists. Include CI_EKPODB contains one Quan and four Char fields.
Please tell me how to resolve this issue.
Regards
NadeemHi
check this code
Program : ZGMIMM_ME21.
Transaction Code :
Description : BDC for Purchase order
report zgmimm_me21 no standard page heading line-size 255.
tables: t100.
type-pools: truxs.
types: begin of i_upload,
lifnr like ekko-lifnr, "Vendor Number
bukrs like ekko-bukrs, "Order type
bedat like ekko-bedat, "Purchase Order Date
ekorg like ekko-ekorg, "Purchasing organization
ausnr like ekko-ausnr, "Purchase order
ekgrp like ekko-ekgrp, "Purchasing group
eddat like ekko-bedat, "Delivery date
werks like ekpo-werks, "Plant
lgort like ekpo-lgort, "Storage location
zterm like ekko-zterm, "Payment terms
ematn like ekpo-ematn, "Material
menge like ekpo-menge, "PO Quantity
lewed like ekpo-lewed, "Latest GR Date
end of i_upload.
data: begin of i_input occurs 0,
pbg(10) type c,
bldat(07) type c, "001
BLDAT like BKPF-BUDAT,
hkont(10) type c,
kostl(10) type c,
wrbtr(11) type c,
dbcrflag(01) type c,
sgtxt(32) type c,
end of i_input.
data: v_counter(2) type n.
data: v_mod type i.
data: v_ebelp like ekpo-ebelp.
data: v_fname(132) type c.
data: v_fname1(132) type c.
data: v_tabix like sy-tabix.
data : ws_text(200) type c.
data : wa_mag(1).
data: begin of int_msg occurs 0,
cnt type i,
massage(1) type c,
text(200) type c,
end of int_msg.
data : begin of i_final occurs 0,
lifnr like ekko-lifnr, "Vendor Number
bukrs like ekko-bukrs, "Order type
bedat(10),
ekorg like ekko-ekorg, "Purchasing organization
ausnr like ekko-ausnr, "Purchase order
ekgrp like ekko-ekgrp, "Purchasing group
eddat(10),
werks like ekpo-werks, "Plant
lgort like ekpo-lgort, "Storage location
zterm like ekko-zterm, "Payment terms
ematn like ekpo-ematn, "Material
menge type char15, "PO Quantity
lewed(10),
***+EDS
TAX_CODE type mwskz,
GR_BASEDIV,
end of i_final.
data: it_datatab type standard table of i_upload,
wa_datatab type i_upload.
data: it_raw type truxs_t_text_data.
data: begin of bdcdata occurs 0.
include structure bdcdata.
data: end of bdcdata.
data: begin of messtab occurs 0.
include structure bdcmsgcoll.
data: end of messtab.
data: begin of t_input occurs 0.
include structure i_input.
data: end of t_input.
data: begin of i_local_output occurs 0,
text(2800) type c,
end of i_local_output.
data: begin of i_error occurs 0.
include structure i_input.
data: text(50) type c.
data: end of i_error.
data : _datum1(10).
data : t_datum1(10).
data: msgno like sy-msgno,
msgid like sy-msgid,
msgty like sy-msgty,
message like message.
*Data : TEXT(50) Type c value 'File Shoud be in Excel Format'.
data: wa_head type bapimepoheader,
wa_headx type bapimepoheaderx,
i_return type bapiret2 occurs 0 with header line,
i_item type bapimepoitem occurs 0 with header line,
i_itemx type bapimepoitemx occurs 0 with header line,
i_sch type bapimeposchedule occurs 0 with header line,
i_schx type bapimeposchedulx occurs 0 with header line.
SELECTION SCREEN
parameters: p_file type rlgrap-filename obligatory modif id app.
Write : /3 Text.
START OF SELECTION
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
field_name = 'P_FILE'
importing
file_name = p_file.
start-of-selection.
perform data_from_excel_to_sap.
perform pass_data_to_final_int_tab.
perform fill_bdc_data.
perform fill_bapi_parameters.
perform call_po_create_bapi.
*& Form DATA_FROM_EXCEL_TO
text
--> p1 text
<-- p2 text
form data_from_excel_to_sap.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
tables
i_tab_converted_data = it_datatab[] "ACTUAL DATA
exceptions
conversion_failed = 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.
endform. " DATA_FROM_EXCEL_TO
*& Form PASS_DATA_TO_FINAL_INTERNAL_TA
text
--> p1 text
<-- p2 text
form pass_data_to_final_int_tab.
loop at it_datatab into wa_datatab.
move wa_datatab-lifnr to i_final-lifnr. "Vendor Number
move wa_datatab-bukrs to i_final-bukrs. "Order type
move wa_datatab-bedat to i_final-bedat. "Purchase Order Date
concatenate i_final-bedat6(2) '.' i_final-bedat4(2) '.20'
i_final-bedat+2(2) into _datum1.
i_final-bedat = _datum1.
move wa_datatab-ekorg to i_final-ekorg. "Purchasing organization
move wa_datatab-ausnr to i_final-ausnr. "Purchase order
move wa_datatab-ekgrp to i_final-ekgrp. "Purchasing group
move wa_datatab-eddat to i_final-eddat. "Delivery date
concatenate i_final-eddat6(2) '.' i_final-eddat4(2) '.20'
i_final-eddat+2(2) into _datum1.
i_final-eddat = _datum1.
move wa_datatab-werks to i_final-werks. "Plant
move wa_datatab-lgort to i_final-lgort. "Storage location
move wa_datatab-zterm to i_final-zterm. "Payment terms
move wa_datatab-ematn to i_final-ematn. "Material
move wa_datatab-menge to i_final-menge. "PO Quantity
move wa_datatab-lewed to i_final-lewed. "Latest GR Date
***Value Hard coaded considering this Program is only for Import.
I_FINAL-TAX_CODE = 'V0'.
I_FINAL-GR_BASEDIV = ' '.
concatenate i_final-lewed6(2) '.' i_final-lewed4(2) '.20'
i_final-lewed+2(2) into _datum1.
i_final-lewed = _datum1.
append i_final.
endloop.
endform. " PASS_DATA_TO_FINAL_INTERNAL_TA
*& Form FILL_BDC_DATA
text
--> p1 text
<-- p2 text
form fill_bdc_data.
read table i_final index 1.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0100',
' ' 'BDC_CURSOR' 'RM06E-MATKL',
' ' 'BDC_OKCODE' '=KOPF',
' ' 'EKKO-LIFNR' i_final-lifnr,
' ' 'RM06E-BSART' i_final-bukrs,
' ' 'RM06E-BEDAT' i_final-bedat,
' ' 'RM06E-BSTNR' i_final-ausnr,
' ' 'EKKO-EKORG' i_final-ekorg,
' ' 'EKKO-EKGRP' i_final-ekgrp,
' ' 'RM06E-EEIND' i_final-eddat,
' ' 'RM06E-LPEIN' 'T',
' ' 'RM06E-WERKS' i_final-werks,
' ' 'RM06E-LGORT' i_final-lgort.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0101',
' ' 'BDC_OKCODE' '=AB',
' ' 'EKKO-ZTERM' i_final-zterm.
move: '01' to v_counter.
loop at i_final.
move: sy-tabix to v_tabix.
concatenate 'EKPO-EMATN(' v_counter ')' into v_fname.
concatenate 'EKPO-MENGE(' v_counter ')' into v_fname1.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_OKCODE' '=DETZ',
' ' 'RM06E-EBELP' '5',
' ' v_fname i_final-ematn,
' ' v_fname1 i_final-menge.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0112',
' ' 'BDC_CURSOR' 'EKPO-LEWED',
' ' 'BDC_OKCODE' '/00',
' ' 'EKPO-LEWED' i_final-lewed,
' ' 'EKPO-PRDAT' i_final-bedat.
' ' 'EKPO-IPRKZ' 'D'.
v_mod = v_counter mod 5.
if v_mod eq 0.
clear v_ebelp.
move: v_tabix to v_ebelp.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_OKCODE' '/00',
' ' 'RM06E-EBELP' v_ebelp.
v_counter = '02'.
else.
v_counter = v_counter + 1.
endif.
endloop.
loop at i_final.
clear: v_fname.
v_counter = sy-tabix.
v_ebelp = sy-tabix.
concatenate 'RM06E-TCSELFLAG(' '01' ')' into v_fname.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'RM06E-EBELP' v_ebelp,
' ' 'BDC_OKCODE' '/00'.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-BSTPO(01)',
' ' 'BDC_OKCODE' '=DETZ',
' ' 'RM06E-EBELP' v_ebelp,
' ' v_fname 'X'.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0112',
' ' 'BDC_CURSOR' 'EKPO-LEWED',
' ' 'BDC_OKCODE' '/00',
' ' 'EKPO-PLIFZ' '91',
' ' 'EKPO-GEWEI' 'KG',
' ' 'EKPO-PRDAT' i_final-bedat,
' ' 'EKPO-IPRKZ' 'D',
' ' 'EKPO-LEWED' i_final-lewed.
endloop.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-BSTPO(10)',
' ' 'BDC_OKCODE' '=BU',
' ' 'RM06E-EBELP' '1'.
perform f0510_bdcdata using :
'X' 'SAPLSPO1' '0300',
' ' 'BDC_OKCODE' '=YES'.
call transaction 'ME21' using bdcdata messages into messtab
mode 'A' update 'S'.
perform f000_process_errors.
clear: bdcdata, messtab.
refresh: bdcdata, messtab.
loop at int_msg.
write:/ int_msg-text.
endloop.
endform. " FILL_BDC_DATA
*& Form F0510_BDCDATA
text
-->dynbegin text
-->name text
-->value text
form f0510_bdcdata using value(dynbegin)
value(name)
value(value).
if dynbegin = 'X'.
clear bdcdata.
move: name to bdcdata-program,
value to bdcdata-dynpro,
'X' to bdcdata-dynbegin.
append bdcdata.
else.
clear bdcdata.
move: name to bdcdata-fnam,
value to bdcdata-fval.
append bdcdata.
endif.
endform. " F0510_BDCDATA
*& Form F000_PROCESS_ERRORS
text
--> p1 text
<-- p2 text
form f000_process_errors.
loop at messtab.
clear t100.
select single * from t100 where sprsl = messtab-msgspra
and arbgb = messtab-msgid
and msgnr = messtab-msgnr.
ws_text = t100-text.
wa_mag = messtab-msgtyp.
if ws_text cs '&1'.
replace '&1' with messtab-msgv1 into ws_text.
replace '&2' with messtab-msgv2 into ws_text.
replace '&3' with messtab-msgv3 into ws_text.
replace '&4' with messtab-msgv4 into ws_text.
else.
replace '&' with messtab-msgv1 into ws_text.
replace '&' with messtab-msgv2 into ws_text.
replace '&' with messtab-msgv3 into ws_text.
replace '&' with messtab-msgv4 into ws_text.
endif.
condense ws_text.
move ws_text to int_msg-text.
move wa_mag to int_msg-massage.
append int_msg.
endloop.
delete int_msg where massage = 'W'.
endform. " F000_PROCESS_ERRORS
*& Form fill_bapi_parameters
Subroutine to fill BAPI Parameters
form fill_bapi_parameters.
clear: wa_head, wa_headx, i_return, i_item, i_itemx, i_sch, i_schx.
perform fill_bapi_header.
perform fill_bapi_items.
endform. " fill_bapi_parameters
*& Form fill_bapi_header
Subroutine to fill the bapi header
form fill_bapi_header.
read table i_final index 1.
check sy-subrc eq 0.
move: i_final-ausnr to wa_head-po_number,
i_final-bukrs to wa_head-doc_type,
i_final-zterm to wa_head-pmnttrms,
i_final-ekorg to wa_head-purch_org,
i_final-ekgrp to wa_head-pur_group,
'FOB' to wa_head-incoterms1,
'Free On Board' to wa_head-incoterms2.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = i_final-lifnr
importing
output = i_final-lifnr.
move: i_final-lifnr to wa_head-vendor.
concatenate i_final-bedat+6(4)
i_final-bedat+3(2)
i_final-bedat(2) into wa_head-doc_date.
move: 'X' to wa_headx-po_number,
'X' to wa_headx-doc_type,
'X' to wa_headx-vendor,
'X' to wa_headx-pmnttrms,
'X' to wa_headx-purch_org,
'X' to wa_headx-pur_group,
'X' to wa_headx-doc_date,
'X' to wa_headx-incoterms1,
'X' to wa_headx-incoterms2.
endform. " fill_bapi_header
*& Form fill_bapi_items
Subroutine to fill the bapi items
form fill_bapi_items.
loop at i_final.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = i_final-ematn
importing
output = i_final-ematn.
move: sy-tabix to i_item-po_item,
i_final-ematn to i_item-material,
i_final-werks to i_item-plant,
i_final-lgort to i_item-stge_loc,
i_final-menge to i_item-quantity.
I_ITEM-TAX_CODE = I_FINAL-TAX_CODE.
I_ITEM-GR_BASEDIV = I_FINAL-GR_BASEDIV.
concatenate i_final-lewed+6(4)
i_final-lewed+3(2)
i_final-lewed(2) into i_item-gr_to_date.
move: sy-tabix to i_itemx-po_item,
'X' to i_itemx-po_itemx,
'X' to i_itemx-material,
'X' to i_itemx-plant,
'X' to i_itemx-stge_loc,
'X' to i_itemx-quantity,
'X' to i_itemx-gr_to_date.
**EDS
move: 'X' TO i_itemx-TAX_CODE ,
'X' TO i_itemx-GR_BASEDIV.
append: i_item, i_itemx.
move: sy-tabix to i_sch-po_item,
'0001' to i_sch-sched_line,
'D' to i_sch-del_datcat_ext.
i_final-menge to i_sch-quantity.
concatenate i_final-eddat(2)
i_final-eddat+3(2)
i_final-eddat+6(4) into i_sch-delivery_date.
move: sy-tabix to i_schx-po_item,
'0001' to i_schx-sched_line,
'X' to i_schx-po_itemx,
'X' to i_schx-sched_linex,
'X' to i_schx-quantity,
'X' to i_schx-delivery_date,
'X' to i_schx-del_datcat_ext.
append: i_sch, i_schx.
endloop.
endform. " fill_bapi_items
*& Form call_po_create_bapi
Subroutine to call PO CREATE BAPI
form call_po_create_bapi.
call function 'BAPI_PO_CREATE1'
exporting
poheader = wa_head
poheaderx = wa_headx
tables
return = i_return
poitem = i_item
poitemx = i_itemx
poschedule = i_sch
poschedulex = i_schx.
read table i_return with key type = 'S'
id = '06'
number = '017'.
if sy-subrc eq 0.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
write:/ i_return-message.
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.
loop at i_return.
write:/ i_return-message.
endloop.
endif.
endform. " call_po_create_bapi
thanks
sitaram -
Using BAPI_PO_CREATE1 : Linking service, and account assignment
Hello,
I have trouble when using BAPI_PO_CREATE1. When creating PO using BAPI_PO_CREATE1, I need to input service for each po item and the service itself need to have account assignment. I simplify the code below.
**PO item
t_poitem-po_item = '10'. "for item 10
t_poitem-PCKG_NO = '20'. "link with service
t_poitemx-po_item = 'X'.
t_poitemx-PCKG_NO = 'X'.
**Account Assignment
t_poaccount-po_item = '10'. "link with PO Item
t_poaccount-SERIAL_NO = '01'.
t_poaccount-DISTR_PERC = 1.
t_poaccountx-po_item = '10'.
t_poaccountx-SERIAL_NO = '01'.
t_poaccountx-po_itemx = 'X'.
t_poaccountx-SERIAL_NOx = 'X'.
t_poaccountx-DISTR_PERC = 'X'.
**PO Services
**1st row
t_poservices-PCKG_NO = '20'.
t_poservices-LINE_NO = '0000000001'.
t_poservices-SUBPCKG_NO = '21'.
APPEND t_poservices.
clear t_poservices.
**2nd row
t_poservices-PCKG_NO = '21'.
t_poservices-LINE_NO = '0000000002'.
t_poservices-EXT_LINE = '0000000010'.
**fill account assignment for services
t_POSRVACCESSVALUES-pckg_no = '21'.
t_POSRVACCESSVALUES-LINE_NO = '0000000002'.
T_POSRVACCESSVALUES-SERNO_LINE = '01'.
t_POSRVACCESSVALUES-SERIAL_NO = '01'. "acct. assign. link
t_POSRVACCESSVALUES-PERCENTAGE = '100'.
Every time i execute BAPI_PO_CREATE1 using entry similar like above, i always found error message in t_return like this:
No account assignment exists for service line 0000000010
I feel sure that i have fill every field needed to link services and account assignment which is using serial_no, but somehow it does not link correctly. Can anyone advise me if there is some thing missing or incorrect with my ABAP code above? Thank you in advance for your help. For sure, first helpful answer will receive my rewards point.
Regards,
AbrahamThank you for the code. Actually i have fill the required field as you told but i did not put it in my code here to focus the problem on service and account assignment. After checking out your code, i found that the different between your code and mine is in services table.
<u><b>your code :</b></u>
<b>POSERVICES:structure</b>
PCKG_NO : 0000000001
LINE_NO :0000000001
SUBPCKG_NO : 0000000002
SERVICE :3000000000017
QUANTITY :5
BASE_UOM :AU
GR_PRICE :20000
<b>POSRVACCESSVALUES: structure name</b>
PCKG_NO :0000000002
LINE_NO :0000000002
<u><b>my code are:</b></u>
<b>POSERVICES:structure</b>
PCKG_NO : 0000000001
LINE_NO :0000000001
SUBPCKG_NO : 0000000002
PCKG_NO : 0000000002
LINE_NO :0000000002
SERVICE :3000000000017
QUANTITY :5
BASE_UOM :AU
GR_PRICE :20000
<b>POSRVACCESSVALUES: structure name</b>
PCKG_NO :0000000002
LINE_NO :0000000002
SERIAL_NO :0000000001
The other difference are in account assignment table, you didn't fill SERIAL_NO field.
my code will be like below:
<b>POACCOUNT: structure name</b>
PO_ITEM :10
SERIAL_NO : 0000000001
If using your version, the error message will be:
<i>In case of account assignment, please enter acc. assignment data for item</i>
If using my version, the error message will be:
<i>No account assignment exists for service line 0000000010</i>
Please advise what was wrong with my code. Thank you.
Regards,
Abraham -
Getting errors when iam using BAPI_PO_CREATE1 for Purchase Order creation
Hi sap Gurus,
I am getting Errors when iam using BAPI_PO_CREATE1 for Purchase Order creation that Material (144) does not exist but it is alreardy maintained in MM01.
I dont get how it is coming.and what are the mandatory fields in bapi BAPI_PO_CREATE1 in item level .that is too material only.
pls let me know .
thanks in advance.Hi,
Check the sample code..
report zpo_test .
*DATA DECLARATION
constants : c_x value 'X'.
*Structures to hold PO header data
data : header like bapimepoheader ,
headerx like bapimepoheaderx .
*Structures to hold PO account data
data : account like bapimepoaccount occurs 0 with header line ,
accountx like bapimepoaccountx occurs 0 with header line .
*Internal Tables to hold PO ITEM DATA
data : item like bapimepoitem occurs 0 with header line,
itemx like bapimepoitemx occurs 0 with header line,
*Internal table to hold messages from BAPI call
return like bapiret2 occurs 0 with header line,
*Internal table to hold messages from BAPI call
pocontractlimits like bapiesucc occurs 0 with header line.
data : w_header(40) value 'PO Header',
purchaseorder like bapimepoheader-po_number,
delivery_date like bapimeposchedule-delivery_date.
data : ws_langu like sy-langu.
*text-001 = 'PO Header' - define as text element
selection-screen begin of block b1 with frame title text-001.
parameters : company like header-comp_code default '122' ,
doctyp like header-doc_type default 'NB' ,
cdate like header-creat_date default sy-datum ,
vendor like header-vendor default '2000000012' ,
pur_org like header-purch_org default 'PU01' ,
pur_grp like header-pur_group default '005' .
*sociedad like HEADER-COMP_CODE default '122' ,
*vendedor like HEADER-SALES_PERS default 'sale person'.
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-002.
parameters : item_num like item-po_item default '00010',
material like item-material default '12000000' ,
tipo_imp like item-acctasscat default 'K' ,
*pos_doc like ITEM-ITEM_CAT default 'F' ,
shorttxt like item-short_text default 'PRUEBA BAPI' ,
grup_art like item-matl_group default '817230000' ,
plant like item-plant default '3001' ,
mpe like item-trackingno default '9999' ,
*contrato like ITEM-AGREEMENT default '4904000003' ,
*quantity like ITEM-QUANTITY default 1 .
po_unit like item-po_unit default 'EA'.
selection-screen end of block b2.
Par?mnetros de imputaci?n
selection-screen begin of block b3 with frame title text-004.
parameters : centro like account-costcenter default '1220813150',
cuenta like account-gl_account default '6631400' ,
num_pos like account-po_item default '10' ,
serial like account-serial_no default '01' ,
ind_imp like account-tax_code default 'I2' .
selection-screen end of block b3.
start-of-selection.
*DATA POPULATION
ws_langu = sy-langu. "Language variable
*POPULATE HEADER DATA FOR PO
*HEADER-COMP_CODE = sociedad .
header-doc_type = doctyp .
header-vendor = vendor .
header-creat_date = cdate .
header-created_by = 'TD17191' .
header-purch_org = pur_org .
header-pur_group = pur_grp .
header-comp_code = company .
header-langu = ws_langu .
*HEADER-SALES_PERS = vendedor .
*HEADER-CURRENCY = 'DOP' .
*HEADER-ITEM_INTVL = 10 .
*HEADER-PMNTTRMS = 'N30' .
*HEADER-EXCH_RATE = 1 .
*POPULATE HEADER FLAG.
headerx-comp_code = c_x.
headerx-doc_type = c_x.
headerx-vendor = c_x.
headerx-creat_date = c_x.
headerx-created_by = c_x.
headerx-purch_org = c_x.
headerx-pur_group = c_x.
headerx-langu = c_x.
*HEADERX-sales_pers = c_x.
*HEADERX-CURRENCY = c_x.
*HEADER-ITEM_INTVL = c_x.
*HEADER-PMNTTRMS = c_x.
*HEADER-EXCH_RATE = c_x.
*HEADER-EXCH_RATE = c_x.
*POPULATE ITEM DATA.
item-po_item = item_num.
item-quantity = '1'.
*ITEM-MATERIAL = material .
item-short_text = 'prueba bapi_po_create1'.
*ITEM-TAX_CODE = ''.
item-acctasscat = 'K' .
*ITEM-ITEM_CAT = 'D' .
item-matl_group = '817230000' .
item-plant = '3001' .
item-trackingno = '99999'.
item-preq_name = 'test'.
*ITEM-AGREEMENT = '' .
*ITEM-AGMT_ITEM = ''.
item-quantity = '1' .
item-po_unit = 'EA'.
*ITEM-ORDERPR_UN = 'EA'.
item-conv_num1 = '1'.
item-conv_den1 = '1'.
item-net_price = '1000000' .
item-price_unit = '1'.
item-gr_pr_time = '0'.
item-prnt_price = 'X'.
item-unlimited_dlv = 'X'.
item-gr_ind = 'X' .
item-ir_ind = 'X' .
item-gr_basediv = 'X'.
*ITEM-PCKG_NO = '' .
append item. clear item.
*POPULATE ITEM FLAG TABLE
itemx-po_item = item_num.
itemx-po_itemx = c_x.
*ITEMX-MATERIAL = C_X.
itemx-short_text = c_x.
itemx-quantity = c_x.
*ITEMX-TAX_CODE = C_X.
itemx-acctasscat = c_x.
*ITEMX-ITEM_CAT = c_x.
itemx-matl_group = c_x.
itemx-plant = c_x.
itemx-trackingno = c_x.
itemx-preq_name = c_x.
*ITEMX-AGREEMENT = C_X.
*ITEMX-AGMT_ITEM = c_x.
itemx-stge_loc = c_x.
itemx-quantity = c_x.
itemx-po_unit = c_x.
*ITEMX-ORDERPR_UN = C_X.
itemx-conv_num1 = c_x.
itemx-conv_den1 = c_x.
itemx-net_price = c_x.
itemx-price_unit = c_x.
itemx-gr_pr_time = c_x.
itemx-prnt_price = c_x.
itemx-unlimited_dlv = c_x.
itemx-gr_ind = c_x .
itemx-ir_ind = c_x .
itemx-gr_basediv = c_x .
append itemx. clear itemx.
*POPULATE ACCOUNT DATA.
account-po_item = item_num.
account-serial_no = serial .
account-creat_date = sy-datum .
account-costcenter = centro .
account-gl_account = cuenta .
account-gr_rcpt = 'tester'.
append account. clear account.
*POPULATE ACCOUNT FLAG TABLE.
accountx-po_item = item_num .
accountx-po_itemx = c_x .
accountx-serial_no = serial .
accountx-serial_nox = c_x .
accountx-creat_date = c_x .
accountx-costcenter = c_x .
accountx-gl_account = c_x .
account-gr_rcpt = c_x.
append accountx. clear accountx.
*BAPI CALL
call function 'DIALOG_SET_NO_DIALOG'.
call function 'BAPI_PO_CREATE1'
exporting
poheader = header
poheaderx = headerx
importing
exppurchaseorder = purchaseorder
tables
return = return
poitem = item
poitemx = itemx
poaccount = account
poaccountx = accountx.
*Confirm the document creation by calling database COMMIT
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'
IMPORTING
RETURN =
end-of-selection.
*Output the messages returned from BAPI call
loop at return.
write / return-message.
endloop.
Regards
Sudheer -
Error using BAPI_PO_CREATE1 for creating PO with services
Hi,
I'm getting an error saying 'EnTER account assignment data for item' when I use BAPI_PO_CREATE1 and try to create POs with Service Items. I have filled all the required details, even then the system throws up this error message. Thanks for any help.
Regards,
Vijaywhat have you passed to the table POACCOUNT? and POACCOUNTX?
Regards,
Ravi -
Problem in conditions pricing updation using BAPI_PO_CREATE1
hi,
I am creating PO using BAPI_PO_CREATE1 however when i am passing the data to the bapi for conditions at item level the price value is not changing and throwing error as ( NET PRICE FOR ITEM 00010 adopted from last document ) so for all the items its throwing the same information and when i am chekin the PO the value is not the changing. and while creating the PO manually also the net price is coming automatically and we need to backspace the value and re enter the new value. So wht should i do in order to input the data into the PO.
Thanks in advanceThanks
-
Net Price showing zero while using BAPI_PO_CREATE1 for me21n
Dear All,
I am using BAPI_PO_CREATE1 for ME21N. The problem is, after execution of the program the error msg it shows-
No instance of object type PurchaseOrder has been created. External reference:
Purchase order still contains faulty items
Net price must be greater than 0
The values are coming from excel file.
Please tell me where I am doing wrong.
With regards,
Rosaline.Hi,
Symptom
You create a purchase order with BAPI_PO_CREATE1 or you add an item to an existing purchase order with BAPI_PO_CHANGE. You assign a value in field POITEM-NET_PRICE. However, this value is not transferred. If it was not possible for you to determine any conditions, the system generated the error message 06218 'Net price must be greater than 0'.
Other terms
BAPI_PO_CREATE1, BAPI_PO_CHANGE, price, net price, gross price, conditions, price determination, condition type, 06218, EKPO-NETPR, NETPR, POITEM-NET_PRICE, NET_PRICE, PO_PRICE, BAPI_PO_PRICE, BUS2012, PurchaseOrder.CreateFromData1, CreateFromData1, PurchaeOrder.Change
Reason and Prerequisites
This function has not been available up to now. You could also assign conditions via the condition tables.
Read also Notes 399791, 428621, 529287, 578253 and 539950 for this.
Solution
The present note adds field PO_PRICE to table POITEM. PO_PRICE can have the values ' ', '1' or '2' with the following meaning:
PO_PRICE = ' ': The price determination is carried out as before.
PO_PRICE = '1': The value assigned in field NET_PRICE is transferred as a gross price, that is it is set in the condition type that is defined as a base price in the calculation schema. All other condition types remain unchanged. No conditions are copied from the last document.
PO_PRICE = '2': The value assigned in field NET_PRICE is transferred as a net price, that is it is set in the condition type that is defined as base price in the calculation scheme. All other condition types are deleted.
Note the following
The following restrictions apply to field PO_PRICE:
If you assign conditions via the BAPI interface, these are always transferred. This is carried out independently of the value that you assign in field PO_PRICE.
If you add a new item to a purchase order with BAPI_PO_CHANGE, it does not suffice to fill field POITEM-NET_PRICE on item level. The corresponding currency must be specified explicitly on header level.
You can only use field PO_PRICE during the creation of a purchase order item. If you want to change the price of an already existing item, you can only do this via the conditions.
If you fill field POITEM-PO_PRICE, you must enter an 'X' in POITEMX-PO_PRICE so that the value is transferred.
Correction
The correction is made available via R/3 support package. If you want to implement the note manually, proceed as follows:
1. Make sure that your system contains Notes 494759, 552189 and 578253.
2. Create data type BAPI_PO_PRICE with the following attributes:
Short text:
Price transfer indicator: 1 = gross, 2 = net
Package: ME
Domain: BPUEB
3. Extend structure BAPIMEPOITEM (directly after NO_ROUNDING):
Component: PO_PRICE
Component type: BAPI_PO_PRICE
4. Extend structure BAPIMEPOITEMX (directly after NO_ROUNDING):
Component: PO_PRICE
Component type: BAPIUPDATE
5. Extend structure MEPOITEM_DATA (directly after NO_ROUNDING):
Component: PO_PRICE
Component type: BAPI_PO_PRICE
6. Extend structure MEPOITEM_DATAX (directly after NO_ROUNDING):
Component: PO_PRICE
Component type: BAPIUPDATE
7. Implement the correction instructions in your system.
regards,
Ravi
Edited by: Parupelly on Dec 14, 2011 1:30 PM
Maybe you are looking for
-
In some documents object placement doesn't work anymore. Any ideas?
-
I want to delete everything off the phone but don't want the photo stream to update on the mac and delete the photos saved on it from the iPhone 4. Thanks
-
Hi Guys, When I am clearing a vendor payment using F-04 transaction I am getting the following error. Pls suggest. *Tax code 00 does not appear in any G/L account item* *Message no. FF753* *Diagnosis* *The document entered contains a customer or vend
-
Double finger swipe on magic mouse NEVER works
i've got my 21.5" iMac for about two months. the magic mouse works well except the double finger swipe function has never been worked. i tried installing the wireless mouse software update file as suggested by other users and it doesn't help. i'm sur
-
Adobe Acrobat Reader 6.0 standard
Hi i will like to know if Adobe Acrobat Reader 6.0 standard can be install on window 7 64 bit OS?