2021 Mar 14 1:14 PM
I am creating new notification number and if notification number already exists then its data should get updated.
Creating is working fine with fm BAPI_ALM_NOTIF_CREATE but modify is not working. getting return error message as NO CHANGES MADE. BELOW IS THE CODE:
unction zrfc_notification.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(OBJECTID) TYPE QMNUM
*" VALUE(ASSET_ID) TYPE TPLNR
*" VALUE(FAULT_TYPE) TYPE QMGRP
*" VALUE(FAULT_DESC) TYPE CHAR10
*" VALUE(REPORTED_DT) TYPE QMDAT
*" VALUE(REPORTEDBY) TYPE QMNAM
*" VALUE(NOTE) TYPE QMTXT
*" EXPORTING
*" VALUE(E_MESSAGE) TYPE CHAR300
*"----------------------------------------------------------------------
data:lv_objectkey type bapi1003_key-object,
lv_objecttable type bapi1003_key-objecttable,
lv_classnum type bapi1003_key-classnum,
lv_classtype type bapi1003_key-classtype.
data:li_char_values type table of bapi1003_alloc_values_char,
li_num_values type table of bapi1003_alloc_values_num,
li_curr_values type table of bapi1003_alloc_values_curr,
li_return type table of bapiret2,
li_return_read type table of bapiret2,
li_line type table of tline,
li_creretun type standard table of bapiret2,
li_savretun type standard table of bapiret2.
data:lwa_char_values type bapi1003_alloc_values_char,
lwa_num_values type bapi1003_alloc_values_num,
lwa_return type bapiret2,
lwa_head type thead,
lwa_line type tline,
lwa_notif_head type bapi2080_nothdri,
lwa_notynohe type bapi2080_nothdre,
lwa_notysave type bapi2080_nothdre,
lwa_comretun type bapiret2,
lwa_notynohe1 TYPE ALM_ME_NOTIF_HEADER.
data:lv_tabix type sy-tabix,
lv_datum type cawn-atwrt,
lv_datum_float type cawn-atflv,
lv_msg_notif type string,
lv_notification type qmnum,
lv_condition type char200,
external_number type qmnum,
wa_qme1 type qmel.
lwa_notif_head-funct_loc = asset_id.
lwa_notif_head-code_group = fault_type.
* lwa_notif_head-coding = fault_desc.
lwa_notif_head-notif_date = reported_dt.
lwa_notif_head-reportedby = reportedby.
lwa_notif_head-short_text = note.
if fault_desc = 'LEAKAGE'.
lwa_notif_head-coding = '0001'.
elseif fault_desc = 'DAMAGE'.
lwa_notif_head-coding = '0002'.
elseif fault_desc = 'CRACK'.
lwa_notif_head-coding = '0003'.
endif.
select * from qmel into wa_qme1 where qmnum = objectid.
endselect.
if sy-subrc ne 0.
call function 'BAPI_ALM_NOTIF_CREATE'
exporting
external_number = objectid
notif_type = 'M1'
notifheader = lwa_notif_head
* TASK_DETERMINATION = ' '
* SENDER =
* ORDERID =
* IV_DONT_CHK_MANDATORY_PARTNER =
* NOTIFCATION_COPY =
* DOCUMENT_ASSIGN_COPY = ' '
* MAINTACTYTYPE =
importing
notifheader_export = lwa_notynohe
* MAINTACTYTYPE_EXPORT =
tables
* NOTITEM =
* NOTIFCAUS =
* NOTIFACTV =
* NOTIFTASK =
* NOTIFPARTNR =
* LONGTEXTS =
* KEY_RELATIONSHIPS =
return = li_creretun
* EXTENSIONIN =
* EXTENSIONOUT =
.
if sy-subrc = 0 and lwa_notynohe-notif_no is not initial.
call function 'BAPI_ALM_NOTIF_SAVE'
exporting
number = lwa_notynohe-notif_no
importing
notifheader = lwa_notysave
tables
return = li_savretun.
if sy-subrc = 0 and li_savretun is initial.
call function 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
importing
return = lwa_comretun.
if sy-subrc = 0 and lwa_comretun is initial.
* lv_notification = lwa_notysave-notif_no.
lv_notification = lwa_notynohe-notif_no.
elseif lwa_comretun is not initial.
lv_msg_notif = 'Notification not commited'.
endif.
elseif li_savretun is not initial.
lv_msg_notif = 'Notification not Saved'.
endif.
elseif li_creretun is not initial.
lv_msg_notif = 'Notification not created,incorrect input values'.
endif.
if lv_msg_notif is not initial.
concatenate 'Data updated successfully for pole:' asset_id 'and' lv_msg_notif into e_message separated by space.
else.
concatenate 'Data updated successfully for pole:' asset_id 'Notification created:' lv_notification into e_message separated by space.
endif.
else .
call function 'BAPI_ALM_NOTIF_DATA_MODIFY'
exporting
number = OBJECTID
NOTIFHEADER = lwa_notif_head
* NOTIFHEADER_X = 'X'
* NO_BUFFER_REFRESH_ON_ERROR = ' '
* MAINTACTYTYPE =
IMPORTING
NOTIFHEADER_EXPORT = lwa_notynohe
* MAINTACTYTYPE_EXPORT =
TABLES
* NOTIFITEM =
* NOTIFITEM_X =
* NOTIFCAUS =
* NOTIFCAUS_X =
* NOTIFACTV =
* NOTIFACTV_X =
* NOTIFTASK =
* NOTIFTASK_X =
* NOTIFPARTNR =
* NOTIFPARTNR_X =
RETURN = li_creretun
* EXTENSIONIN =
* EXTENSIONOUT =
.
if sy-subrc = 0 and lwa_notynohe-notif_no is not initial.
call function 'BAPI_ALM_NOTIF_SAVE'
exporting
number = lwa_notynohe-notif_no
importing
notifheader = lwa_notynohe
tables
return = li_savretun.
if sy-subrc = 0 and li_savretun is initial.
call function 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
importing
return = lwa_comretun.
endif.
endif.
endif.
endfunction.
2021 Mar 14 2:36 PM
Hi!
It's much easier to read code formatted with the CODE button, please use that the next time to make life easier for us... 🙂
In this case, for BAPI_ALM_NOTIF_DATA_MODIFY, you also need to specify which fields to update in the NOTIFHEADER_X by specifying 'X' for all the fields you want updated. As you are not supplying that one to the BAPI now you are correctly getting the message that no changes are made.
2024 May 02 4:35 AM
Hi Experts,
I am also facing similar issue with this BAPI. My scenario is to update details of task of notification like changing date or partner of task.
When executed 3 Bapi's (BAPI_ALM_NOTIF_DATA_MODIFY, BAPI_ALM_NOTIF_SAVE, BAPI_TRANSACTION_COMMIT) in sequence directly through SE37 then it updates the required details. But when tried the same sequence in report then neither it returns any error nor updates any details in db. Tried below code with destination 'None' and without also.
Code added is:
CALL FUNCTION 'BAPI_ALM_NOTIF_GET_DETAIL'
EXPORTING
number = '000300002864'
* CLEAR_BUFFER =
* IMPORTING
* NOTIFHEADER_EXPORT =
* NOTIFHDTEXT =
* MAINTACTYTYPE =
TABLES
notiftask = lt_notif_task_list
* NOTIFPARTNR =
* RETURN =
* EXTENSIONOUT =
.
READ TABLE lt_notif_task_list INTO lwa_notask INDEX 3.
IF sy-subrc = 0.
MOVE-CORRESPONDING lwa_notask TO lwa_notask_i.
lwa_notask-task_key = '0003'.
lwa_notask-partn_role = 'VW'.
lwa_notask-partner = '6'.
APPEND lwa_notask TO lt_notask.
lwa_notask_i-refobjectkey = lwa_notask-object_no.
lwa_notask_i-task_key = '0003'.
lwa_notask_i-partn_role = 'X'.
lwa_notask_i-partner = 'X'.
APPEND lwa_notask_i TO lt_notask_i.
CALL FUNCTION 'BAPI_ALM_NOTIF_DATA_MODIFY' DESTINATION 'NONE'
EXPORTING
number = lv_notf
* no_buffer_refresh_on_error = ' '
IMPORTING
notifheader_export = ls_notf_det
TABLES
notiftask = lt_notask
notiftask_x = lt_notask_i
* notifpartnr = lt_task_part
* notifpartnr_x = lt_task_part_i
return = lt_part_return2.
lv_notif = '000300002864'.
CALL FUNCTION 'BAPI_ALM_NOTIF_SAVE' DESTINATION 'NONE'
EXPORTING
number = lv_notif
IV_REFRESH_COMPLETE = 'X'
TABLES
return = lt_task_succ.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' DESTINATION 'NONE'.
Kindly let me know which step I am missing or any another way.
Thanks.
Shilpi