Foro de programación ABAP
SAP / ABAP => Formularios => Mensaje iniciado por: Neo_25 en 15 de Mayo de 2009, 02:20:16 pm
-
Hola otra vez.
Me gustaría mandar un Smartform convertido a PDF por email, a unas personas (campo a: del email) y a otras (campo cc: del email).
Tiene q ser así, no puedo juntar los emails.
Yo se crear el PDF y guardarlo en el disco duro. Pero eso no es lo q me piden, porque no tengo permisos de guardarlo en C: y lo tengo q guardar en Mis documentos ...
Pero bueno, aunque lo tuviera q crear en el disco duro, la pregunta es,
a que función le puedo meter el PDF y de manera independiente los que reciben el email en "a:" y en "c:".
Muchas gracias
-
Se puede hacer con: SO_NEW_DOCUMENT_SEND_API1
Pero limita el Asunto a 12 caracteres y el Cuerpo del email a 50.
He encontrado éste código, pero no se como anexar la tabla interna en la q tengo el PDF, si alguien me podría echar una mano por favor.
DATA : l_o_send_request TYPE REF TO cl_bcs, " email request object
l_o_document TYPE REF TO cl_document_bcs, " documents object
l_o_sender TYPE REF TO cl_cam_address_bcs, " sender object
l_o_recipient TYPE REF TO cl_cam_address_bcs, " recipient object
bcs_exception TYPE REF TO cx_bcs, " exceptions
l_v_ret TYPE os_boolean, " boolean return value
" document contents
l_it_contents TYPE bcsy_text,
l_wa_contents TYPE LINE OF bcsy_text,
" documents attachment
l_i_attachment TYPE solix_tab.
TRY.
" create email objects
l_o_send_request = cl_bcs=>create_persistent( ).
" sender
l_o_sender = cl_cam_address_bcs=>create_internet_address( 'emailaddressAsender.com' ).
l_o_send_request->set_sender( i_sender = l_o_sender ).
" recipient TO
l_o_recipient = cl_cam_address_bcs=>create_internet_address( 'emailtoArecipient.com' ).
l_o_send_request->add_recipient(
i_recipient = l_o_recipient
i_copy = '' " CC indicator).
" recipient CC
l_o_recipient = cl_cam_address_bcs=>create_internet_address( 'emailccArecipient.com' ).
l_o_send_request->add_recipient(
i_recipient = l_o_recipient
i_copy = 'X' " CC indicator).
" email contents
CLEAR l_wa_contents.
l_wa_contents-line = 'Dear Recipients,'.
APPEND l_wa_contents TO l_it_contents.
CLEAR l_wa_contents.
l_wa_contents-line = 'This in the contents attachments'.
APPEND l_wa_contents TO l_it_contents.
" create documents
l_o_document = cl_document_bcs=>create_document(
i_type = 'RAW' " RAW document format
i_text = l_it_contents
i_subject = 'This Is The Subject for Email With Attachment' ).
l_o_document->add_attachment(
i_attachment_type = 'PDF' " add PDF attachment
i_attachment_subject = 'PDF attachment'
i_att_content_hex = l_i_attachment ).
l_o_send_request->set_document( l_o_document ).
" send email
l_v_ret = l_o_send_request->send( ).
CATCH cx_bcs INTO bcs_exception. " exceptions, do something
ENDTRY.
COMMIT WORK. " never forget this one
-
El PDF lo obtengo así:
* saco los datos del smartform
DATA:
lfm_name TYPE rs38l_fnam,
lw_ctrlop TYPE ssfctrlop,
lw_compop TYPE ssfcompop,
lw_return TYPE ssfcrescl,
li_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
lv_len_in LIKE sood-objlen,
li_tline TYPE TABLE OF tline WITH HEADER LINE.
* llamo a mi smartform ZSGCF0001
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSGCF0001'
IMPORTING
fm_name = lfm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* para no verlo y que se marquen solos algunos botones
* para que se mande imprimir directamente
lw_ctrlop-getotf = 'X'.
lw_ctrlop-no_dialog = 'X'.
lw_compop-tdnoprev = 'X'.
* se visualizaría el smartform
CALL FUNCTION lfm_name
EXPORTING
control_parameters = lw_ctrlop
output_options = lw_compop
user_settings = 'X'
e_task = pi_e_task
e_object = pi_e_object
i_estimation = pi_i_estimation
i_text_detail = pi_i_text_detail
IMPORTING
job_output_info = lw_return
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
li_otf[] = lw_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = lv_len_in
TABLES
otf = li_otf
lines = li_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* tenemos los datos del smartform en la ***** li_tline *****
-
Existe un programa de ejemplo en SAP muy bueno que convierte una orden SPOOL a PDF y lo envía como adjunto por MAIL.
BCS_EXAMPLE_8