Skip to Content
1
Feb 04, 2015 at 03:32 PM

CRAETE OPERATION USING BAPI_ALM_ORDER_MAINTAIN

1705 Views

HI ABAP EXPERTS,

I am trying to create components and operations for an existing order(IW32) .

i can create component correctly,but i face a problem creating new operation

this is my bapi

could you provide me solving the error?

DATA wa_header_up TYPE bapi_alm_order_headers_up.
DATA itab_header_up TYPE TABLE OF bapi_alm_order_headers_up.

DATA wa_operation_up TYPE bapi_alm_order_operation_up.
DATA it_operation_up TYPE TABLE OF bapi_alm_order_operation_up.


data:
IT_PLANT TYPE STANDARD TABLE OF BAPI_ALM_ORDER_HEADERS_I-PLANPLANT, "HADY PLANT
WA_PLANT LIKE LINE OF IT_PLANT,


it_methods type standard table of bapi_alm_order_method,
wa_methods like line of it_methods,
it_header type standard table of bapi_alm_order_headers_i,
wa_header like line of it_header,
it_header_up type standard table of bapi_alm_order_headers_up,
it_header_srv type standard table of bapi_alm_order_srvdat_e,
it_header_srv_up type standard table of bapi_alm_order_srvdat_up,
it_userstatus type standard table of bapi_alm_order_usrstat,
it_partner type standard table of bapi_alm_order_partn_mul,
wa_partner like line of it_partner,
it_partner_up type standard table of bapi_alm_order_partn_mul_up,
it_operation type standard table of bapi_alm_order_operation,
wa_operation like line of it_operation,
*it_operation_up type standard table of bapi_alm_order_operation_up,
it_relation type standard table of bapi_alm_order_relation ,
it_relation_up type standard table of bapi_alm_order_relation_up ,
it_component type standard table of bapi_alm_order_component,
wa_component like LINE OF it_component,
it_component_up type standard table of bapi_alm_order_component_up,
it_text type standard table of bapi_alm_text,
it_text_lines type standard table of bapi_alm_text_lines,
extension_in type standard table of bapiparex,
return type standard table of bapiret2,
wa_return like line of return,
et_numbers type standard table of bapi_alm_numbers,
wa_numbers like line of et_numbers.




wa_methods-refnumber = 1.
wa_methods-objecttype = 'OPERATION'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO it_methods.


wa_methods-refnumber = 1.
wa_methods-objecttype = ' '.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = ORDERNO.
APPEND wa_methods TO IT_methods.


wa_header-orderid = ORDERNO.
wa_header-order_type = 'ZSM2'.
wa_header-mn_wk_ctr = 'HAHV'.
WA_HEADER-EQUIPMENT = '000000000010008442'.
wa_header-start_date = '20150217'.
wa_header-FINISH_DATE = '20150217'.
wa_header-short_text = 'HEADER'.
wa_header-NOTIF_NO = '300002927'.
APPEND wa_header TO IT_header.

wa_header_up-mn_wk_ctr = 'X'.
WA_HEADER_up-EQUIPMENT = 'X'.

wa_header_up-start_date = 'X'.
wa_header_up-short_text = 'X'.
APPEND wa_header_up TO itab_header_up.

wa_operation-activity = '0010'.
WA_OPERATION-WORK_CNTR = 'HAHV'.
wa_operation-control_key = 'SM01'.
wa_operation-plant = 'BC20'.
WA_OPERATION-DESCRIPTION = 'OPERATION DESCRIPTION'.
APPEND wa_operation TO IT_operation.

wa_operation_UP-activity = 'X'.
WA_OPERATION_UP-WORK_CNTR = 'X'.
wa_operation_UP-control_key = 'X'.
wa_operation_UP-plant = 'X'.
wa_operation_UP-description = 'X'.

APPEND wa_operation_up TO IT_operation_up.











wa_methods-refnumber = '000001'.
wa_methods-objecttype = ''.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = ORDERNO.
append wa_methods to it_methods.
clear wa_methods.

wa_methods-refnumber = '000001'. " Component
wa_methods-objecttype = 'COMPONENT'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = ORDERNO.
append wa_methods to it_methods.
clear wa_methods.

wa_component-ACTIVITY = '0010'.
wa_component-material = 'TY-120'.
Wa_component-item_cat = 'L'.
wa_component-unload_pt = 'XXX'.
wa_component-requirement_quantity = '4'.
wa_component-planT = 'BC20'.
append wa_component to it_component.
clear wa_component.

refresh return.








BREAK ABAPTEAM.

refresh return.
call function 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = it_methods
it_header = it_header
it_header_up = it_header_up
it_header_srv = it_header_srv
it_header_srv_up = it_header_srv_up
it_userstatus = it_userstatus
it_partner = it_partner
it_partner_up = it_partner_up
it_operation = it_operation
it_operation_up = it_operation_up
it_relation = it_relation
it_relation_up = it_relation_up
it_component = it_component
it_component_up = it_component_up
it_text = it_text
it_text_lines = it_text_lines
extension_in = extension_in
return = return
et_numbers = et_numbers.

DATA : XX TYPE I VALUE 0.
loop at return into wa_return.
IF WA_RETURN-TYPE = 'S'.
FLAG = 1.


ELSE.
FLAG = ''.
write:/ WA_RETURN-MESSAGE.

ENDIF.

endloop.



call function 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.

CALL FUNCTION 'DEQUEUE_ALL'
EXPORTING
_SYNCHRON = 'X'.
commit work and wait.