Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

Binding BAPI_ALM_ORDER_MAINTAIN with existing notification

$
0
0

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.

Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>