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 to create service order through notification

Former Member
0 Likes
5,982

Hi,

I am looking for a BAPI to create service order through notification (IW34).

Please help.

Thanks,

Varuna Pal

Hi,

I am looking for a BAPI to create service order through notification (IW34).

Please help.

Thanks,

Varuna Pal

13 REPLIES 13
Read only

former_member544878
Participant
0 Likes
3,243

Hi ,

Try with - BAPI_SERVNOT_CREATE

Go to SE37 -;  BAPI_SERVNOT_CREATE

OR Try with BAPI_ALM_NOTIF_CREATE.

data: i_bapi2080_nothdri type standard table of bapi2080_nothdri with header line.

data: i_bapiret2 type standard table of bapiret2 with header line.

data: i_bapi2080_nothdre type standard table of bapi2080_nothdre with header line.

data: i_bapi2080_notfulltxti type standard table of bapi2080_notfulltxti with header line.

•create header data

i_bapi2080_nothdri-refobjectkey = 'PJAREF'.

i_bapi2080_nothdri-equipment    = '10000030'.

i_bapi2080_nothdri-reportedby   = 'PJAREP'.

i_bapi2080_nothdri-short_text   = 'PJA Short Test from BAPI'.

i_bapi2080_nothdri-priority     = '1'.

•create header long text

i_bapi2080_notfulltxti-objtype            = 'QMEL'.

i_bapi2080_notfulltxti-FORMAT_COL = 'U1'.

i_bapi2080_notfulltxti-text_line           = 'Long text 1'.

append i_bapi2080_notfulltxti.

i_bapi2080_notfulltxti-objtype            = 'QMEL'.

i_bapi2080_notfulltxti-FORMAT_COL = 'U1'.

i_bapi2080_notfulltxti-text_line           = 'Long text 2'.

append i_bapi2080_notfulltxti.

call function 'BAPI_ALM_NOTIF_CREATE'

  exporting

    notif_type               = 'M1'

    notifheader             = i_bapi2080_nothdri

importing

    notifheader_export   = i_bapi2080_nothdre

tables

    longtexts                = i_bapi2080_notfulltxti

    return                     = i_bapiret2.

call function 'BAPI_ALM_NOTIF_SAVE'

  exporting

    number                   = i_bapi2080_nothdre-notif_no.

call function 'BAPI_TRANSACTION_COMMIT'.

Thanks,

Rehan

Read only

0 Likes
3,243

Thanks for your reply.

But i want to create service order from notification number through a bapi, in the similar way as its done in IW34.

Read only

Former Member
0 Likes
3,243

Hi Varuna,

Check ALM_ME_ORDER_CREATE & CO_IH_ORDER_GENER_2

Regards

Shrikant

Read only

Former Member
0 Likes
3,243

Hi,

Solved it myself.

Here is the solution:

Use BAPI BAPI_ALM_ORDER_MAINTAIN and enter the data as follows:

IT_METHODS:

REFNUM     OBJECTTYPE     METHOD     OBJECTKEY

000001                                   SAVE          %00000000001

000001          HEADER             CREATE     %00000000001300000105

Here 300000105 is the notification number.

IT_HEADER

Orderid:  %00000000001

Order_type: SM01

Planplant: 11

mn_wk_ctr: 11

notif_no : 300000105

IT_HEADER_UP

Orderid: %00000000001

That's it and the order is created against a notification.

Regards,

Varuna Pal

Read only

0 Likes
3,243

Hi Varuna,

I have the same requirements.   I need to create a notification first and then use the notification to create an order.

I tried what you mentioned above but the bapi return that the objectkey cannot be more than 12chars.

If i create an order without using the notification, there is no problem.  The order is successfully created.

Please can you help me!  What did you to make it work?

Thanks and regards,

Jimmy

Read only

0 Likes
3,243

Hi Varuna,

I am also looking for similar functionality, I tried to execute the function module as per above code sample, I am getting errors, Did this work for you? If yes could you please reply with code snippet?

Thanks in advance,

Brahma Ausali.

Read only

0 Likes
3,243

Hi,

Yes it did work fine for me and the code is as above.

Can you please tell me what error are you getting and

also what all parameters are you passing.

Thanks,

Varuna

Read only

0 Likes
3,243

Hi Aruna, I passed below values in it_methods,

REFNUM OBJECTTYPE                       METHOD                           OBJECTKEY

000001                                  SAVE                             %00000000001

000001 HEADER                           CREATE                           000030099825

it_header

ORDERID                        %00000000001

ORDER_TYPE                     SM02

