Application Development 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: 

Why is creation of a service notification using BAPI not working?

Former Member
0 Kudos

I need to create a service notification.

I have found 2 BAPIs.

BAPI_SERVICENOTIFICAT_CREATE

BAPI_SERVNOT_CREATE

The code below using the second BAPI is not creating a notification and the return parm does not have any errors.

You can see it does a call to commit after the BAPI call

Perhaps I am missing something critical in the parms.

We are trying to creat a service type notification using equipment.

-


DATA ls_notif_h TYPE bapi2080_nothdri.

data ls_notif_e type BAPI2080_NOTHDRE.

DATA lt_return TYPE STANDARD TABLE OF bapiret2.

DATA ls_return LIKE LINE OF lt_return.

ls_notif_h-equipment = '10000044'.

CALL FUNCTION 'BAPI_SERVNOT_CREATE'

EXPORTING

  • EXTERNAL_NUMBER =

notif_type = 'S3'

notifheader = ls_notif_h

  • TASK_DETERMINATION = ' '

  • SENDER =

  • ORDERID =

IMPORTING

NOTIFHEADER_EXPORT = ls_notif_e

TABLES

  • NOTITEM =

  • NOTIFCAUS =

  • NOTIFACTV =

  • NOTIFTASK =

  • NOTIFPARTNR =

  • LONGTEXTS =

  • KEY_RELATIONSHIPS =

return = lt_return

.

IF lt_return IS INITIAL.

COMMIT WORK AND WAIT.

write: / ls_notif_e-NOTIF_NO.

ELSE.

LOOP AT lt_return INTO ls_return.

WRITE:/ 'errors'.

  • ls_return.

ENDLOOP.

-


Thanks.

Scott

7 REPLIES 7

former_member194669
Active Contributor
0 Kudos

Try this way


CALL FUNCTION 'BAPI_SERVNOT_CREATE'
EXPORTING
* EXTERNAL_NUMBER =
notif_type = 'S3'
notifheader = ls_notif_h
* TASK_DETERMINATION = ' '
* SENDER =
* ORDERID =
IMPORTING
NOTIFHEADER_EXPORT = ls_notif_e
TABLES
* NOTITEM =
* NOTIFCAUS =
* NOTIFACTV =
* NOTIFTASK =
* NOTIFPARTNR =
* LONGTEXTS =
* KEY_RELATIONSHIPS =
return = lt_return
.

* IF lt_return IS INITIAL.                                               " <<< Comment this lie
read table  lt_return into ls_return with key type = 'E'. " << Change
if sy-subrc ne 0.                                                             " << Change 
COMMIT WORK AND WAIT.
write: / ls_notif_e-NOTIF_NO.
ELSE.
LOOP AT lt_return INTO ls_return.

WRITE:/ 'errors'.
* ls_return.
ENDLOOP.
endif.

0 Kudos

Nope - no change but i did get it to work.

I used the BAPI called BAPI_SERVICENOTIFICAT_CREATE and it works.

But thanks for your suggestion.

Scott

Former Member
0 Kudos

Found bapi BAPI_SERVICENOTIFICAT_CREATE and it works.

Former Member
0 Kudos

Will follow up with correct answer.

Former Member
0 Kudos

I was calling the correct FM but you must follow it up with calls to 2 more FM to get the data into SAP.

After calling BAPI_SERVNOT_CREATE you MUST call BAPI_SERVNOT_SAVE and then BAPI_TRANSACTION_COMMIT to get it to work.

0 Kudos

Thank you Scott for writing the solution, because, generally, many people do not write the resolution, How they achieved it.....its so useful, while doing Google.

0 Kudos

Thank you Scott for writing the solution, because, generally, many people do not write the resolution, How they achieved it.....its so useful, while doing Google.