*&---------------------------------------------------------------------* *& Report Z_ITAB_MAIL *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT z_itab_mail. *Global Top CLASS: cl_abap_char_utilities DEFINITION LOAD. DATA: docdata TYPE sodocchgi1, gs_objpack TYPE sopcklsti1, it_objpack TYPE STANDARD TABLE OF sopcklsti1, it_objtxt TYPE STANDARD TABLE OF solisti1, it_objbin1 TYPE STANDARD TABLE OF solisti1, it_objbin2 TYPE STANDARD TABLE OF solisti1, it_objbin_final TYPE STANDARD TABLE OF solisti1, it_reclist TYPE STANDARD TABLE OF somlreci1, gs_objtxt TYPE solisti1, gs_objbin1 TYPE solisti1, gs_objbin2 TYPE solisti1, gs_objbin_final TYPE solisti1, gs_reclist TYPE somlreci1, tab_lines TYPE sy-tabix. DATA: gd_sender_type TYPE so_adr_typ. DATA: c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab, c_ret TYPE c VALUE cl_abap_char_utilities=>cr_lf. DATA: c_dev TYPE sy-sysid. TYPES: BEGIN OF i_data, a(20), b(20), END OF i_data. TYPES: BEGIN OF st, f1(2) TYPE c, f2(2) TYPE n, END OF st. DATA: it_itab1 TYPE STANDARD TABLE OF st, gs_itab1 TYPE st, it_itab2 TYPE STANDARD TABLE OF st, gs_itab2 TYPE st. DATA: n TYPE i. *Selection Screen PARAMETER: p_email1 TYPE so_recname DEFAULT 'admin@sapforbeginners.com', p_sender LIKE somlreci1-receiver. *Start of Selection START-OF-SELECTION. *Begin of preparing two internal tables with random data gs_itab1-f1 = 'Row1 Column1'. gs_itab1-f2 = 'Row1 Column2'. APPEND gs_itab1 TO it_itab1. CLEAR gs_itab1. gs_itab1-f1 = 'Row2 Column1'. gs_itab1-f2 = 'Row2 Column2'. APPEND gs_itab1 TO it_itab1. CLEAR gs_itab1. gs_itab1-f1 = 'Row3 Column1'. gs_itab1-f2 = 'Row3 Column2'. APPEND gs_itab1 TO it_itab1. CLEAR gs_itab1. gs_itab2-f1 = 'Row1 Column1'. gs_itab2-f2 = 'Row1 Column2'. APPEND gs_itab2 TO it_itab2. CLEAR gs_itab2. gs_itab2-f1 = 'Row2 Column1'. gs_itab2-f2 = 'Row2 Column2'. APPEND gs_itab2 TO it_itab2. CLEAR gs_itab2. gs_itab2-f1 = 'Row3 Column1'. gs_itab2-f2 = 'Row3 Column2'. APPEND gs_itab2 TO it_itab2. CLEAR gs_itab2. *End of internal table data LOOP AT it_itab1 INTO gs_itab1. CONCATENATE gs_itab1-f1 gs_itab1-f2 INTO gs_objbin1 SEPARATED BY c_tab. CONCATENATE c_ret gs_objbin1 INTO gs_objbin1. APPEND gs_objbin1 TO it_objbin1. ENDLOOP. CLEAR: gs_objbin1, gs_itab1. LOOP AT it_itab2 INTO gs_itab2. CONCATENATE gs_itab2-f1 gs_itab2-f2 INTO gs_objbin2 SEPARATED BY c_tab. CONCATENATE c_ret gs_objbin2 INTO gs_objbin2. APPEND gs_objbin2 TO it_objbin2. ENDLOOP. CLEAR: gs_objbin2, gs_itab2. LOOP AT it_objbin1 INTO gs_objbin1. MOVE gs_objbin1-line TO gs_objbin_final-line. APPEND gs_objbin_final TO it_objbin_final. ENDLOOP. CLEAR: gs_objbin_final, gs_objbin1. LOOP AT it_objbin2 INTO gs_objbin2. MOVE gs_objbin2-line TO gs_objbin_final-line. APPEND gs_objbin_final TO it_objbin_final. ENDLOOP. CLEAR: gs_objbin2, gs_objbin_final. PERFORM process_email. c_dev = sy-sysid. IF sy-sysid = c_dev. WAIT UP TO 5 SECONDS. SUBMIT rsconn01 WITH mode = 'INT' WITH output = 'X' AND RETURN. ENDIF. IF sy-subrc = 0. WRITE: / 'Email succesfilly delivered'. ELSE. WRITE: / 'Email could not be delivered'. ENDIF.
Send Internal Tables in an e-Mail as Excel attachments using Function Module
S
Introduction:
We are going to create a program that uses “SO_NEW_DOCUMENT_ATT_SEND_API1” function module to send two internal tables in an e-mail as separate excel attachments.
Explanation:
I am abstaining from writing any explanations on below snippet as it is a simple program and easy to understand. We build couple of internal tables and attach the two internal tables “IT_ITAB1” & “IT_ITAB2” as two separate excel attachments in the e-mail. The only part that you might be wondering is the use of the program “RSCONN01” and the program queues the email. Please feel free to comment below if you have any queries or issues in following the post.