PLANPLANT                      1350

SCENARIO

BUS_AREA

MN_WK_CTR                      SN

PLANT                          1350

I am getting below error.

E IWO_BAPI2            118 Order %00000000001 cannot be saved, since no operation is maintained

E IWO_BAPI2            113 Error  during processing of BAPI methods

Read only

0 Likes
3,243

Hi,

In IT_METHODS : Give the Objkey in Create method as orderno + notification no

e.g. if ur notification no. is 30099825 then give the key as %0000000000130099825.

In IT_HEADER give notification number as well.

Also Pass IT_HEADER_UP and add order number.

It should work fine.

Read only

0 Likes
3,243

I am getting error "Length of internal key is incorrect (actual:20 target:12)' when I pass concatenated %0000000000130099825. i tried all possible ways to call by passing IT_METHODS IT_HEADER and IT_HEADER_UP. is possible for you to send me your woorking code to a.brahmanandam at gmail.com, that will be greatful.

Read only

0 Likes
3,243

This is how it should be called.

REPORT  ZALMBAPI_TEST.

DATA:

  is_methods       TYPE bapi_alm_order_method,

  is_header        TYPE bapi_alm_order_headers_i,

  is_operation     TYPE bapi_alm_order_operation,

  is_component     TYPE bapi_alm_order_component,

  is_component_up  TYPE bapi_alm_order_component_up,

  is_objlist       TYPE bapi_alm_order_objectlist .

DATA:

  it_methods       TYPE TABLE OF bapi_alm_order_method,

  it_header        TYPE TABLE OF bapi_alm_order_headers_i,

  it_operation     TYPE TABLE OF bapi_alm_order_operation,

  it_component     TYPE TABLE OF bapi_alm_order_component,

  it_component_up  TYPE TABLE OF bapi_alm_order_component_up,

  return           TYPE TABLE OF bapiret2,

  et_numbers       TYPE TABLE OF bapi_alm_numbers WITH HEADER LINE,

  it_objlist       TYPE TABLE OF bapi_alm_order_objectlist.

DATA: lv_temp TYPE char12 VALUE '%00000000001'.

is_methods-refnumber = '000001'.

is_methods-objecttype = 'OPERATION'.

is_methods-method = 'CREATE'.

is_methods-objectkey = lv_temp.

APPEND is_methods TO it_methods.

is_methods-refnumber = '000001'.

is_methods-objecttype = 'HEADER'.

is_methods-method = 'CREATETONOTIF'.

is_methods-objectkey = '%00000000001NNNNNNNNNN'  . " Notification number

APPEND is_methods TO it_methods.

*Save methode

CLEAR is_methods.

is_methods-method = 'SAVE'.

APPEND is_methods TO it_methods.

is_operation-ACTIVITY               =        '0010'.

is_operation-CONTROL_KEY           =         'SM01'.

is_operation-WORK_CNTR             =         'SN'.

is_operation-PLANT                =          '1350'.

is_operation-DESCRIPTION           =         'ABCDS'.

is_operation-ACTTYPE               =         'LHTH'.

is_operation-WORK_ACTIVITY        =          '10.0'.

is_operation-UN_WORK              =          'H'.

APPEND is_operation TO it_operation.

*data for header

is_header-orderid    = lv_temp.

is_header-ORDER_TYPE = 'SM02' .

is_header-PLANPLANT = '1350' .

is_header-MN_WK_CTR = 'SN' .

is_header-PLANT    = '1350' .

is_header-NOTIF_NO = NNNNNNNNNN'.

is_header-START_DATE  = sy-datum.

APPEND is_header TO it_header.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

  DESTINATION 'NONE'

  TABLES

    it_methods             = it_methods

    it_header              = it_header

   it_operation           = it_operation

    return                 = return

    et_numbers             = et_numbers.

IF test IS INITIAL.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  DESTINATION 'NONE'

    EXPORTING

      wait = 'X'.

ENDIF.

Read only

0 Likes
3,243

Thanks Brahmanandam.

It worked for me but some how changes are not reflecting in database. I see a new order generated but it do not appear in IW33. Even though I have done BAPI COMMIT as well.

Read only

Former Member
0 Likes
3,243

I found the solution making this. Create notification after order. It's necesary to make the following customizing. Please in Customizing go to Define notification and order integration. Assign to Order type an Notification type that will be assigned to the order. Then use bapi BAPI_ALM_ORDER_MAINTAIN. Customizing is the key task. If the customizing is right when bapi is being executed its will be creating the order at the same time notification.