adesso orange🍊Stellenangebote:
Software Engineer Trainee · Senior
| (Senior) Cloud Software Engineer BTP
(Senior) Consultant Technologie · Consultant ABAP
Werkstudent Softwareentwicklung · Fiori / UI5 · Consulting · Application Management
Ich habe manuell über mehrere Versionen das Wiki geupdated. Evtl. läuft es noch nicht ganz rund ツ
Eigene Fiori Push Benachrichtigungen erzeugen
Im Fiori Launchpad gibt es das Icon "Glocke". Hier werden alle Fiori Push Notifications angezeigt. Ziel dieses Wiki-Artikels ist es, dass man in der Lage ist dort eigene Meldungen anzeigen zu lassen.
Überblick der benötigten Objekte und Customizing
- Erstellung Y/Z Notification-Klasse
- Interface /iwngw/if_notif_provider
- Implementierung Methode /iwngw/if_notif_provider~get_notification_parameters
- Implementierung Methode /iwngw/if_notif_provider~get_notification_type
- Implementierung Methode /iwngw/if_notif_provider~get_notification_type_text
- Implementierung Methode /iwngw/if_notif_provider~handle_action
- Implementierung Methode send_notification
Erstellung Y/Z Notification-Klasse
Für Methode send_notification ist selber zu überlegen welche Paramater benötigt werden. Ebenso das Erfolgs/Fehler-Handling.
CLASS ycl_your_class_notifprov DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES /iwngw/if_notif_provider .
CONSTANTS mc_notification_provider_id TYPE /iwngw/notif_provider_id VALUE 'YMM_PUR_WE_MSG_PO_ITEM' ##NO_TEXT.
CONSTANTS:
BEGIN OF mc_notification_type,
general_gr TYPE /iwngw/notification_type_key VALUE 'GenGrForAPoItem',
gr_with_ref_to_sales_order TYPE /iwngw/notification_type_key VALUE 'SalesOrderGrForAPoItem',
END OF mc_notification_type.
CLASS-METHODS: send_notification
IMPORTING iv_purchaseorder TYPE I_PurchaseOrderAPI01-PurchaseOrder
EXPORTING ev_is_sending_successful TYPE abap_bool
ev_ex_msg TYPE string.
PROTECTED SECTION.
PRIVATE SECTION.
CLASS-DATA: _mt_parameters type /iwngw/if_notif_provider=>ty_t_notification_parameter.
ENDCLASS.
CLASS ycl_your_class_notifprov IMPLEMENTATION.
METHOD /iwngw/if_notif_provider~get_notification_parameters ##NEEDED.
CLEAR:et_parameter.
SET LANGUAGE iv_language.
LOOP AT _mt_parameters ASSIGNING FIELD-SYMBOL(<ls_para>).
MOVE-CORRESPONDING <ls_para> TO et_parameter.
ENDLOOP.
SET LANGUAGE lv_lang.
ENDMETHOD.
METHOD /iwngw/if_notif_provider~get_notification_type.
DATA ls_notif_action LIKE LINE OF et_notification_action ##NEEDED.
CLEAR es_notification_type.
CLEAR et_notification_action.
CASE iv_type_key.
WHEN mc_notification_type-general_gr.
es_notification_type-type_key = mc_notification_type-general_gr.
es_notification_type-version = 0.
es_notification_type-is_groupable = abap_true.
WHEN mc_notification_type-gr_with_ref_to_sales_order.
es_notification_type-type_key = mc_notification_type-gr_with_ref_to_sales_order.
es_notification_type-version = 0.
es_notification_type-is_groupable = abap_true.
WHEN OTHERS.
RAISE EXCEPTION TYPE /iwngw/cx_notif_provider.
ENDCASE.
ENDMETHOD.
METHOD /iwngw/if_notif_provider~get_notification_type_text.
DATA lv_tmp_text TYPE string.
CLEAR es_type_text.
CLEAR et_action_text.
SET LANGUAGE iv_language.
CASE iv_type_key.
WHEN mc_notification_type-general_gr.
lv_tmp_text = TEXT-100.
REPLACE '&1' WITH '{po}' INTO lv_tmp_text.
REPLACE '&2' WITH '{poitem}' INTO lv_tmp_text.
es_type_text-template_public = lv_tmp_text.
es_type_text-template_grouped = TEXT-101.
CLEAR lv_tmp_text.
lv_tmp_text = TEXT-102.
REPLACE '&1' WITH '{article}' INTO lv_tmp_text.
REPLACE '&2' WITH '{plant}' INTO lv_tmp_text.
es_type_text-subtitle = lv_tmp_text.
es_type_text-description = TEXT-103.
WHEN mc_notification_type-gr_with_ref_to_sales_order.
lv_tmp_text = TEXT-200.
REPLACE '&1' WITH '{po}' INTO lv_tmp_text.
REPLACE '&2' WITH '{poitem}' INTO lv_tmp_text.
REPLACE '&3' WITH '{so}' INTO lv_tmp_text.
es_type_text-template_public = lv_tmp_text.
es_type_text-template_grouped = TEXT-201.
CLEAR lv_tmp_text.
lv_tmp_text = TEXT-202.
REPLACE '&1' WITH '{article}' INTO lv_tmp_text.
REPLACE '&2' WITH '{plant}' INTO lv_tmp_text.
es_type_text-subtitle = lv_tmp_text.
es_type_text-description = TEXT-203.
WHEN OTHERS.
RAISE EXCEPTION TYPE /iwngw/cx_notif_provider.
ENDCASE.
ENDMETHOD.
METHOD /iwngw/if_notif_provider~handle_action.
CLEAR es_result.
* For now always return success if ids are set, since no persistence in this provider
IF iv_notification_id IS INITIAL.
es_result-success = abap_false.
ELSEIF iv_action_key IS INITIAL.
es_result-success = abap_false.
ELSE.
es_result-success = abap_true.
es_result-delete_on_return = abap_true.
ENDIF.
ENDMETHOD.
METHOD /iwngw/if_notif_provider~handle_bulk_action.
* no bulk notifications supported
CLEAR et_notif_result.
ENDMETHOD.
METHOD send_notification.
CLEAR _mt_parameters.
TRY.
DATA: lt_recipients type /iwngw/if_notif_provider=>ty_t_notification_recipient,
lt_parameters type /iwngw/if_notif_provider=>ty_t_notification_parameter,
lv_type_key type /iwngw/notification_type_key.
IF iv_so_creator IS INITIAL.
lt_recipients = VALUE #( ( id = iv_po_creator ) ).
_mt_parameters = VALUE #( ( name = 'po' value = iv_purchaseorder type = 'Edm.String' is_sensitive = abap_false )
( name = 'poitem' value = iv_poitem type = 'Edm.String' is_sensitive = abap_false )
( name = 'article' value = iv_product type = 'Edm.String' is_sensitive = abap_false )
( name = 'plant' value = iv_plant type = 'Edm.String' is_sensitive = abap_false ) ).
lv_type_key = mc_notification_type-general_gr.
ELSE.
lt_recipients = VALUE #( ( id = iv_po_creator ) ( id = iv_so_creator ) ).
_mt_parameters = VALUE #( ( name = 'po' value = iv_purchaseorder type = 'Edm.String' is_sensitive = abap_false )
( name = 'poitem' value = iv_poitem type = 'Edm.String' is_sensitive = abap_false )
( name = 'so' value = iv_salesorder type = 'Edm.String' is_sensitive = abap_false )
( name = 'article' value = iv_product type = 'Edm.String' is_sensitive = abap_false )
( name = 'plant' value = iv_plant type = 'Edm.String' is_sensitive = abap_false ) ).
lv_type_key = mc_notification_type-gr_with_ref_to_sales_order.
ENDIF.
/iwngw/cl_notification_api=>create_notifications(
EXPORTING
iv_provider_id = mc_notification_provider_id
it_notification = VALUE #( ( id = cl_uuid_factory=>create_system_uuid( )->create_uuid_x16( )
type_key = lv_type_key
type_version = '0'
priority = 'NEUTRAL'
navigation_parameters = VALUE #( ( name = 'MaterialDocument' value = iv_matdoc )
( name = 'MaterialDocumentYear' value = iv_matdoc_year )
( name = 'sap-fiori-id' value = 'F1077' )
( name = 'StockCHangeContext' value = '' )
( name = 'StockCHangeContext' value = '01' )
( name = 'StockChangeType' value = '05')
( name = 'sap-keep-alive' value = 'restricted' )
( name = 'MaterialDocumentItem' value = iv_matdoc_item ) )
navigation_target_object = 'MaterialDocument'
navigation_target_action = 'displayFactSheet'
recipients = lt_recipients
parameters = VALUE #( language = sy-datum
( parameters = _mt_parameters ) ) ) ) ).
CATCH cx_uuid_error INTO DATA(lrx_uuid_error).
ev_ex_msg = lrx_uuid_error->get_text( ).
RETURN.
CATCH /iwngw/cx_notification_api INTO DATA(lrx_api).
" HANDLE ERROR
ev_ex_msg = lrx_api->get_text( ).
RETURN.
ENDTRY.
ev_is_sending_successful = abap_true.
ENDMETHOD.
ENDCLASS.
adesso orange🍊Stellenangebote:
Software Engineer Trainee · Senior
| (Senior) Cloud Software Engineer BTP
(Senior) Consultant Technologie · Consultant ABAP
Werkstudent Softwareentwicklung · Fiori / UI5 · Consulting · Application Management