Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI for TX IW34

Former Member
0 Likes
1,115

Hi All,

I am using bapi BAPI_SERVNOT_SAVE (Create Notification) and BAPI_ALM_ORDER_MAINTAIN (Create Service Orders). They all work perfectly,expect the order that is created is not linked to the notification.tx IW34 creates order for a notification. Thats what i would like to accomplish with BAPI_ALM_ORDER_MAINTAIN.

Is there anything that i am doing wrong?

Thank you in Advance

D

3 REPLIES 3
Read only

Former Member
0 Likes
714

I had the same problem.

Here is a corresponding enty in the Wiki with which you can solve the problem.

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/erplo/using%2bbapi_alm_order_maintain%2bmethod%2b...

Read only

0 Likes
714

Hi Kim,

Thank you for the response. For some reason i get an error while trying to create an order for a notification. I tried to follow the wiki that you referred. Can you please have a look at the below and check if there anything i am missing.

Thank you in advance,

constants: charx TYPE C VALUE 'X',

chare TYPE C VALUE 'E',

chara TYPE C VALUE 'A'.

data: it_methods type BAPI_ALM_ORDER_METHOD occurs 0 with header line,

it_header type BAPI_ALM_ORDER_HEADERS_I occurs 0 with header line,

it_operations type BAPI_ALM_ORDER_OPERATION occurs 0 with header line,

it_et_numbers type BAPI_ALM_NUMBERS occurs 0 with header line,

it_objectlist type BAPI_ALM_ORDER_OBJECTLIST occurs 0 with header line,

it_return like bapiret2 occurs 0 with header line.

data: l_error like bapiflag,

l_date type sy-datum value '29092008',

l_ordernr type OBJIDEXT,

l_notif TYPE qmnum VALUE 'INC0002',

l_temp TYPE char15 VALUE '% 0000000001'.

concatenate l_temp l_notif into l_ordernr.

  • Methods

it_methods-refnumber = '000001'.

it_methods-objecttype = 'OPERATION'.

it_methods-method = 'CREATE'.

it_methods-objectkey = l_ordernr.

append it_methods. clear it_methods.

it_methods-refnumber = '000001'.

it_methods-objecttype = 'HEADER'.

it_methods-method = 'CREATETONOTIF'.

it_methods-objectkey = l_ordernr.

append it_methods. clear it_methods.

it_methods-refnumber = '000001'.

it_methods-objecttype = ''.

it_methods-method = 'SAVE'.

it_methods-objectkey = l_ordernr.

append it_methods. clear it_methods.

*******************************

*Header

it_header-ORDERID = 'INC002'.

it_header-ORDER_TYPE = 'SM01'.

it_header-PLANPLANT = '120'.

it_header-MN_WK_CTR = 'STACY'.

append it_header. clear it_methods.

*******************************

*Operations

it_operations-ACTIVITY = '0010'.

it_operations-CONTROL_KEY = 'SM01'.

it_operations-DESCRIPTION = 'TEST NOTIFICATION 8'.

it_operations-ACTTYPE = 'TS-001'.

it_operations-WORK_ACTIVITY = '1'.

append it_operations. clear: it_operations.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

TABLES

IT_METHODS = it_methods

IT_HEADER = it_header

IT_OPERATION = it_operations

RETURN = it_return

ET_NUMBERS = it_et_numbers.

loop at it_return where type = chare or type = chara.

l_error = charx.

write: / it_return-id, it_return-number, it_return-message.

endloop.

call function 'BAPI_TRANSACTION_COMMIT'.

Edited by: Danny Molepo on Sep 30, 2008 6:06 PM

Edited by: Danny Molepo on Sep 30, 2008 6:07 PM

Read only

0 Likes
714

This is realy good one

[Solved] BAPI to create service order through notification

And remember it is important that in lt_methods line with save were at the end.

This is my code

APPEND INITIAL LINE TO lt_methods ASSIGNING <ls_methods>.
     <ls_methods>-refnumber  = '000001'.
     <ls_methods>-objecttype = zcl_tm1_constants=>cs_order_methods-objecttype-oper.
     <ls_methods>-method     = zcl_tm1_constants=>cs_order_methods-method-create.
     <ls_methods>-objectkey  = lv_aufnr.

     APPEND INITIAL LINE TO lt_methods ASSIGNING <ls_methods>.
     <ls_methods>-refnumber  = '000001'.
     <ls_methods>-objecttype = zcl_tm1_constants=>cs_order_methods-objecttype-head.
     <ls_methods>-method     = zcl_tm1_constants=>cs_order_methods-objecttype-notif.
     CONCATENATE lv_aufnr iv_notif_no INTO <ls_methods>-objectkey .

     APPEND INITIAL LINE TO lt_methods ASSIGNING <ls_methods> .
     <ls_methods>-refnumber  = '000001'.
     <ls_methods>-method     = zcl_tm1_constants=>cs_order_methods-method-save.
     <ls_methods>-objectkey  = lv_aufnr.


     "header
     APPEND INITIAL LINE TO lt_maint_header ASSIGNING FIELD-SYMBOL(<ls_maint_header>).
     <ls_maint_header>-order_type  = iv_order_type.
     <ls_maint_header>-start_date  = lv_beg_date.
     <ls_maint_header>-finish_date = lv_fin_date.
     <ls_maint_header>-basicstart  = iv_beg_time.
     <ls_maint_header>-basic_fin   = iv_fin_time.
     <ls_maint_header>-mn_wk_ctr   = iv_main_work_center.
     <ls_maint_header>-plant       = iv_main_work.
     <ls_maint_header>-planplant   = iv_planning_plant.
     <ls_maint_header>-notif_no    = iv_notif_no.
     <ls_maint_header>-notif_type  = iv_notif_type.


     "operations
     APPEND INITIAL LINE TO lt_operation ASSIGNING FIELD-SYMBOL(<ls_operations>).
     <ls_operations>-control_key = iv_control_key.
     <ls_operations>-number_of_capacities = iv_no_of_cap.
     <ls_operations>-un_work = iv_unit_of_work.
     <ls_operations>-duration_normal_unit = iv_normal_duration.
     <ls_operations>-work_activity = iv_work_involved.
     <ls_operations>-description = iv_operation_txt.
     <ls_operations>-activity    = '0010'.


CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
       TABLES
         it_methods   = lt_methods   " BAPI structure: Processing methods
         it_header    = lt_maint_header
*       it_component = lt_component
         it_operation = lt_operation
         return       = lt_return
         et_numbers   = et_numbers.   " Return Parameter(s)