Skip to content

Instantly share code, notes, and snippets.

@fabianlupa
Created October 5, 2018 11:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabianlupa/ccb17f703817f03570be89adc08abc09 to your computer and use it in GitHub Desktop.
Save fabianlupa/ccb17f703817f03570be89adc08abc09 to your computer and use it in GitHub Desktop.
REPORT z_fl_atc_mail_test.
PARAMETERS: p_did TYPE satc_d_id.
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
METHODS:
run.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_main IMPLEMENTATION.
METHOD run.
DATA: li_mail_handler TYPE REF TO if_satc_ac_ui_email_handler,
lt_messages TYPE satc_t_ac__ui_message_headers,
lo_config TYPE REF TO object.
CREATE OBJECT lo_config TYPE ('\PROGRAM=SAPLSATC_AC_UI_EMAIL_CONF_DLG\CLASS=LCL_DISTRIBUTE_CONFIG').
CALL METHOD lo_config->('SET_SEND_TO_TYPE')
EXPORTING
i_send_to_type = if_satc_ac_distribute_config=>c_send_to-responsible.
CALL METHOD lo_config->('SET_ERROR_HANDLING_TYPE')
EXPORTING
i_error_handling_type = if_satc_ac_distribute_config=>c_error_handling-send_to.
CALL METHOD lo_config->('SET_SEND_TO_BY_ERROR')
EXPORTING
i_send_to_by_error = sy-uname.
DATA(lo_filter) = NEW cl_satc_ac__ui_vdct_filter_std( ).
lo_filter->if_satc_ac__ui_vdct_filter~set_criteria( VALUE cl_satc_ac__ui_vdct_filter_std=>ty_s_criteria(
prio_range = VALUE #( ( option = 'EQ' sign = 'I' low = 1 ) )
) ).
DATA(lo_model) = NEW cl_satc_ac__ui_vdct_model_std( ).
lo_model->init( i_display_id = p_did
i_filter = lo_filter ).
lo_model->if_satc_ac__ui_vdct_grid_model~get_headers(
EXPORTING
i_read_new = abap_false
IMPORTING
e_data = lt_messages
).
CALL FUNCTION 'SATC_AC_GET_EMAIL_HANDLER'
EXPORTING
i_handler_type = if_satc_ac_ui_email_handler=>c_handler_types-vdct_old
IMPORTING
e_email_handler = li_mail_handler.
DATA(lv_sendable) = li_mail_handler->init( i_messages = lt_messages
i_display_id = p_did
i_configuration = CAST #( lo_config )
i_display_title = 'ATC Benachrichtigung' ).
IF lv_sendable = abap_true.
li_mail_handler->send_emails( ).
ENDIF.
li_mail_handler->reset( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
NEW lcl_main( )->run( ).
@f4abap
Copy link

f4abap commented Jan 14, 2019

Just to give you soemthing back. With a 7.52 Release S4/HANA 1709 SP0 the send-part need some modification, because the function is not there anymore.

CALL FUNCTION 'SATC_AC_EMAIL_GET_HANDLER'
  EXPORTING
    i_handler_type  = if_satc_ac_ui_email_handler=>c_handler_types-finding
  IMPORTING
    e_email_handler = li_mail_handler.
TRY.
    li_mail_handler->init( i_messages      = lt_messages
                                               i_display_id    = p_did
                                               i_configuration = CAST #( lo_config )
                                               i_display_title = 'ATC Benachrichtigung' ).


    li_mail_handler->send_emails( ).

    li_mail_handler->reset( ).
  CATCH cx_satc_ac_root.
    li_mail_handler->reset( ).
ENDTRY.

@fabianlupa
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment