Skip to Content
0
Former Member
Jul 23, 2010 at 09:09 AM

Equipmen dismantle, change plant, install does not work

734 Views

Hello experts,

I have developed a function module which should execute the following steps:

- dismantle an equipment from a functional location

- change the plant of the equipment

- install the equipment into a new functional location

I therefor tried to use these three existing function modules:

- Dismantle -> EQUIPMENT_DISMANTLE

- Change Plant -> BAPI_EQUI_CHANGE

- Install -> EQUIPMENT_INSTALL

Now the problem occurs that the call of the BAPI_EQUI_CHANGE does not execute a commit so the changes are not directly written to the database and the following call of EQUIPMENT_INSTALL is not able to install the equipment into the new functional location.

I tried to execute a BAPI_TRANSACTION_COMMIT after the BAPI_EQUI_CHANGE but still it does not work. In my dev system I can insert a "WAIT UP TO 1 SECONDS." call which work but this does not work in the testing env. Also this is a very bad approach.

The curious thing is that everytime I debug my FM everything is working fine. So I bet there is a problem in the direct following call after the BAPI_EQUI_CHANGE and EQIPMENT_INSTALL.

Here are the relevant calls:

CALL FUNCTION 'EQUIPMENT_DISMANTLE'
    EXPORTING
*     READ_SOBJ             = 'X'
*     READ_ROBJ             = 'X'
*     LOCK_SOBJ             = 'X'
*     I_DATE                = SY-DATUM
*     I_TIME                = SY-UZEIT
      i_inherit_flags       = p_i_inheritance_flags
      old_sequi             = p_i_ls_equi
*     EXEC_MEAS             = ' '
      transmit_new          = 'X'
      direct_new            = 'X'
      commit_new            = 'S'
    CHANGING
      s_equi                = p_i_ls_equi
*     R_EQUI                =
*     R_IFLO                =
    EXCEPTIONS
      err_dismantle         = 1
      OTHERS                = 2
            .

  p_rc = sy-subrc.

  IF sy-subrc NE 0.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait   = 'X'
      IMPORTING
        return = bapiret2.

  ENDIF.

*...

  itob-maintplant   = p_target_swerk.
  itob-planplant    = p_target_iwerk.

  itobx-maintplant  = 'X'.
  itobx-planplant   = 'X'.

  CALL FUNCTION 'BAPI_EQUI_CHANGE'
    EXPORTING
      equipment               = p_ls_equi-equnr
      data_general            = itob
      data_generalx           = itobx
      data_specific           = itob_eq
      data_specificx          = itob_eqx
*     VALID_DATE              = SY-DATUM
*     VALID_TIME              = SY-UZEIT
    IMPORTING
*     DATA_GENERAL_EXP        =
*     DATA_SPECIFIC_EXP       =
      return                  = bapiret2
            .

  IF bapiret2 IS INITIAL.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait   = 'X'
      IMPORTING
        return = bapiret2.

  ENDIF.

*...

  CALL FUNCTION 'EQUIPMENT_INSTALL'
    EXPORTING
      read_sobj             = 'X'
*     READ_ROBJ             = 'X'
*     LOCK_SOBJ             = 'X'
*     POSEQUI               =
*     I_DATE                = SY-DATUM
*     I_TIME                = SY-UZEIT
      i_inherit_flags       = p_i_inheritance_flags
*     OLD_SEQUI             =
*     EXEC_MEAS             = ' '
*     CALL_EXIT             = ' '
*     CHECK_NEW             = 'X'
      transmit_new          = 'X'
      direct_new            = ' '
      commit_new            = 'X'
    CHANGING
      s_equi                = p_ls_equi
      r_equi                = p_ls_equi_target
      r_iflo                = s_iflo
    EXCEPTIONS
      err_install           = 1
      OTHERS                = 2
            .

How can I enable this inside one function module?

Please, any hints are welcome!

Regards,

Andreas