FUNCTION zf_send_email.*"----------------------------------------------------------------------*"*"Interface local:*" IMPORTING*" VALUE(IM_SPOOL) TYPE RSPOID OPTIONAL*" VALUE(IM_EMAIL) TYPE AD_SMTPADR OPTIONAL*"----------------------------------------------------------------------* Bom dia Abapers, conforme prometido hoje vou mostrar uma funcao pratica* que envia o Spool em anexo para o email informado, os parametros de* importacao estao informadas acima, qualquer duvida comentem e vamos* aprendendo juntos, coloquei alguns Breaks no codigo para visualizarem* o processo.* A transacao para saber o Spool e a SP01 / SP02. DATA : lt_lines TYPE TABLE OF tline, lst_lines LIKE LINE OF lt_lines, l_rspoid TYPE rspoid, lst_tsp01 TYPE tsp01, l_objtype TYPE rststype-type, l_pdf_bytecount TYPE i, l_pdf_spoolid TYPE tsp01-rqident, l_btc_jobname TYPE tbtcjob-jobname, l_btc_jobcount TYPE tbtcjob-jobcount, l_xstring TYPE xstring, lt_soli_tab TYPE TABLE OF soli, " soli_tab lt_solix_tab TYPE TABLE OF solix, " solix_tab, l_size TYPE sood-objlen, lt_text TYPE TABLE OF solisti1, lst_text LIKE LINE OF lt_text, li_emails TYPE TABLE OF ad_smtpadr, lst_email TYPE ad_smtpadr, l_subject TYPE so_obj_des . DATA : lo_document TYPE REF TO cl_document_bcs, lo_bcs TYPE REF TO cl_bcs, lo_recipient TYPE REF TO if_recipient_bcs, lo_ex_bcs TYPE REF TO cx_bcs. BREAK-POINT.* Selecao para get dos detalhes do Spool Informado. SELECT SINGLE * FROM tsp01 INTO lst_tsp01 WHERE rqident = im_spool. IF sy-subrc IS INITIAL.* Funcao para get dos atributos do Spool, CALL FUNCTION 'RSTS_GET_ATTRIBUTES' EXPORTING* AUTHORITY = ' ' client = lst_tsp01-rqclient name = lst_tsp01-rqo1name IMPORTING objtype = l_objtype EXCEPTIONS fb_error = 1 fb_rsts_other = 2 no_object = 3 no_permission = 4 OTHERS = 5. IF sy-subrc IS INITIAL.* Inicio - Conversao SPOOL -> PDF IF l_objtype(3) = 'OTF'. CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF' EXPORTING src_spoolid = lst_tsp01-rqident no_dialog = space IMPORTING pdf_bytecount = l_pdf_bytecount pdf_spoolid = l_pdf_spoolid btc_jobname = l_btc_jobname btc_jobcount = l_btc_jobcount TABLES pdf = lt_lines[] EXCEPTIONS err_no_otf_spooljob = 1 err_no_spooljob = 2 err_no_permission = 3 err_conv_not_possible = 4 err_bad_dstdevice = 5 user_cancelled = 6 err_spoolerror = 7 err_temseerror = 8 err_btcjob_open_failed = 9 err_btcjob_submit_failed = 10 err_btcjob_close_failed = 11 OTHERS = 12. ELSE. CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF' EXPORTING src_spoolid = lst_tsp01-rqident no_dialog = space IMPORTING pdf_bytecount = l_pdf_bytecount pdf_spoolid = l_pdf_spoolid btc_jobname = l_btc_jobname btc_jobcount = l_btc_jobcount TABLES pdf = lt_lines[] EXCEPTIONS err_no_abap_spooljob = 1 err_no_spooljob = 2 err_no_permission = 3 err_conv_not_possible = 4 err_bad_destdevice = 5 user_cancelled = 6 err_spoolerror = 7 err_temseerror = 8 err_btcjob_open_failed = 9 err_btcjob_submit_failed = 10 err_btcjob_close_failed = 11 OTHERS = 12. ENDIF. CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE' TABLES content_in = lt_lines[] content_out = lt_soli_tab[] EXCEPTIONS err_line_width_src_too_long = 1 err_line_width_dst_too_long = 2 err_conv_failed = 3 OTHERS = 4. CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' EXPORTING input_length = l_pdf_bytecount IMPORTING buffer = l_xstring TABLES binary_tab = lt_soli_tab[] EXCEPTIONS failed = 1 OTHERS = 2. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = l_xstring TABLES binary_tab = lt_solix_tab. DESCRIBE TABLE lt_solix_tab LINES l_size. l_size = l_size * 255.* Fim - Conversao Spool PDF. BREAK-POINT.* Coloque dentro do TRY para nao dar DUMP durante o processo. TRY. IF im_email IS NOT INITIAL. SPLIT im_email AT ';' INTO TABLE li_emails.* Titulo do email l_subject = 'ABAP Juniores'.* Conteudo do email lst_text-line = 'Prezado,'. APPEND lst_text TO lt_text. CLEAR lst_text. APPEND lst_text TO lt_text. lst_text-line = 'Segue anexo o Spool conforme o Blog '. APPEND lst_text TO lt_text. lst_text-line = 'falou que iria funcionar'.