Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem adding PM02 Operation using BAPI_ALM_ORDER_MAINTAIN

Former Member
0 Kudos


Hello All,

             I am trying to add a PM02 operation  to an existing order  and release the order using the BAPI_ALM_ORDER_MAINTAIN. I have added the below lines of code while calling the BAPI. BAPI runs successfully yet ,neither is the operation added  nor order is released.Could you please help me with this.

   lwa_methods-refnumber  = '000001'.
  lwa_methods-objecttype = 'OPERATION'.
  lwa_methods-method     = 'CREATE'."'CREATE'.
  CONCATENATE l_aufnr l_vornr INTO lwa_methods-objectkey.
  APPEND lwa_methods TO it_methods_rel.
  CLEAR lwa_methods.

  lwa_methods-refnumber  = '000001'.
  lwa_methods-objecttype = 'COMPONENT'.
  lwa_methods-method     = 'CREATE'.
  CONCATENATE l_aufnr '0010' INTO lwa_methods-objectkey.
***  lwa_methods-objectkey  = l_init_ordid .
  APPEND lwa_methods TO it_methods_rel.
  CLEAR lwa_methods.

      lwa_methods-refnumber  = '000001'.
      lwa_methods-objecttype = ' '.
      lwa_methods-method     = 'SAVE'.
      lwa_methods-objectkey  = l_aufnr .
      APPEND lwa_methods TO it_methods_rel.
      CLEAR lwa_methods.

      lwa_methods-refnumber  = '000001'.
      lwa_methods-objecttype = 'HEADER'.
      lwa_methods-method     = 'RELEASE'.
      lwa_methods-objectkey  l_aufnr.
      APPEND lwa_methods TO it_methods_rel.
      CLEAR lwa_methods.
*
*

      lwa_methods-refnumber  = '000001'.
      lwa_methods-objecttype = ' '.
      lwa_methods-method     = 'SAVE'.
      lwa_methods-objectkey  = l_aufnr .
      APPEND lwa_methods TO it_methods_rel.
      CLEAR lwa_methods.

Thanks,

Prakrita Kapoor.

3 REPLIES 3

jogeswararao_kavala
Active Contributor
0 Kudos

Hello Prakrita,

In my view this FM is a difficult one. I remember the following code worked for me for adding an operation. you may develop other requirements if it is useful. (Later I opted for BDCDATA through SHDB recording for operation addition into the Order).


IT_METHODS-REFNUMBER  = '000001'.
IT_METHODS-OBJECTTYPE = 'OPERATION'.
IT_METHODS-METHOD     = 'CREATE'.
IT_METHODS-OBJECTKEY  = P_AUFNR.
APPEND IT_METHODS.

IT_METHODS-OBJECTTYPE = ''.
IT_METHODS-METHOD     = 'SAVE'.
APPEND IT_METHODS.

IT_OPERATION-ACTIVITY = P_VORNR.
IT_OPERATION-CONTROL_KEY = 'BSP1'.
IT_OPERATION-WORK_CNTR = P_ARBPL.
IT_OPERATION-PLANT = P_WERKS.
IT_OPERATION-DESCRIPTION = P_LTXA1.
IT_OPERATION-LANGU = 'E'.
APPEND IT_OPERATION.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
   TABLES
     IT_METHODS              = IT_METHODS
     IT_OPERATION            = IT_OPERATION
     RETURN                  = RETURN
     ET_NUMBERS              = ET_NUMBERS  .

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


Other fm is IBAPI_ORDER_OPERATION_CREATE , looks good but I could never succeed in testing through SE37 itself.


You may have more clues from this discussion

Good luck

KJogeswaraRao

karun_prabhu
Active Contributor
0 Kudos

Hello Prakrita Kapoor.

     Did you write BAPI_TRANSACTION_COMMIT after your BAPI?

Regards.

0 Kudos

Hi Arun ,

              Yes I did use  BAPI_TRANSACTION_COMMIT.