Create ADRNR
-ADDR_MAINTAIN_COMPLETE
-ADDR_NUMBER_GET
-ADDR_MEMORY_SAVE
-BAPI_TRANSACTION_COMMIT
DATA: lw_addr_c TYPE szadr_addr1_complete,
lw_addr_out TYPE szadr_addr1_complete,
lw_addr_ref TYPE addr_ref,
lw_adrc TYPE adrc.
DATA: lw_xaddr TYPE adsmtp,
lw_addrline TYPE szadr_adsmtp_line.
DATA: lw_addr TYPE addr1_data,
lw_addrline1 TYPE szadr_addr1_line.
DATA: lw_qmel TYPE qmel,
lw_vqmel TYPE viqmel,
lw_equi TYPE equi,
lw_iflo2 TYPE iflot,
lw_iflo1 TYPE iflot.
DATA: ls_riqs5 TYPE riqs5.
DATA: ls_vqmel TYPE viqmel.
DATA: ls_qmel TYPE qmel.
DATA:lv_addrno TYPE adrc-addrnumber,
lv_retcode TYPE szad_field-returncode,
lv_updateflag TYPE szad_field-updateflag.
IF i_noti IS NOT INITIAL.
SELECT SINGLE * FROM qmel INTO lw_qmel WHERE qmnum = i_noti.
IF sy-subrc = 0.
lw_addr_ref-appl_table = `QMEL`.
lw_addr_ref-appl_field = `QMNUM`.
lw_addr_ref-owner = `X`.
lw_addr_ref-addr_group = `PM01`.
lw_addr_ref-appl_key = i_noti.
lw_addr_c-addrhandle = lw_qmel-handle.
ENDIF.
ENDIF.
* get name city etc details
SELECT SINGLE * FROM adrc INTO lw_adrc WHERE addrnumber = i_adrnr.
IF sy-subrc = 0.
lw_addr-date_from = `00010101`.
lw_addr-date_to = `99991231`.
lw_addr-name1 = lw_adrc-name1.
lw_addr-city1 = lw_adrc-city1.
lw_addr-post_code1 = lw_adrc-post_code1.
lw_addr-country = lw_adrc-country.
lw_addrline1-data = lw_addr.
APPEND lw_addrline1 TO lw_addr_c-addr1_tab.
ENDIF.
lw_xaddr-flgdefault = `X`.
* lw_xaddr-home_flag = `X`.
lw_xaddr-smtp_addr = i_email.
lw_xaddr-smtp_srch = i_email.
lw_xaddr-remark = `Notification Standard`.
lw_xaddr-valid_from = `00010101`.
lw_xaddr-updateflag = `I`.
lw_addrline-adsmtp = lw_xaddr.
APPEND lw_addrline TO lw_addr_c-adsmtp_tab.
CALL FUNCTION `ADDR_MAINTAIN_COMPLETE`
EXPORTING
updateflag = `I`
addr1_complete = lw_addr_c
address_group = `PM01`
substitute_all_comm_data = `X`
check_address = ` `
* BLK_EXCPT =
IMPORTING
returncode = lv_retcode
addr1_complete_out = lw_addr_out
* TABLES
* ERROR_TABLE =
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
handle_exist = 3
internal_error = 4
address_blocked = 5
OTHERS = 6.
IF sy-subrc EQ 0.
CALL FUNCTION `ADDR_NUMBER_GET`
EXPORTING
address_handle = lw_addr_c-addrhandle
address_reference = lw_addr_ref
IMPORTING
address_number = lv_addrno
EXCEPTIONS
address_handle_not_exist = 1
internal_error = 2
parameter_error = 3
OTHERS = 4.
IF sy-subrc = 0.
CALL FUNCTION `ADDR_MEMORY_SAVE`
EXPORTING
execute_in_update_task = ` `
EXCEPTIONS
address_number_missing = 1
person_number_missing = 2
internal_error = 3
database_error = 4
reference_missing = 5
OTHERS = 6.
IF sy-subrc = 0.
CALL FUNCTION `BAPI_TRANSACTION_COMMIT`.
ENDIF.
SELECT SINGLE * FROM viqmel INTO ls_vqmel WHERE qmnum = i_noti.
IF sy-subrc = 0.
MOVE-CORRESPONDING ls_vqmel TO ls_riqs5.
ENDIF.
IF lv_addrno IS NOT INITIAL.
e_noti = lv_addrno.
ls_riqs5-adrnr = lv_addrno.
ENDIF.
CALL FUNCTION `IQS0_MODIFY_NOTIFICATION`
EXPORTING
i_qmnum = i_noti
i_riqs5_new = ls_riqs5
* I_RESET = `X`
* P_HEAD_NOCHANGE =
IMPORTING
e_viqmel = ls_vqmel
EXCEPTIONS
show_messages = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION `IQS4_SAVE_NOTIFICATION`
EXPORTING
i_qmnum = i_noti
i_commit = `X`
i_wait = `X`
* I_REFRESH_COMPLETE = `X`
IMPORTING
e_viqmel = lw_vqmel.
ENDIF.
ENDIF.