Skip to Content
Get the everyday’s failed message list of Integration Engine and send as an alert mail with attachment of failed message list as .csv file. Also work item to SAP-inbox with attachment. SAP-PI is having the facility of alert configuration. It triggers the alert immediately, when message is getting failed.  But one of my requirements is to get the everyday’s failed message list of Integration Engine and send as an alert mail with attachment and also work item to SAP-inbox with attachment. To archive this I have created a RFC to get the failed message list (also this can be used to get the all the status message like success, scheduled and failed). h3. *Step: 1 *

Create the Structure in ABAP dictionary.

image

 

*Step: 2*

Create RFC “ZZIXX_GET_FAILED_XI_MSG_LIST”, with specific import, export and table parameter as follows.

image

*Code of the RFC. * FUNCTION zzixx_get_failed_xi_msg_list . *”——————————————————————— *”*”Local Interface: *” IMPORTING *” VALUE(I_HOURLY_REPORT) TYPE CHAR1 DEFAULT ‘X’ *” VALUE(I_REPORT_DATE) TYPE SY-DATUM OPTIONAL *” VALUE(I_STATTYPE) TYPE SXMSPMSTAT_TYPE DEFAULT ‘4’ *” EXPORTING *” VALUE(E_EXECUTION_STATUS) TYPE CHAR1 *” VALUE(E_EXECUTION_STATUS_MSG) TYPE STRING *” VALUE(E_SYSID) TYPE SYST-SYSID *” VALUE(E_STATTYPE) TYPE SXMSPMSTAT_TYPE *” VALUE(E_STARTTIMESTAMP) TYPE STRING *” VALUE(E_ENDTIMESTAMP) TYPE STRING *” TABLES *” ET_MSGTAB STRUCTURE ZZSXMSMSGLST_S OPTIONAL *”——————————————————————— ******************************************************************* * PROGRAM ID : ZZALRT_GET_FAILED_XI_MSG_LIST * TITLE : Get FAILED XI message list * FO contact : Terri / Amit / Dhanabal * CREATE DATE : AUG-11-2009 * AUTHOR : Dhanabal * Project No. : *—————————————————————— * * DESCRIPTION : Get FAILED XI message list * *—————————————————————— * * CHANGE HISTORY *—————————————————————— * * DATE | NAME | DESCRIPTION | Reference *—————————————————————— * * Nov.16.2009| Dhanabal| Intial Creation |DPIK900018 ********************************************************************* *********************************************************************** * Constants * *********************************************************************** CONSTANTS : c_line_count TYPE int4 VALUE ‘2147483647’, c_col(1) TYPE c VALUE ‘:’. ************************************************************************ * Work Fields * ************************************************************************ DATA : w_date_start TYPE sy-datum, w_date_end TYPE sy-datum, w_exc_date TYPE sy-datum, w_time_start TYPE sy-uzeit, w_time_end TYPE sy-uzeit, w_exc_time TYPE sy-uzeit, w_sdatestr(30) TYPE c, w_stimestr(8) TYPE c. *********************************************************************** * Structure declaration * *********************************************************************** DATA: st_result TYPE sxmsadminresult, st_msgtab TYPE sxmsmsglst, st_msgtab_r TYPE zzsxmsmsglst_s . *********************************************************************** * Internal Table declaration * *********************************************************************** DATA: i_stat_tab_ko TYPE sxmspmstat_tab, i_msgtab TYPE sxmsmsgtab. * Assigning the system time w_exc_time = sy-timlo. * Checking Import variable report_date is initial or not. * if report_date is initial then assign the system date. IF i_report_date IS INITIAL. w_exc_date = sy-datlo. ELSE. w_exc_date = i_report_date. ENDIF. * Check if hourly_report ‘X’ then calculate the Start time (Present Time – 1 hour ) IF i_hourly_report EQ ‘X’. w_date_start = w_exc_date. w_date_end = w_exc_date. w_time_start = w_exc_time – ‘003600’. w_time_end = w_exc_time. IF w_time_start > w_time_end . w_date_start = w_exc_date – 1. ENDIF. ELSE. * Check if hourly_report ‘ ‘ then calculate the Start Date (Present Date – 1 Day ) w_date_start = w_exc_date – 1. w_date_end = w_exc_date. w_time_start = ‘000000’. w_time_end = w_exc_time. ENDIF. TRY. * Get the XI-Message from Local Integration Engine CALL METHOD cl_xms_persist_adm=>get_mstat_table EXPORTING im_stat_type = i_stattype IMPORTING ex_mstat_tab = i_stat_tab_ko. CALL FUNCTION ‘SXMB_SELECT_MESSAGES’ EXPORTING im_exedate = w_date_start im_exe2date = w_date_end im_exetime = w_time_start im_exe2time = w_time_end im_msgstate_tab = i_stat_tab_ko im_number = c_line_count IMPORTING ex_msgtab = i_msgtab ex_result = st_result. IF sy-subrc <> 0. e_execution_status = ‘E’. e_execution_status_msg = ‘Error in Execution’. ENDIF. IF i_msgtab IS NOT INITIAL. e_execution_status = ‘S’. * Assigning the XI message list in to Table Parameter of RFC. SORT i_msgtab BY mandt. LOOP AT i_msgtab INTO st_msgtab. CLEAR st_msgtab_r. MOVE-CORRESPONDING st_msgtab TO st_msgtab_r. APPEND st_msgtab_r TO et_msgtab. ENDLOOP. e_execution_status_msg = st_result-text. ELSE. e_execution_status = ‘N’. e_execution_status_msg = ‘No Messages found’. ENDIF. IF st_result-was_successful = ‘1’. * There is no Error…. ELSE. IF st_result-code = ‘too_many’. e_execution_status = ‘S’. e_execution_status_msg = ‘Too Many Records’. ELSE. e_execution_status = ‘E’. CONCATENATE st_result-code ‘ – ‘ st_result-text INTO e_execution_status_msg SEPARATED BY space. ENDIF. ENDIF. * Setting the value in Export variable. WRITE w_date_start TO w_sdatestr DD/MM/YYYY. REPLACE ALL OCCURRENCES OF ‘/’ IN w_sdatestr WITH ‘.’. CONCATENATE w_time_start+0(2) w_time_start+2(2) w_time_start+4(2) INTO w_stimestr SEPARATED BY c_col. CONCATENATE w_sdatestr w_stimestr sy-zonlo INTO w_sdatestr SEPARATED BY space. e_starttimestamp = w_sdatestr. WRITE w_date_end TO w_sdatestr DD/MM/YYYY. REPLACE ALL OCCURRENCES OF ‘/’ IN w_sdatestr WITH ‘.’. CLEAR w_stimestr. CONCATENATE w_time_end+0(2) w_time_end+2(2) w_time_end+4(2) INTO w_stimestr SEPARATED BY c_col. CONCATENATE w_sdatestr w_stimestr sy-zonlo INTO w_sdatestr SEPARATED BY space. e_endtimestamp = w_sdatestr. e_stattype = i_stattype. e_sysid = sy-sysid. CATCH cx_root. “#EC CATCH_ALL e_execution_status = ‘E’. e_execution_status_msg = ‘Error in Execution’. ENDTRY. ENDFUNCTION. We need to pass the following input to this RFC. ** If you want Daily report then pass ‘Y’ to I_HOURLY_REPORT else pass ‘X’ to I_HOURLY_REPORT ** Status type of the message to I_STATTYPE,   0.1.  ‘1’ – successfully Executed message 0.2. ‘3’ – Scheduled message 0.3. ‘4’ – Error Message h3. *Step: 3* Create a Report ‘ZZRXX_SEND_FAULT_MSG_ALRT_MAIL’. *&——————————————————————– * *& Report ZZRXX_SEND_FAULT_MSG_ALRT_MAIL *& *&——————————————————————– * *& *& *&——————————————————————– * REPORT zzrxx_send_fault_msg_alrt_mail. ******************************************************************* * PROGRAM ID : ZZRXX_SEND_FAULT_MSG_ALRT_MAIL * TITLE : Get FAILED XI message List and send the mail * CREATE DATE : AUG-11-2009 * AUTHOR : Dhanabal * Project No. : *—————————————————————— * * DESCRIPTION : Get FAILED XI message List and send the mail * *—————————————————————— * * CHANGE HISTORY *—————————————————————— * * DATE | NAME | DESCRIPTION | Reference *—————————————————————— * * Nov.16.2009| Dhanabal| Intial Creation | DPIK900018 ********************************************************************* ************************************************************************ * Types Pools ************************************************************************ TYPE-POOLS: sscr. ************************************************************************ * Types ************************************************************************ * Attachment File Type. TYPES : BEGIN OF ty_msgtab, rowno TYPE string, mandt TYPE zzsxmsmsglst_s-mandt, msgguid TYPE zzsxmsmsglst_s-msgguid, qosmode TYPE zzsxmsmsglst_s-qosmode, inittimest TYPE zzsxmsmsglst_s-inittimest, adapt_typ TYPE zzsxmsmsglst_s-adapt_typ, ob_system TYPE zzsxmsmsglst_s-ob_system, ob_ns TYPE zzsxmsmsglst_s-ob_ns, ob_name TYPE zzsxmsmsglst_s-ob_name, errcat TYPE zzsxmsmsglst_s-errcat, errcode TYPE zzsxmsmsglst_s-errcode, END OF ty_msgtab . ************************************************************************ * Constants ************************************************************************ * Constants for Header line in the attachment. CONSTANTS: c_rowno TYPE string VALUE ‘S.No’, c_mandt TYPE string VALUE ‘Client’, c_msgguid TYPE string VALUE ‘XI: Message ID’, c_qosmode TYPE string VALUE ‘QoS’, c_inittimest TYPE string VALUE ‘Exec.TimeStamp’, c_adapt_typ TYPE string VALUE ‘Service Type’, c_ob_system TYPE string VALUE ‘Sending System’, c_ob_ns TYPE string VALUE ‘Outbound Interface Namespace’, c_ob_name TYPE string VALUE ‘Outbound Interface Name’, c_errcat TYPE string VALUE ‘XI: Error Category’, c_errcode TYPE string VALUE ‘XI: Error ID’. * Constant for sending the input to RFC. CONSTANTS: c_stattype(1) TYPE c VALUE ‘4’, c_eq(2) TYPE c VALUE ‘EQ’, c_x(1) TYPE c VALUE ‘X’, c_s(1) TYPE c VALUE ‘S’, c_i(1) TYPE c VALUE ‘I’, c_s_email(7) TYPE c VALUE ‘S_EMAIL’, c_s_suser(7) TYPE c VALUE ‘S_SUSER’. ************************************************************************ * Work Fields * ************************************************************************ DATA: w_execution_status(1) TYPE c, w_execution_status_msg TYPE string, w_sysid TYPE syst-sysid, w_stattype TYPE sxmspmstat_type, w_starttimestamp TYPE string, w_endtimestamp TYPE string, w_hourly_r(1) TYPE c VALUE ‘X’, w_filename TYPE string, w_email TYPE adr6-smtp_addr, w_suser TYPE usr02-bname. *********************************************************************** * Structure declaration * *********************************************************************** DATA : st_msgtab TYPE ty_msgtab, st_tmsgtab TYPE zzsxmsmsglst_s. *********************************************************************** * Internal Table declaration * *********************************************************************** DATA : t_msgtab TYPE STANDARD TABLE OF ty_msgtab, i_tmsgtab TYPE STANDARD TABLE OF zzsxmsmsglst_s. *——————————————————————– * * S E L E C T I O N – S C R E E N. *——————————————————————– * SELECTION-SCREEN BEGIN OF BLOCK bl1. SELECTION-SCREEN ULINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 5. SELECTION-SCREEN COMMENT 7(40) comm_st1. SELECT-OPTIONS: s_email FOR w_email NO INTERVALS. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 5. SELECTION-SCREEN COMMENT 7(40) comm_st2. SELECT-OPTIONS: s_suser FOR w_suser NO INTERVALS. . SELECTION-SCREEN END OF LINE. SELECTION-SCREEN ULINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 2. SELECTION-SCREEN COMMENT 4(47) comm_st3. PARAMETERS p_dailyt RADIOBUTTON GROUP rb DEFAULT ‘X’ USER-COMMAND radio. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 2. SELECTION-SCREEN COMMENT 4(47) comm_st4. PARAMETERS p_hourst RADIOBUTTON GROUP rb. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN ULINE. SELECTION-SCREEN END OF BLOCK bl1. *——————————————————————– * * S E L E C T I O N – S C R E E N-INITIALIZATION. *——————————————————————– * INITIALIZATION. *********************************************************************** * Structure declaration * *********************************************************************** DATA: st_selopt TYPE sscr_***, st_opt_list TYPE sscr_opt_list. *********************************************************************** * Internal Table declaration * *********************************************************************** DATA: i_restrict TYPE sscr_restrict. s_email-low = ‘dhanabal.thangavel@atosorigin.com‘. s_email-option = ‘EQ’. s_email-sign = ‘I’. APPEND s_email. CLEAR st_opt_list. st_opt_list-name = c_eq. st_opt_list-options-eq = c_x. APPEND st_opt_list TO i_restrict-opt_list_tab. CLEAR st_selopt. st_selopt-kind = c_s. st_selopt-name = c_s_email. st_selopt-sg_main = c_i. st_selopt-sg_addy = ‘ ‘. st_selopt-op_main = c_eq. st_selopt-op_addy = c_eq. APPEND st_selopt TO i_restrict-***_tab. CLEAR st_opt_list. st_opt_list-name = c_eq. st_opt_list-options-eq = c_x. APPEND st_opt_list TO i_restrict-opt_list_tab. s_suser-low = ‘DTHANG’. s_suser-option = c_eq. s_suser-sign = c_i. APPEND s_suser. CLEAR st_selopt. st_selopt-kind = c_s. st_selopt-name = c_s_suser. st_selopt-sg_main = c_i. st_selopt-sg_addy = ‘ ‘. st_selopt-op_main = c_eq. st_selopt-op_addy = c_eq. APPEND st_selopt TO i_restrict-***_tab. CLEAR st_opt_list. st_opt_list-name = c_eq. st_opt_list-options-eq = c_x. CALL FUNCTION ‘SELECT_OPTIONS_RESTRICT’ EXPORTING restriction = i_restrict EXCEPTIONS too_late = 1 repeated = 2 selopt_without_options = 5 selopt_without_signs = 6 invalid_sign = 7 empty_option_list = 9 invalid_kind = 10 repeated_kind_a = 11 OTHERS = 12. *——————————————————————– * * AT SELECTION SCREEN OUTPUT *——————————————————————– * AT SELECTION-SCREEN OUTPUT. comm_st1 = ‘E-Mail Recipient :’. comm_st2 = ‘SAP-User Recipient (SAP-Mail Box) :’. comm_st3 = ‘Send Alert of Failed Messages in last 1 Day :’. comm_st4 = ‘Send Alert of Failed Messages in last 1 Hour :’. *——————————————————————– * * S T A R T – O F – S E L E C T I O N. *——————————————————————– * START-OF-SELECTION. w_hourly_r = p_hourst. PERFORM f_get_fault_msg_list. IF w_execution_status = ‘S’ AND w_stattype EQ ‘4’. PERFORM f_send_fault_msg_alrt_mail. ELSEIF w_execution_status NE ‘S’. WRITE: / w_execution_status_msg. ELSEIF w_execution_status = ‘S’ AND w_stattype NE ‘4’. WRITE: / ‘There is no error message, but’ , w_execution_status_msg. ENDIF. *&——————————————————————– * *& Form f_get_fault_msg_list *&——————————————————————– * * DESCRIPTION : Getting fault message list from integration engine *——————————————————————— * FORM f_get_fault_msg_list. CALL FUNCTION ‘ZZIXX_GET_FAILED_XI_MSG_LIST’ EXPORTING i_hourly_report = w_hourly_r * I_REPORT_DATE = i_stattype = c_stattype IMPORTING e_execution_status = w_execution_status e_execution_status_msg = w_execution_status_msg e_sysid = w_sysid e_stattype = w_stattype e_starttimestamp = w_starttimestamp e_endtimestamp = w_endtimestamp TABLES et_msgtab = i_tmsgtab. LOOP AT i_tmsgtab INTO st_tmsgtab. MOVE-CORRESPONDING st_tmsgtab TO st_msgtab. st_msgtab-rowno = sy-tabix. APPEND st_msgtab TO t_msgtab. CLEAR st_msgtab . ENDLOOP. ENDFORM. ” f_get_fault_msg_list *&——————————————————————– * *& Form f_send_fault_msg_alrt_mail *&——————————————————————– * * DESCRIPTION : Sending alert mail with * fault message list as an attachment (.csv file) *——————————————————————— * FORM f_send_fault_msg_alrt_mail. ************************************************************************ * Types ************************************************************************ TYPES: BEGIN OF ty_dload, dload(1000) , END OF ty_dload . TYPES: BEGIN OF ty_email_list, sign(1), option(2), low TYPE adr6-smtp_addr, END OF ty_email_list. TYPES: BEGIN OF ty_suser_list, sign(1), option(2), low TYPE usr02-bname, END OF ty_suser_list. ************************************************************************ * CONSTANTS ************************************************************************ CONSTANTS: c_x(1) TYPE c VALUE ‘X’, c_csv(3) TYPE c VALUE ‘CSV’, c_raw(3) TYPE c VALUE ‘RAW’, c_objname(10) TYPE c VALUE ‘ALERT’, c_u(1) TYPE c VALUE ‘U’, c_b(1) TYPE c VALUE ‘B’, c_int(3) TYPE c VALUE ‘INT’. ************************************************************************ * WORK FIELD ************************************************************************ DATA : w_longtext(255) TYPE c, w_linestring(255) TYPE c, w_strnum(15) TYPE c, w_tab_lines TYPE sy-tabix. ************************************************************************ * WORK AREA ************************************************************************ DATA: st_dload TYPE ty_dload, st_doc_chng TYPE sodocchgi1, st_objtxt TYPE solisti1, st_reclist TYPE somlreci1, st_objbin TYPE solisti1, st_objpack TYPE sopcklsti1, st_holder TYPE solisti1, st_email_list TYPE ty_email_list, st_suser_list TYPE ty_suser_list. ************************************************************************ * INTERNAL TABLE ************************************************************************ DATA: i_objpack TYPE STANDARD TABLE OF sopcklsti1, i_objbin TYPE STANDARD TABLE OF solisti1, i_finobjbin TYPE STANDARD TABLE OF solisti1, i_objtxt TYPE STANDARD TABLE OF solisti1 , i_reclist TYPE STANDARD TABLE OF somlreci1, i_holder TYPE STANDARD TABLE OF solisti1. ************************************************************************ * FIELD SYMBOL ************************************************************************ FIELD-SYMBOLS: TYPE ANY. CLASS cl_abap_char_utilities DEFINITION LOAD. *setting name of file for csv attachment. CONCATENATE ‘Error_Report_’ w_starttimestamp ‘_To_’ w_endtimestamp ‘.csv’ INTO w_filename . *check Email input is empty or not. IF ( s_email IS NOT INITIAL ) OR ( s_suser IS NOT INITIAL ). *–Get receipient address CLEAR i_reclist. *—passing e_mail address LOOP AT s_email INTO st_email_list. CLEAR st_reclist. st_reclist-receiver = st_email_list-low. st_reclist-rec_type = c_u. st_reclist-express = ‘ ‘. st_reclist-com_type = c_int. APPEND st_reclist TO i_reclist. ENDLOOP. *—passing e_mail address LOOP AT s_suser INTO st_suser_list. CLEAR st_reclist. st_reclist-receiver = st_suser_list-low. st_reclist-rec_type = c_b. st_reclist-express = c_x. st_reclist-com_type = c_int. APPEND st_reclist TO i_reclist. ENDLOOP. * Build body of message IF w_hourly_r = ‘X’. CONCATENATE ‘**** Hourly Status Report of Failed XI-Messages < From ‘ w_starttimestamp ‘ To ‘ w_endtimestamp ‘> ****’ INTO st_objtxt SEPARATED BY space. ELSE. CONCATENATE ‘**** Daily Status Report of Failed XI-Messages < From ‘ w_starttimestamp ‘ To ‘ w_endtimestamp ‘> ****’ INTO st_objtxt SEPARATED BY space. ENDIF. APPEND st_objtxt TO i_objtxt. CLEAR st_objtxt. APPEND st_objtxt TO i_objtxt. APPEND st_objtxt TO i_objtxt. DESCRIBE TABLE t_msgtab LINES w_tab_lines. w_strnum = w_tab_lines. CONDENSE w_strnum. IF w_tab_lines > 1. CONCATENATE ‘There are “‘ w_strnum ‘” Messages failed in the Integration Engine.’ ‘For further analysis, use SXMB_MONI T-Code.’ INTO st_objtxt SEPARATED BY space. ELSE. CONCATENATE ‘There is “‘ w_strnum ‘” Message failed in the Integration Engine.’ ‘For further analysis, use SXMB_MONI T-Code.’ INTO st_objtxt SEPARATED BY space. ENDIF. APPEND st_objtxt TO i_objtxt. CLEAR st_objtxt. CONCATENATE ‘ For ‘ w_strnum ‘ Messages are failed in the Integration Engine.’ INTO st_objtxt SEPARATED BY space. CONCATENATE ‘ For further assistance, contact your XI Specialist….’ ‘ Please find the attached report in this mail.’ INTO st_objtxt SEPARATED BY space. . APPEND st_objtxt TO i_objtxt. CLEAR st_objtxt. APPEND st_objtxt TO i_objtxt. CONCATENATE ‘By,’ cl_abap_char_utilities=>cr_lf ‘XI-Alert Management System.’ INTO st_objtxt SEPARATED BY space. APPEND st_objtxt TO i_objtxt. CLEAR st_objtxt. *–Set title of object and email IF w_hourly_r = ‘X’. CONCATENATE ‘Hourly Status Report of Failed XI-Messages on’ sy-sysid ‘ (‘ sy-mandt ‘).’ INTO st_doc_chng-obj_descr SEPARATED BY space. ELSE. CONCATENATE ‘Daily Status Report of Failed XI-Messages on’ sy-sysid ‘ (‘ sy-mandt ‘).’ INTO st_doc_chng-obj_descr SEPARATED BY space. ENDIF. st_doc_chng-obj_name = ‘INBOUND’. DESCRIBE TABLE i_objtxt LINES w_tab_lines. READ TABLE i_objtxt INTO st_objtxt INDEX w_tab_lines. st_doc_chng-doc_size = ( w_tab_lines – 1 ) * 255 + STRLEN( st_objtxt ). *–Move the Report Name as the Heading line for email file CLEAR: w_longtext. CONCATENATE ‘**** FAILED MESSAGE REPORT < ‘ w_starttimestamp ‘ To ‘ w_endtimestamp ‘> ****’ INTO w_longtext SEPARATED BY space. st_objbin = w_longtext. APPEND st_objbin TO i_objbin. CLEAR st_objbin. CONCATENATE ‘System Details ‘ sy-sysid ‘(‘ sy-mandt ‘)’ INTO w_longtext SEPARATED BY space. st_objbin = w_longtext. st_objbin = w_longtext. APPEND st_objbin TO i_objbin. CLEAR st_objbin. CONCATENATE ‘Report Generated on ‘ w_endtimestamp INTO w_longtext SEPARATED BY space. st_objbin = w_longtext. APPEND st_objbin TO i_objbin. CLEAR st_objbin. APPEND st_objbin TO i_objbin. CLEAR st_objbin. * —appending heading to Internal table of Email CONCATENATE c_rowno c_mandt c_msgguid c_qosmode c_inittimest c_adapt_typ c_ob_system c_ob_ns c_ob_name c_errcat c_errcode INTO w_longtext SEPARATED BY ‘,’. st_objbin = w_longtext. APPEND st_objbin TO i_objbin. CLEAR st_objbin. DATA wa_le TYPE i. LOOP AT t_msgtab INTO st_msgtab. DO. ASSIGN COMPONENT sy-index OF STRUCTURE st_msgtab TO 0. CLEAR st_holder. LOOP AT i_holder INTO st_holder. IF st_holder IS NOT INITIAL. w_linestring = st_holder. CONDENSE w_linestring . ELSE. w_linestring = ‘–‘. ENDIF. IF sy-tabix = 1. st_dload-dload = w_linestring. SHIFT: st_dload-dload LEFT DELETING LEADING space. ELSE. * Put Comma as a separator for values in IT_DLOAD internal table wa_le = STRLEN( st_dload-dload ) + STRLEN( w_linestring ). IF wa_le cr_lf. CONCATENATE w_longtext ‘$,’ INTO w_longtext. LOOP AT i_objbin INTO st_objbin. REPLACE ALL OCCURRENCES OF w_longtext IN st_objbin-line WITH ‘,’. APPEND st_objbin TO i_finobjbin. CLEAR st_objbin. ENDLOOP. * create the control table entry for the main email DESCRIBE TABLE i_objtxt LINES w_tab_lines. CLEAR st_objpack. st_objpack-head_start = 1. st_objpack-head_num = 0. st_objpack-body_start = 1. st_objpack-body_num = w_tab_lines. st_objpack-doc_type = c_raw. APPEND st_objpack TO i_objpack. DESCRIBE TABLE i_finobjbin LINES w_tab_lines. st_objpack-head_start = 1. st_objpack-head_num = 0. st_objpack-body_start = 1. st_objpack-body_num = w_tab_lines. st_objpack-transf_bin = c_x. st_objpack-doc_type = c_csv. st_objpack-obj_descr = w_filename. st_objpack-obj_name = c_objname. st_objpack-doc_size = w_tab_lines * 1000. APPEND st_objpack TO i_objpack. CALL FUNCTION ‘SO_NEW_DOCUMENT_ATT_SEND_API1’ EXPORTING document_data = st_doc_chng put_in_outbox = c_x commit_work = c_x TABLES packing_list = i_objpack * object_header = contents_bin = i_finobjbin contents_txt = i_objtxt receivers = i_reclist EXCEPTIONS too_many_receivers = 1 document_not_sent = 2 operation_no_authorization = 4 OTHERS = 99. IF sy-subrc <> 0. WRITE: / ‘failure in sending mail’. ELSE. WRITE: / ‘Success in sending mail.. Error ‘ , w_execution_status_msg , ‘< ‘, w_starttimestamp , ‘ To ‘ , w_endtimestamp , ‘>’. ENDIF. else. WRITE: / ‘Please give the recipient as input to either email or sap-user’. ENDIF. ENDFORM. ” f_send_fault_msg_alrt_mail Report UI looks like as follows, You have to give E-mail list and SAP-UserID. image

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Naresh Nelapatla
    After sending the mail each line of the internal table is coming in one cell.

    Suppose if i have 4 lines in internal table then first cell of each column is filling with each line.

    Normally each cell should contain one field from internal table.

    (0) 

Leave a Reply