2009 Mar 05 9:53 AM
Dear Experts,
The situation is that I have to change data in the componenten in an order ( IW32 ) and I try to get it done by using a bapi called BAPI_ALM_ORDER_MAINTAIN .
This is how I've done it so far
Fill Method Internal table
wa_meth-method = 'SAVE'.
APPEND wa_meth TO t_meth.
Fill components
wa_meth-refnumber = sy-tabix.
wa_meth-objecttype = 'COMPONENT'.
wa_meth-method = 'CHANGE'.
wa_meth-objectkey(12) = aufnr. " ES_HEADER-orderID (order no.)
wa_meth-objectkey+12(4) = wa_in-activity. " ET_COMPONENT-activity (operation no.)
wa_meth-objectkey+16(4) = wa_in-res_item. " ET_COMPONENT-ITEM (suboperation no.)
APPEND wa_meth TO t_meth.
Could anyone give me some explanation about BAPI_ALM_ORDER_MAINTAIN and its object key.
2009 Mar 05 10:06 AM
CONSTANTS: c_1(1) TYPE c VALUE '1',
c_header(6) TYPE c VALUE 'HEADER',
c_change(6) TYPE c VALUE 'CHANGE'.
MOVE: c_1 TO wa_methods-refnumber,
c_header TO wa_methods-objecttype,
c_change TO wa_methods-method,
wa_final-aufnr TO wa_methods-objectkey.
APPEND wa_methods TO it_methods.
MOVE: wa_final-aufnr TO wa_header-orderid,
wa_final-auftext TO wa_header-short_text.
APPEND wa_header TO it_header.
MOVE: wa_final-aufnr TO wa_header_up-orderid,
gc_x TO wa_header_up-short_text,
gc_x TO wa_header_up-start_date,
gc_x TO wa_header_up-finish_date.
APPEND wa_header_up TO it_header_up.
-
CONSTANTS: c_operation(9) TYPE c VALUE 'OPERATION',
c_change(6) TYPE c VALUE 'CHANGE'.
gv_tabix = gv_tabix + 1.
*Method Details
MOVE: gv_tabix TO wa_methods-refnumber,
c_operation TO wa_methods-objecttype,
c_change TO wa_methods-method,
wa_final-aufnr TO wa_methods-objectkey,
wa_final-vornr TO wa_methods-objectkey+12(4).
APPEND wa_methods TO it_methods.
*Values
MOVE: wa_final-vornr TO wa_operation-activity, "Operation
wa_final-ltxa1 TO wa_operation-description. "Opr. short text
REPLACE ALL OCCURRENCES OF ',' IN wa_final-arbeit WITH '.'.
REPLACE ALL OCCURRENCES OF ',' IN wa_final-daunor WITH '.'.
REPLACE ALL OCCURRENCES OF ',' IN wa_final-anzkap WITH '.'.
REPLACE ALL OCCURRENCES OF ',' IN wa_final-duration_relation WITH '.'.
MOVE: wa_final-arbeit TO wa_operation-work_activity, "Duration
wa_final-arbeite TO wa_operation-un_work, "Unit for Work Activity
wa_final-daunor TO wa_operation-duration_normal. "Duration
MOVE: wa_final-daunore TO wa_operation-duration_normal_unit, "Normal
"Duration Unit
wa_final-anzkap TO wa_operation-number_of_capacities, "# Resources
wa_final-arbpl TO wa_operation-work_cntr. "Operation Work Center
MOVE wa_final-indet TO wa_operation-calc_key.
APPEND wa_operation TO it_operation.
*Update Flag
MOVE: gc_x TO wa_operation_up-activity, "Operation
gc_x TO wa_operation_up-description, "Opr. short text
gc_x TO wa_operation_up-work_activity, "Duration
gc_x TO wa_operation_up-un_work, "Unit for Work Activity
gc_x TO wa_operation_up-duration_normal, "Duration
gc_x TO wa_operation_up-duration_normal_unit,
"Normal Duration Unit
gc_x TO wa_operation_up-number_of_capacities, "# Resources
gc_x to wa_operation_up-start_cons, "Start Date
gc_x to wa_operation_up-fin_constr, "Finish Date
gc_x TO wa_operation_up-work_cntr, "Operation Work Center
gc_x TO wa_operation_up-calc_key. "calculation key
APPEND wa_operation_up TO it_operation_up.
-
CONSTANTS: c_relation(8) TYPE c VALUE 'RELATION',
c_change(6) TYPE c VALUE 'CHANGE'.
IF wa_final-order_predecessor IS NOT INITIAL.
gv_relation = gv_relation + 1.
MOVE: gv_relation TO wa_methods-refnumber,
c_relation TO wa_methods-objecttype,
c_change TO wa_methods-method,
wa_final-aufnr TO wa_methods-objectkey,
wa_final-aufnr TO wa_methods-objectkey+16(12).
"Pass this value for Operations
APPEND wa_methods TO it_methods.
MOVE: wa_final-order_predecessor TO wa_relation-order_predecessor,
wa_final-operation_predecessor TO wa_relation-operation_predecessor,
wa_final-order_successor TO wa_relation-order_successor,
wa_final-operation_successor TO wa_relation-operation_successor,
wa_final-relation_type TO wa_relation-relation_type,
wa_final-duration_relation_unit TO wa_relation-duration_relation_unit,
wa_final-duration_relation TO wa_relation-duration_relation.
APPEND wa_relation TO it_relation.
MOVE: gc_x TO wa_relation_up-relation_type,
gc_x TO wa_relation_up-duration_relation_unit,
gc_x TO wa_relation_up-duration_relation.
APPEND wa_relation_up TO it_relation_up.
ENDIF.
-
MOVE c_save TO wa_methods-method .
APPEND wa_methods TO it_methods.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = it_methods
it_header = it_header
it_header_up = it_header_up
it_operation = it_operation
it_operation_up = it_operation_up
it_relation = it_relation
it_relation_up = it_relation_up
return = it_return.
2009 Mar 05 10:06 AM
CONSTANTS: c_1(1) TYPE c VALUE '1',
c_header(6) TYPE c VALUE 'HEADER',
c_change(6) TYPE c VALUE 'CHANGE'.
MOVE: c_1 TO wa_methods-refnumber,
c_header TO wa_methods-objecttype,
c_change TO wa_methods-method,
wa_final-aufnr TO wa_methods-objectkey.
APPEND wa_methods TO it_methods.
MOVE: wa_final-aufnr TO wa_header-orderid,
wa_final-auftext TO wa_header-short_text.
APPEND wa_header TO it_header.
MOVE: wa_final-aufnr TO wa_header_up-orderid,
gc_x TO wa_header_up-short_text,
gc_x TO wa_header_up-start_date,
gc_x TO wa_header_up-finish_date.
APPEND wa_header_up TO it_header_up.
-
CONSTANTS: c_operation(9) TYPE c VALUE 'OPERATION',
c_change(6) TYPE c VALUE 'CHANGE'.
gv_tabix = gv_tabix + 1.
*Method Details
MOVE: gv_tabix TO wa_methods-refnumber,
c_operation TO wa_methods-objecttype,
c_change TO wa_methods-method,
wa_final-aufnr TO wa_methods-objectkey,
wa_final-vornr TO wa_methods-objectkey+12(4).
APPEND wa_methods TO it_methods.
*Values
MOVE: wa_final-vornr TO wa_operation-activity, "Operation
wa_final-ltxa1 TO wa_operation-description. "Opr. short text
REPLACE ALL OCCURRENCES OF ',' IN wa_final-arbeit WITH '.'.
REPLACE ALL OCCURRENCES OF ',' IN wa_final-daunor WITH '.'.
REPLACE ALL OCCURRENCES OF ',' IN wa_final-anzkap WITH '.'.
REPLACE ALL OCCURRENCES OF ',' IN wa_final-duration_relation WITH '.'.
MOVE: wa_final-arbeit TO wa_operation-work_activity, "Duration
wa_final-arbeite TO wa_operation-un_work, "Unit for Work Activity
wa_final-daunor TO wa_operation-duration_normal. "Duration
MOVE: wa_final-daunore TO wa_operation-duration_normal_unit, "Normal
"Duration Unit
wa_final-anzkap TO wa_operation-number_of_capacities, "# Resources
wa_final-arbpl TO wa_operation-work_cntr. "Operation Work Center
MOVE wa_final-indet TO wa_operation-calc_key.
APPEND wa_operation TO it_operation.
*Update Flag
MOVE: gc_x TO wa_operation_up-activity, "Operation
gc_x TO wa_operation_up-description, "Opr. short text
gc_x TO wa_operation_up-work_activity, "Duration
gc_x TO wa_operation_up-un_work, "Unit for Work Activity
gc_x TO wa_operation_up-duration_normal, "Duration
gc_x TO wa_operation_up-duration_normal_unit,
"Normal Duration Unit
gc_x TO wa_operation_up-number_of_capacities, "# Resources
gc_x to wa_operation_up-start_cons, "Start Date
gc_x to wa_operation_up-fin_constr, "Finish Date
gc_x TO wa_operation_up-work_cntr, "Operation Work Center
gc_x TO wa_operation_up-calc_key. "calculation key
APPEND wa_operation_up TO it_operation_up.
-
CONSTANTS: c_relation(8) TYPE c VALUE 'RELATION',
c_change(6) TYPE c VALUE 'CHANGE'.
IF wa_final-order_predecessor IS NOT INITIAL.
gv_relation = gv_relation + 1.
MOVE: gv_relation TO wa_methods-refnumber,
c_relation TO wa_methods-objecttype,
c_change TO wa_methods-method,
wa_final-aufnr TO wa_methods-objectkey,
wa_final-aufnr TO wa_methods-objectkey+16(12).
"Pass this value for Operations
APPEND wa_methods TO it_methods.
MOVE: wa_final-order_predecessor TO wa_relation-order_predecessor,
wa_final-operation_predecessor TO wa_relation-operation_predecessor,
wa_final-order_successor TO wa_relation-order_successor,
wa_final-operation_successor TO wa_relation-operation_successor,
wa_final-relation_type TO wa_relation-relation_type,
wa_final-duration_relation_unit TO wa_relation-duration_relation_unit,
wa_final-duration_relation TO wa_relation-duration_relation.
APPEND wa_relation TO it_relation.
MOVE: gc_x TO wa_relation_up-relation_type,
gc_x TO wa_relation_up-duration_relation_unit,
gc_x TO wa_relation_up-duration_relation.
APPEND wa_relation_up TO it_relation_up.
ENDIF.
-
MOVE c_save TO wa_methods-method .
APPEND wa_methods TO it_methods.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = it_methods
it_header = it_header
it_header_up = it_header_up
it_operation = it_operation
it_operation_up = it_operation_up
it_relation = it_relation
it_relation_up = it_relation_up
return = it_return.
2009 Mar 17 12:32 PM