Skip to Content

adding new items to existing purchase order

hi experts,

i would like to know if there is any BAPI or FM that enables to add new line items to an existing purchase order....

i tried to use BAPI_PO_CHANGE but i don't really know to use this bapi..

Please help me on this. it's an urgent development.

thanks,

vitish

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2007 at 05:59 AM

    yes it can work.

    BAPI_PO_CHANGE

    bapipochange-in-46c

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2007 at 06:01 AM

    I just did a test today, seems to be working. We have a custom field EKKO-ZZDELIVERYDATE. To work with BAPI, this field must be included in two structures:

    1) BAPI_TE_MEPOHEADER, there is an include CI_EKKODB. Add the Z field there with the same type as on EKKO. (I actually didn't have to do this - either somebody has already done this or it happened automatically when the fiel was added, not sure).

    2) BAPI_TE_MEPOHEADERX, include CI_EKKODBX. Add the field with the same name but type BAPIUPDATE (!).

    PARAMETERS: p_ebeln TYPE ebeln,

    p_date LIKE sy-datum.

    DATA: s_header TYPE bapimepoheader,

    s_headerx TYPE bapimepoheaderx,

    i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,

    i_extension TYPE bapiparex OCCURS 0 WITH HEADER LINE,

    s_bapi_te_mepoheader TYPE bapi_te_mepoheader,

    s_bapi_te_mepoheaderx TYPE bapi_te_mepoheaderx,

    wa_date TYPE ekko-zzdeliverydate,

    wa_message TYPE c LENGTH 100.

    s_bapi_te_mepoheaderx-po_number = p_ebeln.

    s_bapi_te_mepoheaderx-zzdeliverydate = 'X'.

    s_bapi_te_mepoheader-po_number = p_ebeln.

    s_bapi_te_mepoheader-zzdeliverydate = p_date.

    i_extension-structure = 'BAPI_TE_MEPOHEADER'.

    i_extension-valuepart1 = s_bapi_te_mepoheader.

    APPEND i_extension.

    i_extension-structure = 'BAPI_TE_MEPOHEADERX'.

    i_extension-valuepart1 = s_bapi_te_mepoheaderx.

    APPEND i_extension.

    s_header-po_number = p_ebeln.

    CALL FUNCTION 'BAPI_PO_CHANGE'

    EXPORTING

    purchaseorder = p_ebeln

    TABLES

    return = i_return

    extensionin = i_extension.

    COMMIT WORK.

    LOOP AT i_return.

    MESSAGE ID i_return-id

    TYPE i_return-type

    NUMBER i_return-number WITH

    i_return-message_v1

    i_return-message_v2

    i_return-message_v3

    i_return-message_v4.

    ENDLOOP.

    Reward point if it is useful...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 07:44 AM

    hi

    check the code .it is working in my program.

    • fill data to create new line item

    SORT t_po_item.

    DESCRIBE TABLE t_po_item LINES w_lin.

    READ TABLE xekpo INDEX w_lin.

    IF sy-subrc = 0.

    w_lin = xekpo-ebelp.

    ENDIF.

    READ TABLE t_po_item WITH KEY po_item = xekpo-ebelp INTO r_po_item.

    IF sy-subrc = 0.

    MOVE-CORRESPONDING r_po_item TO r_poitem.

    ENDIF.

    w_lin = w_lin + 10.

    r_poitem-po_item = w_lin.

    r_poitem-vend_mat = r_status-idnlf.

    r_poitem-conf_ctrl = c_z001.

    r_poitem-ackn_reqd = c_x.

    r_poitem-acknowl_no = xekpo-labnr.

    APPEND r_poitem TO t_poitem.

    CLEAR r_poitem.

    r_poitemx-po_item = w_lin.

    r_poitemx-po_itemx = c_x.

    r_poitemx-plant = c_x.

    r_poitemx-material = c_x.

    r_poitemx-quantity = c_x.

    r_poitemx-vend_mat = c_x.

    r_poitemx-conf_ctrl = c_x.

    r_poitemx-ackn_reqd = c_x.

    r_poitemx-acknowl_no = c_x.

    APPEND r_poitemx TO t_poitemx.

    CLEAR r_poitemx.

    r_potextitem-po_number = ekko-ebeln.

    r_potextitem-po_item = w_lin.

    r_potextitem-text_id = c_f01.

    r_potextitem-text_line = r_status-text.

    APPEND r_potextitem TO t_potextitem.

    CLEAR r_potextitem.

    r_po_item-po_item = w_lin.

    APPEND r_po_item TO t_po_item.

    UNPACK ekko-ebeln TO w_purchaseorder.

    CALL FUNCTION 'BAPI_PO_CHANGE'

    EXPORTING

    purchaseorder = w_purchaseorder

    poaddrvendor = t_poaddrvendor

    TABLES

    return = t_return

    poitem = t_poitem

    poitemx = t_poitemx

    poaddrdelivery = t_poaddrdelivery

    potextheader = t_potextheader

    potextitem = t_potextitem

    popartner = t_buspartno

    EXCEPTIONS

    OTHERS = 1.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    wait = '0'.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.