‎2008 Nov 20 11:15 AM
Hi,
I am trying to update multiple components for a work order using BAPI_ALM_ORDER_MAINTAIN.
BAPI returns success message but later I am getting the update termination error.
when checked from SM13 transaction, the error is due to "SAPSQL_ARRAY_INSERT_DUPREC". This is happening because whenever a component is added the reservation item table RESB will also be updated. To the RESB table duplicate entries are going with the same reservation number and item number.
I am passing the reservation data (Reservation number and item) in IT_COMPONENT but could not find the field in the update table (IT_COMPONENT_UP). Just guessing that this would be the cause of the problem.
Please help in solving this problem.
I am pasting my code below for reference. Please let me know if am doing anything wrong.
Thanks In Advance,
Vinutha
****************************************************************************************************************
PARAMETER: ODR_NO LIKE BAPI_ALM_ORDER_HEADERS_I-ORDERID. " Order Number
DATA:
V_RSPOS TYPE RESB-RSPOS VALUE '0001',
v_item_num type RESB-RSPOS value '0010',
v_item_char(4) type c,
lv_line type i,
*Get details for Order
CALL FUNCTION 'BAPI_ALM_ORDER_GET_DETAIL'
EXPORTING
NUMBER = ODR_NO
IMPORTING
ES_HEADER = ES_HEADER
ES_SRVDATA = ES_SRVDATA
TABLES
ET_PARTNER = ET_PARTNER
ET_OPERATIONS = ET_OPERATIONS
ET_COMPONENTS = ET_COMP
ET_RELATIONS = ET_RELATIONS
ET_TEXTS = ET_TEXTS
ET_TEXT_LINES = ET_TEXT_LINES
ET_PRTS = ET_PRTS
ET_COSTS_SUM = ET_COSTS_SUM
ET_COSTS_DETAILS = ET_COST_DET
RETURN = RETURN1.
READ table ET_OPERATIONS index 1.
If sy-subrc = 0.
concatenate ODR_NO ET_OPERATIONS-ACTIVITY ET_OPERATIONS-SUB_ACTIVITY into IT_METHODS-OBJECTKEY.
endif.
LOOP AT GT_EXT_OPERATIONS INTO GW_OPERATIONS.
v_item_char = v_item_num.
IT_COMPONENTS-RESERV_NO = ES_HEADER-RESERV_NO.
IT_COMPONENTS-RES_ITEM = V_RSPOS.
IT_COMPONENTS-MATERIAL = V_MATNR.
IT_COMPONENTS-PLANT = GW_OPERATIONS-PLANT.
IT_COMPONENTS-ITEM_CAT = 'N'.
IT_COMPONENTS-ITEM_NUMBER = v_item_char.
IT_COMPONENTS-ITEM_TEXT1 = 'TEST'.
IT_COMPONENTS-ACTIVITY = GW_OPERATIONS-ACTIVITY.
IT_COMPONENTS-PUR_GROUP = GW_OPERATIONS-PUR_GROUP.
IT_COMPONENTS-MATL_GROUP = GW_OPERATIONS-MATL_GROUP.
IT_COMPONENTS-VENDOR_NO = GW_OPERATIONS-VENDOR_NO.
IT_COMPONENTS-TRACKINGNO = 'Maint_bill'.
IT_COMPONENTS-PURCH_ORG = GW_OPERATIONS-PURCH_ORG.
IT_COMPONENTS-REQUIREMENT_QUANTITY = GW_OPERATIONS-WORK_ACTIVITY.
IT_COMPONENTS-REQUIREMENT_QUANTITY_UNIT = V_meins.
APPEND IT_COMPONENTS.
V_RSPOS = V_RSPOS + 1.
v_item_num = v_item_num + 10.
endif.
ENDIF.
ENDLOOP.
describe table IT_COMPONENTS[] lines lv_line.
do lv_line times.
IT_METHODS-METHOD = 'CREATE'.
IT_METHODS-REFNUMBER = '000001'.
IT_METHODS-OBJECTTYPE = 'COMPONENT'.
APPEND IT_METHODS.
enddo.
CLEAR: IT_METHODS.
IT_METHODS-METHOD = 'SAVE'.
APPEND IT_METHODS.
do lv_line times.
IT_COMPONENTS_UP-MATERIAL = 'X'.
IT_COMPONENTS_UP-PLANT = 'X'.
IT_COMPONENTS_UP-ITEM_CAT = 'X'.
IT_COMPONENTS_UP-ITEM_NUMBER = 'X'.
IT_COMPONENTS_UP-ITEM_TEXT1 = 'X'.
IT_COMPONENTS_UP-ACTIVITY = 'X'.
IT_COMPONENTS_UP-PUR_GROUP = 'X'.
IT_COMPONENTS_UP-MATL_GROUP = 'X'.
IT_COMPONENTS_UP-VENDOR_NO = 'X'.
IT_COMPONENTS_UP-TRACKINGNO = 'X'.
IT_COMPONENTS_UP-PURCH_ORG = 'X'.
IT_COMPONENTS_UP-REQUIREMENT_QUANTITY = 'X'.
IT_COMPONENTS_UP-REQUIREMENT_QUANTITY_UNIT = 'X'.
APPEND IT_COMPONENTS_UP.
enddo.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
IT_METHODS = IT_METHODS
IT_HEADER = IT_HEADER
IT_HEADER_UP = IT_HEADER_UP
IT_PARTNER = IT_PARTNERS
IT_PARTNER_UP = IT_PARTNERS_UP
IT_OPERATION = IT_OPERATION
IT_OPERATION_UP = IT_OPERATION_UP
IT_COMPONENT = IT_COMPONENTS
IT_COMPONENT_UP = IT_COMPONENTS_UP
IT_HEADER_SRV = IT_HEADER_SRV
IT_HEADER_SRV_UP = IT_HEADER_SRV_UP
RETURN = RETURN.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
‎2010 Mar 18 8:23 AM
Hi Vinutha,
i m facing the same issue now (Creating changing, multiple, deleting components).
can you please tell me,
how you ended with this problem.
Regards,
Srikanth Pappu.
‎2010 Mar 18 2:42 PM
the documentation about this bapi is in contrary to many bapis very extesnsive
I see that you have
IT_METHODS-METHOD = 'CREATE'
instead of
IT_METHODS-METHOD = 'CHANGE'
since you're code it totally unreadable thanks to sdn policy I can't understand it is to hard to read and to see clearly if that's the mistake
kind regards
arthur
‎2010 Mar 19 6:39 AM
Hi Arthur,
i have not posted my code,
i could understand the methods, i have suceeded in using those methods for different object type individually
now my issue is
when i m trying to use the same method for 2 object type
Example - when i m trying to create to 2 components for an order, i m failing
only the first components is getting created,
prior to this i have appened the method "Create" for object type "Component" twice,
still the first compnent in the internal table is getting created twice, (but my requiremnt is to create, change, delete mutiple components at once)
Regards,
Srikanth Pappu.
‎2010 Mar 22 9:31 AM
please post this as a new question otherwise it's getting confusing if new questions are raised under existing ones
kind regards
arthur
‎2010 Jun 09 5:28 PM
Hello,
I have spent a lot of time (toooo much!) to get this running.
You have to fill method-refnumber with the table index of the component entry!!!!
The object key consists of order number and operation only.
I am using this beast to process networks (with a trick) to create/change operations or create components.
The trick:
- Enhancement to transfer field not included within bapi parameter structure
- global assign to avoid access to T350.
Now it works like a charm.
Regards
Andreas Groß
alogis