Skip to Content
avatar image
Former Member

BAPI_ALM_ORDER_MAINTAIN

Hello Friends, I am wanting to use BAPI BAPI_ALM_ORDER_MAINTAIN to update Personal Number (PERNR) field, End Date and Start Date. Can anyone please help me out what parameters to be used to fetch the required results.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jul 13, 2017 at 07:18 AM

    Please see the SAP-Documentation in the FM as it is well explained and contains some sample on which data is to be expected in the BAPI!

    As you require an update on PERNR and Planned(?) Start / End Date, you must execute these on the specific Operation in the Order.

    You should be able to to something like in the following sample :

    *---> Method to Update OrderOperation
          CLEAR ls_method.
          ADD 1 TO lv_refnumber.
          ls_method-refnumber  = 1.
          ls_method-objecttype = 'OPERATION'.
          ls_method-method     = 'CHANGE'.
          ls_method-objectkey  = <VIAUFK_AFVC-AUFNR> && <VIAUFK_AFVC-VORNR>.
          APPEND ls_method TO lt_methods.
    
    *---> OrderOperation
          CLEAR: ls_operation, ls_operation_up.
          ls_operation-activity   = <VIAUFK_AFVC-VORNR>.
          ls_operation-pers_no    = <YOUR_PERNR>.
          ls_operation_up-pers_no = abap_true.
    
          ls_operation-work_cntr               = <VIAUFK_AFVC-VAPLZ>. "WorkCenter at Operation-Level
          ls_operation-start_cons              = <VIAUFK_AFVC-NTANF>. "Planned Start Date
          ls_operation-strttimcon              = <VIAUFK_AFVC-NTANZ>. "Planned Start Time
          ls_operation-fin_constr              = <VIAUFK_AFVC-NTEND>. "Planned End Date
          ls_operation-fintimcons              = <VIAUFK_AFVC-NTENZ>. "Planned End Time
          ls_operation-constraint_type_start   = 1.                   "Must begin on
          ls_operation-constraint_type_finish  = 1.                   "Must end at
    
    *---> Set indicator to allow Update
          ls_operation_up-work_cntr              = abap_true.
          ls_operation_up-constraint_type_start  = abap_true.
          ls_operation_up-constraint_type_finish = abap_true.
          ls_operation_up-strttimcon             = abap_true.
          ls_operation_up-fintimcons             = abap_true.
          ls_operation_up-start_cons             = abap_true.
          ls_operation_up-fin_constr             = abap_true.
          APPEND ls_operation TO lt_operation.
          APPEND ls_operation_up TO lt_operation_up.
    
    *---> Method Save Order
          CLEAR ls_method.
          ls_method-refnumber  = 1.
          ls_method-objecttype = ''.
          ls_method-method     = 'SAVE'.
          ls_method-objectkey  = <VIAUFK_AFVC-AUFNR>.
          APPEND ls_method TO lt_methods.
    
          CHECK lt_methods IS NOT INITIAL AND
                lt_operation IS NOT INITIAL AND
                lt_operation_up IS NOT INITIAL.
    
    **---> Clear Buffers when updating in LOOP
    *      CALL FUNCTION 'CO_ZF_DATA_RESET_COMPLETE'.
    
    *---> Execute BAPI
          REFRESH lt_return.
          CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
            TABLES
              it_methods      = lt_methods
              it_header       = lt_header
              it_header_up    = lt_header_up
              it_userstatus   = lt_userstatus
              it_operation    = lt_operation
              it_operation_up = lt_operation_up
              return          = lt_return.
    
    *---> Check for Errors and COMMIT / ROLLBACK
          CALL FUNCTION 'ALM_ME_CHECK_RETURN_TABLE'
            TABLES
              return          = lt_return
            EXCEPTIONS
              error_in_return = 1
              OTHERS          = 2.
          IF sy-subrc = 0.
            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
          ELSE.
            CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
          ENDIF.
    

    Hope this helps, if not, please do some experimenting, using a Test Sequence in trx. "SE37" with a set of "BAPI_ALM_ORDER_MAINTAIN" and "BAPI_TRANSACTION_COMMIT" to see what fields are mandatory etc.


    Kind regards

    Nic T.

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 13, 2017 at 06:39 AM
    Add comment
    10|10000 characters needed characters exceeded