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: 

Getting BAPI_ALM_ORDER_MAINTAIN work for updating operations!

Former Member
0 Kudos

Dear users,

I am having a tough time in getting the BAPI_ALM_ORDER_MAINTAIN for updating my operations.

The requirement is to update the Material Group, Vendor and a few fields on the First operation of the Order. I have written a piece of code ( extracted bits and pieces from previous threads raised on the same issue).

The issue I have is, it only updates the Operation if a RELEASE is included in the method, and needless to say, it can happen only once. If I remove the RELEASE from methods table, then it gives a success message that the BAPI has worked, but nothing gets reflected on the Order. And as a bonus (?!!) I get an 'Update terminated' message in my SAP BUsiness workplace with an error SAPSQL_ARRAY_INSERT_DUPREC, when I try to open the Order.

Please find the code below in the next post.

Can you please suggest if there is a way to update ONLY the operation?

Thanks,

Vijay

4 REPLIES 4

Former Member
0 Kudos


  l_method_line-refnumber = '000001'.
  l_method_line-objecttype = 'HEADER'.
  l_method_line-method = 'CHANGE'.
  l_method_line-objectkey = p_aufnr.
  APPEND l_method_line TO l_methods.

  l_method_line-method = 'RELEASE'.
  APPEND l_method_line TO l_methods.

  l_method_line-objecttype = 'OPERATION'.
  l_method_line-method = 'CHANGE'.

  CONCATENATE p_aufnr '0010' INTO l_method_line-objectkey.
  APPEND l_method_line TO l_methods.

  l_method_line-method = 'SAVE'.
  l_method_line-objecttype = space.
  APPEND l_method_line TO l_methods.

  MOVE p_aufnr TO l_header_line-orderid.
  MOVE sy-datum TO l_header_line-start_date.
  MOVE '7' TO l_header_line-priority.
  APPEND l_header_line TO l_header.

  MOVE 'X' TO l_header_up_line-start_date.
  MOVE 'X' TO l_header_up_line-priority.
  APPEND l_header_up_line TO l_header_up.

  MOVE '0010' TO l_operation_line-activity.
  l_operation_line-MATL_GROUP = '9051'.
  l_operation_line-usr01 = 'Test 1'.
  APPEND l_operation_line TO l_operation.

  MOVE 'X' TO l_operation_line_up-MATL_GROUP.
  MOVE 'X' TO l_operation_line_up-usr01.

  APPEND l_operation_line_up TO l_operation_up.

* Update order
  CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
    TABLES
      it_methods             = l_methods
     it_header              = l_header
     it_header_up           = l_header_up
*   IT_HEADER_SRV          =
*   IT_HEADER_SRV_UP       =
*     it_userstatus          = l_userstatus
*   IT_PARTNER             =
*   IT_PARTNER_UP          =
   it_operation           = l_operation
   it_operation_up        = l_operation_up
*   IT_RELATION            =
*   IT_RELATION_UP         =
*   IT_COMPONENT           =
*   IT_COMPONENT_UP        =
*   IT_TEXT                =
*   IT_TEXT_LINES          =
*   EXTENSION_IN           =
     return                 =  l_return
*   ET_NUMBERS             =
            .

    LOOP AT l_return INTO l_return_line.
      WRITE:/ l_return_line-type,
              l_return_line-id,
              l_return_line-number,
              l_return_line-message.
    ENDLOOP.

0 Kudos

You don't need to pass HEADER and RELEASE, you can get Operations updated by just passing OPERATION method.

Everything in your code looks okay to me.

The only thing that is missing is BAPI_TRANSACTION_COMMIT.

Perhaps passing RELEASE calls for a COMMIT work which does the update.

Try calling BAPI_TRANSACTION_COMMIT after your BAPI.

It should work, if it doesn't get back to me...

regards,

Aabhas

Edited by: Aabhas K Vishnoi on Sep 24, 2009 6:27 PM

0 Kudos

Hi Aabhas,

Thanks for your prompt reply.

Infact, I didnot include the BAPI_TRANSACTION_COMMIT in the post since I was exceeding the code limit. But I did call it in the actual code.

Also, I tried removing the HEADER and RELEASE from the methods and only included OPERATIONS CHANGE and SAVE, but it still doesn't work. And as an added frustration, I get this Update termination with an SQL error !

Any ideas?!!!!

Thanks,

Vijay.

0 Kudos

Hi Vijay,

I noticed you are not passing 'X' for l_operation_line_up-activity, could this be a reason?

Also, make sure reference number is passed correctly and your operation key is built correctly..

Try using CONVERSION_EXIT_ALPHA_INPUT for P_AUFNR and after concatenation, use CONDENSE l_method_line-objectkey.

There is absolutely no need to pass Header and Release that is for sure (unless you want to change them), so remove them. What messages does BAPI return in debug when you pass only Operation?

Are you calling BAPI in update / background task?

cheers,

Aabhas