2014 Mar 13 11:00 AM
Dears,
i have this program to create service order and it create it correctly but doesnt link notification number.
could you advice me how to pass existing notification number to this bapi
*&---------------------------------------------------------------------*
*& Report Z_CS_RELEASE_SO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_CS_RELEASE_SO.
DATA wa_methods TYPE bapi_alm_order_method.
DATA itab_methods TYPE TABLE OF bapi_alm_order_method.
DATA wa_header TYPE bapi_alm_order_headers_i.
DATA itab_header TYPE TABLE OF bapi_alm_order_headers_i.
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 TYPE bapi_alm_order_operation.
DATA itab_operation TYPE TABLE OF bapi_alm_order_operation.
DATA wa_operation_up TYPE bapi_alm_order_operation_up.
DATA itab_operation_up TYPE TABLE OF bapi_alm_order_operation_up.
DATA wa_text TYPE bapi_alm_text.
DATA itab_text TYPE TABLE OF bapi_alm_text.
DATA wa_text_lines TYPE bapi_alm_text_lines.
DATA itab_text_lines TYPE TABLE OF bapi_alm_text_lines.
DATA itab_return TYPE TABLE OF bapiret2.
DATA itab_numbers TYPE TABLE OF bapi_alm_numbers.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'OPERATION'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = ' '.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_header-orderid = '%00000000001'.
wa_header-order_type = 'ZM01'.
wa_header-mn_wk_ctr = '101'.
WA_HEADER-EQUIPMENT = '000000000010007264'.
wa_header-start_date = '20100121'.
wa_header-FINISH_DATE = '20100121'.
wa_header-short_text = 'HEADER'.
wa_header-NOTIF_NO = '300002601'.
APPEND wa_header TO itab_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 = '101'.
wa_operation-control_key = 'SM01'.
wa_operation-plant = 'AN00'.
WA_OPERATION-DESCRIPTION = 'material purchase'.
APPEND wa_operation TO itab_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 itab_operation_up.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = itab_methods
it_header = itab_header
it_operation = itab_operation
it_operation_up = itab_operation_up
return = itab_return
et_numbers = itab_numbers.
DATA: W_RETURN TYPE bapiret2,
LV_FLAG TYPE CHAR1.
CLEAR LV_FLAG.
LOOP AT ITAB_RETURN INTO W_RETURN WHERE type = 'E'.
WRITE :/ W_RETURN-MESSAGE.
LV_FLAG = 'X'.
ENDLOOP.
IF LV_FLAG IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
.
commit work and wait.
write : 'order created'.
data: w_numbers type bapi_alm_numbers.
loop at itab_numbers into w_numbers.
* IT_METHODS -header
refresh itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CHANGE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
* IT_METHODS - header
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'RELEASE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
clear wa_methods.
* IT_METHODS - SAVE
wa_methods-refnumber = 1.
wa_methods-objecttype = ' '.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
* IT_HEADER
refresh itab_header.
clear wa_header.
wa_header-orderid = w_numbers-aufnr_new.
wa_header-order_type = 'PM03'.
wa_header-mn_wk_ctr = '2E'.
WA_HEADER-EQUIPMENT = '000000000010007264'.
wa_header-start_date = '20100121'.
wa_header-short_text = 'HEADER'.
APPEND wa_header TO itab_header.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = itab_methods
it_header = itab_header
it_header_up = itab_header_up
it_operation = itab_operation
return = itab_return
et_numbers = itab_numbers.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
commit work and wait.
endloop.
ENDIF.
2014 Mar 17 6:42 AM
Hi,
Use the original code you post and modify only the first HEADER data, not adding another HEADER data:
DATA itab_return TYPE TABLE OF bapiret2.
DATA itab_numbers TYPE TABLE OF bapi_alm_numbers.
"Line 26-30
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATETONOTIF'. <--Change this
wa_methods-objectkey = '%00000000001000300002660'<--change this
APPEND wa_methods TO itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'OPERATION'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
"Remove the additional HEADER data you add (Line 85-93)
"notification
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATETONOTIF'.
wa_methods-objectkey = '110000300002660' .
APPEND wa_methods TO itab_methods.
Thanks.
Regards,
Keng Haw
Dears,
i have this program to create service order and it create it correctly but doesnt link notification number.
could you advice me how to pass existing notification number to this bapi
*&---------------------------------------------------------------------*
*& Report Z_CS_RELEASE_SO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_CS_RELEASE_SO.
DATA wa_methods TYPE bapi_alm_order_method.
DATA itab_methods TYPE TABLE OF bapi_alm_order_method.
DATA wa_header TYPE bapi_alm_order_headers_i.
DATA itab_header TYPE TABLE OF bapi_alm_order_headers_i.
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 TYPE bapi_alm_order_operation.
DATA itab_operation TYPE TABLE OF bapi_alm_order_operation.
DATA wa_operation_up TYPE bapi_alm_order_operation_up.
DATA itab_operation_up TYPE TABLE OF bapi_alm_order_operation_up.
DATA wa_text TYPE bapi_alm_text.
DATA itab_text TYPE TABLE OF bapi_alm_text.
DATA wa_text_lines TYPE bapi_alm_text_lines.
DATA itab_text_lines TYPE TABLE OF bapi_alm_text_lines.
DATA itab_return TYPE TABLE OF bapiret2.
DATA itab_numbers TYPE TABLE OF bapi_alm_numbers.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'OPERATION'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = ' '.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_header-orderid = '%00000000001'.
wa_header-order_type = 'ZM01'.
wa_header-mn_wk_ctr = '101'.
WA_HEADER-EQUIPMENT = '000000000010007264'.
wa_header-start_date = '20100121'.
wa_header-FINISH_DATE = '20100121'.
wa_header-short_text = 'HEADER'.
wa_header-NOTIF_NO = '300002601'.
APPEND wa_header TO itab_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 = '101'.
wa_operation-control_key = 'SM01'.
wa_operation-plant = 'AN00'.
WA_OPERATION-DESCRIPTION = 'material purchase'.
APPEND wa_operation TO itab_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 itab_operation_up.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = itab_methods
it_header = itab_header
it_operation = itab_operation
it_operation_up = itab_operation_up
return = itab_return
et_numbers = itab_numbers.
DATA: W_RETURN TYPE bapiret2,
LV_FLAG TYPE CHAR1.
CLEAR LV_FLAG.
LOOP AT ITAB_RETURN INTO W_RETURN WHERE type = 'E'.
WRITE :/ W_RETURN-MESSAGE.
LV_FLAG = 'X'.
ENDLOOP.
IF LV_FLAG IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
.
commit work and wait.
write : 'order created'.
data: w_numbers type bapi_alm_numbers.
loop at itab_numbers into w_numbers.
* IT_METHODS -header
refresh itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CHANGE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
* IT_METHODS - header
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'RELEASE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
clear wa_methods.
* IT_METHODS - SAVE
wa_methods-refnumber = 1.
wa_methods-objecttype = ' '.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
* IT_HEADER
refresh itab_header.
clear wa_header.
wa_header-orderid = w_numbers-aufnr_new.
wa_header-order_type = 'PM03'.
wa_header-mn_wk_ctr = '2E'.
WA_HEADER-EQUIPMENT = '000000000010007264'.
wa_header-start_date = '20100121'.
wa_header-short_text = 'HEADER'.
APPEND wa_header TO itab_header.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = itab_methods
it_header = itab_header
it_header_up = itab_header_up
it_operation = itab_operation
return = itab_return
et_numbers = itab_numbers.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
commit work and wait.
endloop.
ENDIF.
2014 Mar 13 2:12 PM
Hi,
Let's try this
For example your existing notification number is 000012345678:
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATETONOTIF'.
wa_methods-objectkey = '%00000000001000012345678'.
APPEND wa_methods TO itab_methods.
Thanks.
Regards,
Keng Haw
2014 Mar 16 6:53 AM
I add the code but raise the error in ITAB_RETURN Table
"notification
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATETONOTIF'.
wa_methods-objectkey = '%00300002637' .
APPEND wa_methods TO itab_methods.
ITAB_RETURN IS :
W IW 431 Start date is in the past
W IW 438 End date is in the past
W IW 431 Start date is in the past
W IW 438 End date is in the past
E IWO_BAPI2 118 Order %00000000002 cannot be saved, since no operation is maintained
E IWO_BAPI2 113 Error during processing of BAPI methods
i am sorry how can i add the opertaion ,however it is already exist in code?!!
2014 Mar 16 1:53 PM
Hello Hady,
Can you try with below points.
wa_methods-objectkey = '%00300002637'. <----- Is 030 your client ??
Pass client also to the object key and try.
wa_methods-objectkey = '<client><notification>'.
2014 Mar 16 3:06 PM
i am so sorry i dont understand what is the combination of objectkey .
any way my client is development = 110.
wa_methods-objectkey = '110300002660' . but doesnt work, where notification number is 300002660
thanks Thanga
2014 Mar 16 4:46 PM
Hello Hady,
Pass the leading zeroes of notification also. If the notification is 000200000001 and client is 010.
pass it as objectkey = '010000200000001'.
Regards,
TP
2014 Mar 17 6:02 AM
i did what you said but this message raised ,where my dev client is 110 and notification is 000300002660
Order 110000300002 does not exist
"notification
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATETONOTIF'.
wa_methods-objectkey = '%110000300002660' .
APPEND wa_methods TO itab_methods.
full code is
DATA wa_methods TYPE bapi_alm_order_method.
DATA itab_methods TYPE TABLE OF bapi_alm_order_method.
DATA wa_header TYPE bapi_alm_order_headers_i.
DATA itab_header TYPE TABLE OF bapi_alm_order_headers_i.
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 TYPE bapi_alm_order_operation.
DATA itab_operation TYPE TABLE OF bapi_alm_order_operation.
DATA wa_operation_up TYPE bapi_alm_order_operation_up.
DATA itab_operation_up TYPE TABLE OF bapi_alm_order_operation_up.
DATA wa_text TYPE bapi_alm_text.
DATA itab_text TYPE TABLE OF bapi_alm_text.
DATA wa_text_lines TYPE bapi_alm_text_lines.
DATA itab_text_lines TYPE TABLE OF bapi_alm_text_lines.
DATA itab_return TYPE TABLE OF bapiret2.
DATA itab_numbers TYPE TABLE OF bapi_alm_numbers.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'OPERATION'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = ' '.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_header-orderid = '%00000000001'.
*wa_header-order_type = 'ZM01'.
wa_header-order_type = 'ZM01'.
wa_header-mn_wk_ctr = '101'.
WA_HEADER-EQUIPMENT = '000000000010007264'.
wa_header-start_date = '20100121'.
wa_header-FINISH_DATE = '20100121'.
wa_header-short_text = 'HEADER'.
*wa_header-NOTIF_NO = '3000026 01'.
APPEND wa_header TO itab_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 = '101'.
wa_operation-control_key = 'SM01'.
wa_operation-plant = 'AN00'.
WA_OPERATION-DESCRIPTION = 'material purchase'.
APPEND wa_operation TO itab_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 itab_operation_up.
"notification
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATETONOTIF'.
wa_methods-objectkey = '110000300002660' .
APPEND wa_methods TO itab_methods.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = itab_methods
it_header = itab_header
it_operation = itab_operation
it_operation_up = itab_operation_up
return = itab_return
et_numbers = itab_numbers.
DATA: W_RETURN TYPE bapiret2,
LV_FLAG TYPE CHAR1.
CLEAR LV_FLAG.
LOOP AT ITAB_RETURN INTO W_RETURN WHERE type = 'E'.
WRITE :/ W_RETURN-MESSAGE.
LV_FLAG = 'X'.
ENDLOOP.
IF LV_FLAG IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
.
commit work and wait.
write : 'order created'.
data: w_numbers type bapi_alm_numbers.
loop at itab_numbers into w_numbers.
* IT_METHODS -header
refresh itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CHANGE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
* IT_METHODS - header
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'RELEASE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
clear wa_methods.
* IT_METHODS - SAVE
wa_methods-refnumber = 1.
wa_methods-objecttype = ' '.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
* IT_HEADER
refresh itab_header.
clear wa_header.
wa_header-orderid = w_numbers-aufnr_new.
*wa_header-order_type = 'PM03'.
wa_header-order_type = 'ZM01'.
wa_header-mn_wk_ctr = '2E'.
WA_HEADER-EQUIPMENT = '000000000010007264'.
wa_header-start_date = '20100121'.
wa_header-short_text = 'HEADER'.
APPEND wa_header TO itab_header.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = itab_methods
it_header = itab_header
it_header_up = itab_header_up
it_operation = itab_operation
return = itab_return
et_numbers = itab_numbers.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
commit work and wait.
endloop.
ENDIF.
2014 Mar 17 6:42 AM
Hi,
Use the original code you post and modify only the first HEADER data, not adding another HEADER data:
DATA itab_return TYPE TABLE OF bapiret2.
DATA itab_numbers TYPE TABLE OF bapi_alm_numbers.
"Line 26-30
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATETONOTIF'. <--Change this
wa_methods-objectkey = '%00000000001000300002660'<--change this
APPEND wa_methods TO itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'OPERATION'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
"Remove the additional HEADER data you add (Line 85-93)
"notification
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATETONOTIF'.
wa_methods-objectkey = '110000300002660' .
APPEND wa_methods TO itab_methods.
Thanks.
Regards,
Keng Haw
2014 Mar 17 7:23 AM
Thanks so much Keng Haw Soon
this is full program my help other ABAPERs
*&---------------------------------------------------------------------*
*& Report Z_CS_RELEASE_SO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_CS_RELEASE_SO.
DATA wa_methods TYPE bapi_alm_order_method.
DATA itab_methods TYPE TABLE OF bapi_alm_order_method.
DATA wa_header TYPE bapi_alm_order_headers_i.
DATA itab_header TYPE TABLE OF bapi_alm_order_headers_i.
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 TYPE bapi_alm_order_operation.
DATA itab_operation TYPE TABLE OF bapi_alm_order_operation.
DATA wa_operation_up TYPE bapi_alm_order_operation_up.
DATA itab_operation_up TYPE TABLE OF bapi_alm_order_operation_up.
DATA wa_text TYPE bapi_alm_text.
DATA itab_text TYPE TABLE OF bapi_alm_text.
DATA wa_text_lines TYPE bapi_alm_text_lines.
DATA itab_text_lines TYPE TABLE OF bapi_alm_text_lines.
DATA itab_return TYPE TABLE OF bapiret2.
DATA itab_numbers TYPE TABLE OF bapi_alm_numbers.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
*wa_methods-method = 'CREATE'.
wa_methods-method = 'CREATETONOTIF'.
*wa_methods-objectkey = '%110000300002671'.
wa_methods-objectkey = '%00000000001000300002673 '.
APPEND wa_methods TO itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'OPERATION'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = ' '.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = '%00000000001'.
APPEND wa_methods TO itab_methods.
wa_header-orderid = '%00000000001'.
*wa_header-order_type = 'ZM01'.
wa_header-order_type = 'ZM01'.
wa_header-mn_wk_ctr = '101'.
WA_HEADER-EQUIPMENT = '000000000010007264'.
wa_header-start_date = '20100121'.
wa_header-FINISH_DATE = '20100121'.
wa_header-short_text = 'HEADER'.
*wa_header-NOTIF_NO = '3000026 01'.
APPEND wa_header TO itab_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 = '101'.
wa_operation-control_key = 'SM01'.
wa_operation-plant = 'AN00'.
WA_OPERATION-DESCRIPTION = 'material purchase'.
APPEND wa_operation TO itab_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 itab_operation_up.
******notification
******wa_methods-refnumber = 1.
******
******wa_methods-objecttype = 'HEADER'.
******
******wa_methods-method = 'CREATETONOTIF'.
******
******wa_methods-objectkey = '%110000300002660' .
******APPEND wa_methods TO itab_methods.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = itab_methods
it_header = itab_header
it_operation = itab_operation
it_operation_up = itab_operation_up
return = itab_return
et_numbers = itab_numbers.
DATA: W_RETURN TYPE bapiret2,
LV_FLAG TYPE CHAR1.
CLEAR LV_FLAG.
LOOP AT ITAB_RETURN INTO W_RETURN WHERE type = 'E'.
WRITE :/ W_RETURN-MESSAGE.
LV_FLAG = 'X'.
ENDLOOP.
IF LV_FLAG IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
.
commit work and wait.
write : 'order created'.
data: w_numbers type bapi_alm_numbers.
loop at itab_numbers into w_numbers.
* IT_METHODS -header
refresh itab_methods.
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CHANGE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
* IT_METHODS - header
wa_methods-refnumber = 1.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'RELEASE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
clear wa_methods.
* IT_METHODS - SAVE
wa_methods-refnumber = 1.
wa_methods-objecttype = ' '.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = w_numbers-aufnr_new.
APPEND wa_methods TO itab_methods.
* IT_HEADER
refresh itab_header.
clear wa_header.
wa_header-orderid = w_numbers-aufnr_new.
*wa_header-order_type = 'PM03'.
wa_header-order_type = 'ZM01'.
wa_header-mn_wk_ctr = '2E'.
WA_HEADER-EQUIPMENT = '000000000010007264'.
wa_header-start_date = '20100121'.
wa_header-short_text = 'HEADER'.
APPEND wa_header TO itab_header.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = itab_methods
it_header = itab_header
it_header_up = itab_header_up
it_operation = itab_operation
return = itab_return
et_numbers = itab_numbers.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
commit work and wait.
endloop.
ENDIF.
2014 Mar 17 7:32 AM
could you explain the meaning of
wa_methods-objectkey = '%00000000001000300002673'.
why we put zeros before notification number and the %?
thanks Keng Haw Soon
2014 Mar 17 7:38 AM
HI,
wa_methods-objectkey = '%00000000001000300002673'.
%00000000001<--this is the object key you used in previous code
000300002673<-this is the notification no. of the existing notification
After the execution of BAPI_ALM_ORDER_MAINTAIN, %00000000001 will become new order number and tie to the existing notification.
Thanks.
Regards,
Keng Haw
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |