Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] Sachbearbeiter ermitteln

Bisher kenne ich keine “offizielle” Klasse der SAP für die Sachbearbeiterermittlung. Auf jedem System dafür eine neue Helper Klasse/Methode anzulegen finde ich aber auch nervig. Ich nutze daher diese Klasse aus dem Notification Tool Paket P99_NT, nicht optimal, erfüllt aber seinen Zweck.

    cl_hrpay00_nt_read_db=>get_admin_data( EXPORTING iv_pernr = pernr-pernr
                                           IMPORTING es_sacha = DATA(es_sacha)
                                                     ev_usrid = DATA(ev_usrid)
                                                     ev_sbmod = DATA(ev_sbmod)
                                                     es_p0001 = DATA(es_p0001) ).

[ABAP] Read E-Mail-Template

Addition to https://nocin.eu/abap-e-mail-templates-in-s-4hana/

I had to create an E-Mail template where I did not need a CDS view or any variable at all. I simply needed the defined mail template without any rendering of class cl_smtg_email_api.
Solution: Reading the plain mail template can be achieved using class cl_smtg_email_template and method get_tmpl_cont:

DATA(ls_mail_content) = cl_smtg_email_template=>get( p_mailtx )->get_tmpl_cont( iv_langu = 'D' ).

Full sample:

 PARAMETERS: p_mailtx TYPE smtg_tmpl_id OBLIGATORY.
   
 TRY.
        " get mail template
        DATA(ls_mail_content) = cl_smtg_email_template=>get( p_mailtx )->get_tmpl_cont( iv_langu = 'D' ).

        " optional: dynamic manipulation of html email body

        " create mail document
        DATA(lo_mail_document) = cl_document_bcs=>create_document( i_type    = 'HTM'
                                                                   i_subject = conv #( ls_mail_content-subject )
                                                                   i_text    = cl_bcs_convert=>string_to_soli( ls_mail_content-body_html ) ).

        " create Sender & Receiver
        DATA(lo_sender)    = cl_cam_address_bcs=>create_internet_address( i_address_string = 'noreply@example.com'
                                                                          i_address_name   = 'Test' ).

        DATA(lo_recipient) = cl_cam_address_bcs=>create_internet_address( i_address_string = 'max.mustermann@example.com').

        " create Business Communication Service
        DATA(lo_bcs) = cl_bcs=>create_persistent( ).
        lo_bcs->set_document( lo_mail_document ).
        lo_bcs->set_sender( lo_sender ).
        lo_bcs->add_recipient( lo_recipient ).
        lo_bcs->send( ).
        COMMIT WORK.

      CATCH cx_smtg_email_common INTO DATA(ls_cx).
        DATA(lv_message) = ls_cx->get_text( ).
        MESSAGE e899(id) WITH 'Unable to send message:'(004) lv_message.
    ENDTRY.

[Home Assistant] Update firmware on Sonoff Zigbee USB Dongle-P

Recently, I saw this video showing a super easy way to update the firmware of a SONOFF Zigbee Stick: https://www.youtube.com/watch?v=-_bE_PbZwO0

Just for reference, this was the way I did it previously: https://nocin.eu/home-assistant-update-firmware-on-sonoff-zigbee-usb-dongle-p/

Following just a few notes and screenshots, doing a firmware update using the SONOFF Dongle Flasher.

1. Optional: Check current firmware version

and compare with latest firmware version here

2. Do a backup

3. Stop Z2M and install the SONOFF Dongle Flasher

Install https://github.com/iHost-Open-Source-Project/hassio-ihost-addon

Start Add-on, open WebUI and hit the connect button. If your dongle is not found, simply manually add the device. The rest is pretty self-explanatory.

4. If flash was successful, stop SONOFF Dongle Flasher and Start Z2M again. Check new version in Z2M WebUI. And that’s it.