Register Login

BAPI For PM Order TECO

Updated May 19, 2018

I am using BAPI_ALM_ORDER_MAINTAIN to do TECO for plant maintenance order. However its ending with error. My code is below:

DATA: it_methods TYPE STANDARD TABLE OF bapi_alm_order_method,
w_methods TYPE bapi_alm_order_method,
et_numbers TYPE STANDARD TABLE OF bapi_alm_numbers.

w_methods-refnumber = 1.
w_methods-objecttype = 'HEADER'.
w_methods-method = 'TECHNICALCOMPLETE '.
w_methods-objectkey = g_aufnr. " '000007092118'.
APPEND w_methods to it_methods.

*IT_METHODS-REFNUMBER = 1.
w_methods-objecttype = ''.
w_methods-method = 'SAVE'.
APPEND w_methods to it_methods.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = it_methods
return = i_return
et_numbers = et_numbers.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.

Thanks.


Comments

  • 23 Dec 2013 12:09 pm Sushma Best Answer

    If you need only complete order technically then you can try
    IWO_AER_DL_ORDER_TECO.

    Thanks.

  • 23 Dec 2013 12:07 pm Sushma

    Try this.....
    w_methods-refnumber = 1.
    w_methods-objecttype = 'HEADER'.
    w_methods--method = 'CHANGE'.
    w_methods-objectkey = g_aufnr..
    APPEND w_methods to it_methods.
    w_methods-refnumber = 1.
    w_methods-objecttype = 'HEADER'.
    w_methods-method = 'TECHNICALCOMPLETE '.
    w_methods-objectkey = g_aufnr. " '000007092118'.
    APPEND w_methods to it_methods.

    w_methods-refnumber = 1.
    w_methods-method = 'SAVE'.
    APPEND w_methods to it_methods.

  • 23 Dec 2013 12:07 pm Sushma

    It would help in our analysis of your problem if you told us what
    error/errors it was returning? 

  • 23 Dec 2013 12:08 pm amit butola

    Hi,

    Thanks for your reply, I found the issue and corrected it.

    w_methods-refnumber = 1.
    w_methods-objecttype = 'HEADER'.
    w_methods-method = 'TECHNICALCOMPLETE '.
    w_methods-objectkey = g_aufnr.
    APPEND w_methods TO it_methods.
    CLEAR w_methods.

    w_methods-refnumber = 1.
    w_methods-objecttype = ''.
    w_methods-method = 'SAVE'.
    APPEND w_methods TO it_methods.
    CLEAR w_methods.

    SELECT SINGLE aufnr
    auart
    werks
    prctr
    func_area FROM aufk INTO w_aufk WHERE
    aufnr EQ g_aufnr.
    IF sy-subrc = 0.
    w_header-orderid = w_aufk-aufnr.
    w_header-order_type = w_aufk-auart.
    w_header-plant = w_aufk-werks.
    w_header-profit_ctr = w_aufk-prctr.
    w_header-func_area = w_aufk-func_area.
    w_header-teco_ref_date = sy-datum.
    w_header-teco_ref_time = sy-uzeit.
    APPEND w_header TO it_header.
    CLEAR w_header.
    ENDIF.

    CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
    TABLES
    it_methods = it_methods
    it_header = it_header
    return = i_return
    et_numbers = et_numbers.

  • 23 Dec 2013 12:09 pm Sushma

    Hi,
    Check this function module, I think it will help you.

    *&--- -&> Collect Object Number

    wa_object-objnr = PM order object no.
    APPEND wa_object TO gt_object.

    *&--- ----&> Collect Object Status

    wa_jstat-stat = 'I0002'. "Release
    gs_jstat-inact = 'X'.
    APPEND gs_jstat TO gt_jstat.
    CLEAR : gs_jstat.
    gs_jstat-stat = 'I0045'. "TECO
    wa_jstat-inact = space.
    APPEND wa_jstat TO gt_jstat.

    CALL FUNCTION 'STATUS_CHANGE_INTERN_MULTI'
    EXPORTING
    client = sy-mandt
    TABLES
    status = it_jstat
    OBJECTS = it_object
    EXCEPTIONS
    object_not_found = 1
    status_inconsistent = 2
    status_not_allowed = 3
    OTHERS = 4

  • 30 Dec 2013 5:24 am amit butola

    Hi,

    When I am trying to TECO a PM order with single confirmation, it works fine. However when I need to confirm more than 1 Work Order, the BAPI is failing and not allowing to TECO the Order.

  • 30 Dec 2013 5:24 am amit butola

    Hi,

    It worked after doing multiple confirmation of work order, however the notification is not getting completed. So I am planning to write the BAPI for Notification Complete and then the TECO confirmation BAPI as you suggested.


×