cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_ALM_ORDER_MAINTAIN Reservation Item number of newly created component

0 Kudos

How I can get the value of RES_ITEM field of BAPI_ALM_ORDER_MAINTAIN for a newly created component before calling BAPI_TRANSACTION_COMMIT?

Accepted Solutions (1)

Accepted Solutions (1)

peter_atkin
Active Contributor

Look at table (SAPLCOBC)BT_RESB[] via field-symbols, or use BAPI_ALM_ORDER_GET_DETAIL after the commit.

PeteA

,

You could read table (SAPLCOBC)BT_RESB[] using field-symbols.Or use BAPI_ALM_ORDER_GET_DETAIL after commit:

Here is my amended code for future reference:

report zpja0005.
data : it_methods type standard table of bapi_alm_order_method, s_method like bapi_alm_order_method, it_components type standard table of bapi_alm_order_component, s_component like bapi_alm_order_component, it_components_up type standard table of bapi_alm_order_component_up, s_component_up like bapi_alm_order_component_up, it_return type standard table of bapiret2, lv_aufnr like aufk-aufnr.
lv_aufnr = '80000067'.
s_method-refnumber = '000001'. s_method-objecttype = 'COMPONENT'. s_method-method = 'CREATE'. s_method-objectkey = lv_aufnr.
append s_method to it_methods.
clear s_method. s_method-objecttype = 'ORDER'. s_method-method = 'SAVE'. s_method-objectkey(12) = lv_aufnr.
append s_method to it_methods.
s_component-activity = '0010'. s_component-material = '000000000000000101'. s_component-item_cat = 'L'. s_component-requirement_quantity = 1.
append s_component to it_components.
s_component_up-material = 'X'. s_component_up-item_cat = 'X'. s_component_up-requirement_quantity = 'X'. s_component_up-requirement_quantity_unit = 'X'.
append s_component_up to it_components_up.
* Update order with components call function 'BAPI_ALM_ORDER_MAINTAIN' tables it_methods = it_methods it_component = it_components it_component_up = it_components_up return = it_return.
* Check IT_RESULTS from above and commit change if there are no errors call function 'BAPI_TRANSACTION_COMMIT' exporting wait = 'X' importing return = it_return.

Answers (5)

Answers (5)

0 Kudos

Hi Peter,

Thank you for your answer.

Reading table (SAPLCOBC)BT_RESB[] implies that the field must exist in the ABAP stack and therefore the program SAPLCOBC must be in the stack too. So your suggestion only works if I read the field from a point inside BAPI_ALM_ORDER_MANTAIN (exit or BAdI) where program SAPLCOBC exists in the ABAP stack.

It's an unorthodox approach but I think there is no other way to get the values.

😞

0 Kudos

Peter,

The test code looks something like this (I don't have the exact code because the calling is made from an external system)

* This code will create a new component in order XXXXXXXXXXXX activity 0010

s_method-refnumber = '000001'.

s_method-objecttype = 'COMPONENT'.

s_method-method = 'CREATE'.

s_method-objectkey = 'XXXXXXXXXXXX0010'.



APPEND s_method TO it_methods.



CLEAR s_method.

s_method-objecttype = 'ORDER'.

s_method-method = 'SAVE'.

s_method-objectkey = 'XXXXXXXXXXXX'.



APPEND s_method TO it_methods.



s_component-material = 'SOME_MATERIAL'.

s_component-item_cat = 'L'.

s_component-requirement_quatity = 1.

s_component-requirement_quatity = 'ST'.



APPEND s_component TO it_component.



s_component_update-material = 'X'.

s_component_update-item_cat = 'X'.

s_component_update-requirement_quatity = 'X'.

s_component_update-requirement_quatity = 'X'.



APPEND s_component_update TO it_component_up.





CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

  TABLES

    it_methods      = it_methods

    it_component    = it_component

    it_component_up = it_component_up

    return          = it_return.

* Check return



* Here IT_COMPONENT should provide the values for RESERV_NO and RES_ITEM



CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  EXPORTING

    wait   = 'X'

  IMPORTING

    return = it_return.

* Check return
peter_atkin
Active Contributor
0 Kudos

Victor,

Do you have any BAPI test code so I can then take a look in my system.?

PeteA

0 Kudos

Hi Peter,

I need the whole component key i.e. reservation number RESERV_NO and reservation item RES_ITEM. When I add a component to an order I provide empty values for both fields in IT_COMPONENT table, after calling BAPI_ALM_ORDER_MAINTAIN the values are not updated with the assigned RESERV_NO - RES_ITEM.

peter_atkin
Active Contributor
0 Kudos

Victor,

Is the reservation number data not in IT_COMPONENT-RESERV_NO ?

PeteA