‎2009 Sep 11 2:45 PM
Hi,
I have added a Field Expense type(char 4 and maintained the values in Table Maintainance Generator) in Strctures 'BAPIMEPOHEADER' and 'BAPIMEPOHEADERX' (char 1 only). while executing the BAPI_PO_CREATE1. it is giving the error as 'Please specify Valid Expense type'.
Regards,
Deepthi.
‎2009 Sep 11 3:42 PM
Did you inserted X to the BAPIMEPOHEADERX or you tried to insert the first character the value?
Peter
‎2009 Sep 11 4:55 PM
Hi,
I have inserted 'X' in BAPIMEPOHEADERX.
The below is my Code:
Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code
Regards,
Deepthi.
Edited by: Rob Burbank on Sep 11, 2009 11:57 AM
‎2009 Oct 12 12:36 PM
PO HEADER data
w_header-comp_code = '3082'.
w_header-doc_type = 'Z0RD'.
w_header-created_by = sy-uname.
w_header-vendor = '0005021295'.
w_header-pmnttrms = 'Z004'.
w_header-purch_org = 'P000'.
w_header-pur_group = '052'.
w_header-doc_date = '20080901'.
w_header-zzexptype = '9015'.
w_headerx-comp_code = 'X'.
w_headerx-doc_type = 'X'.
w_headerx-created_by = 'X'.
w_headerx-vendor = 'X'.
w_headerx-pmnttrms = 'X'.
w_headerx-purch_org = 'X'.
w_headerx-pur_group = 'X'.
w_headerx-doc_date = 'X'.
w_headerx-zzexptype = 'X'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_header
poheaderx = w_headerx
IMPORTING
exppurchaseorder = po_numb
TABLES
return = i_return
poitem = i_line
poitemx = i_linex
poaddrdelivery = i_po_deladd
poschedule = i_posch
poschedulex = i_poschx
poaccount = i_po_act
poaccountx = i_po_actx
poservices = i_po_ser.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X' .
‎2009 Oct 12 12:49 PM
REPORT ZPURCHASEORDER.
data:
header like BAPIMEPOHEADER,
headerx like BAPIMEPOHEADERX,
it_item like standard table of BAPIMEPOITEM,
it_itemx like standard table of BAPIMEPOITEMX,
return like standard table of BAPIRET2,
wa_item like BAPIMEPOITEM,
wa_itemx like BAPIMEPOITEMX,
p_int type i,
p_matnr like mara-matnr,
p_pono like ekko-ebeln.
DATA: BEGIN OF BAPIRETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF BAPIRETURN.
constants:
c_x type c value 'X'.
header-comp_code = '3000'.
header-doc_type = 'DP25'.
header-creat_date = sy-datum.
header-item_intvl = '10'.
header-vendor = 'ARAMI-00'.
header-langu = sy-langu.
header-pmnttrms = '0001'.
header-purch_org = '3000'.
header-pur_group = '010'.
header-currency = 'USD'.
headerx-comp_code = c_x.
headerx-doc_type = c_x.
headerx-creat_date = c_x.
headerx-item_intvl = c_x .
headerx-vendor = c_x.
headerx-langu = c_x.
headerx-pmnttrms = c_x .
headerx-purch_org = c_x.
headerx-pur_group = c_x.
*LOOP AT it_final2 INTO wa_final2.
p_int = p_int + 10.
wa_item-po_item = p_int.
p_matnr = 'T-SRM01'.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = p_matnr
IMPORTING
output = p_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
*IF sy-subrc = 0.
*MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*ENDIF.
wa_item-material = p_matnr.
wa_item-plant = '3200'.
wa_item-quantity = 100.
wa_item-conf_ctrl = 'Z01'.
wa_item-ACKN_REQD = 'X'.
WA_ITEM-ERS = ''.
APPEND wa_item TO it_item.
wa_itemx-po_item = p_int.
wa_itemx-material = c_x.
wa_itemx-plant = c_x .
wa_itemx-stge_loc = c_x .
wa_itemx-quantity = c_x .
wa_itemx-item_cat = c_x .
wa_itemx-acctasscat = c_x .
wa_itemx-conf_ctrl = 'X'.
wa_itemx-ACKN_REQD = 'X'.
WA_ITEMX-ERS = 'X'.
APPEND wa_itemx TO it_itemx.
*ENDLOOP.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = header
poheaderx = headerx
IMPORTING
exppurchaseorder = p_pono
TABLES
return = return
poitem = it_item
poitemx = it_itemx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = BAPIRETURN.
write:/ p_pono.
‎2009 Dec 31 7:23 AM
Pass the custome field ZZEXP_TYPE (Expense type) in Extensionin tables paramaetr of BAPI_PO_CREATE1 as below.
data : i_extensionin TYPE STANDARD TABLE OF bapiparex,
w_extensionin TYPE bapiparex.
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.
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_poaddrdel[]
poaccount = i_poaccount[]
poaccountx = i_poaccountx[]
extensionin = i_extensionin[].
Commit the Transaction
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.