|
#1
|
|||
|
|||
Problema al adjuntar pdf a mail..
Hola !!! Tengo un problemita con el envío de mails...
El usuario quiere que cada vez que se grabe un pedido de compras (ME21N y ME22N) se envíe un mail a una persona con el pedido en formato PDF. He metido una función en una exit que a su vez llama a un report. Este report lo que hace es, en fondo, crearme la orden de spool y -se supone- pasarlo a PDF y después adjuntarlo al mail para enviarlo posteriormente. El mail se envía correctamente con el PDF adjunto pero al abrirlo con Acrobat me da un mensaje de "Se ha producido un error de dibujo", le doy a aceptar, se ve el pedido pero si muevo el scroll pierdo el pedido.. Pasa lo mismo incluso aunque lo baje al pc... Adjunto mi código por si a alguien se le ocurre qué puede ser.. Gracias de antemano !!! FORM enviar_mail . DATA: t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE. PERFORM impresora. CLEAR: it_receivers, it_object_content, doc_chng, objpack, objhead, objbin, objtxt. REFRESH: it_receivers, it_object_content, objpack, objhead, objbin, objtxt. * Obtener adjunto PERFORM adjunto. * Informar destinatario del mail PERFORM obtener_destinatario. * Informar cuerpo del mail PERFORM montar_html USING p_lifnr p_ebeln p_cod. doc_chng-obj_name = 'Envio Pedido N'. doc_chng-obj_descr = 'Envío pedido D'. DESCRIBE TABLE objtxt LINES tab_lines. doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ). dir_mail_emisor = sy-uname. objhead = 'Envío mail'. APPEND objhead. CLEAR doc_chng. doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ). doc_chng-obj_langu = sy-langu. doc_chng-obj_name = 'Envio Pedido N'. doc_chng-obj_descr = 'Envío pedido D'. doc_chng-sensitivty = 'F'. CLEAR objbin. REFRESH objbin. objbin[] = it_mess_att[]. DESCRIBE TABLE objbin LINES tab_lines. * Carga del registro que configura el mail PERFORM cargar_registro. DESCRIBE TABLE objbin LINES tab_lines. objpack-transf_bin = 'X'. objpack-body_num = tab_lines. objpack-doc_type = 'PDF'. objpack-doc_size = pbyte. MOVE objhead TO objpack-obj_descr. MOVE objhead TO objpack-obj_name. objpack-doc_size = tab_lines * 255. APPEND objpack. CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' EXPORTING document_data = doc_chng TABLES packing_list = objpack object_header = objhead contents_bin = objbin contents_txt = objtxt receivers = it_receivers EXCEPTIONS too_many_receivers = 1 document_not_sent = 2 document_type_not_exist = 3 operation_no_authorization = 4 parameter_error = 5 x_error = 6 enqueue_error = 7 OTHERS = 8. IF sy-subrc = 0. COMMIT WORK. ENDIF. ENDFORM. " ENVIAR_MAIL *&---------------------------------------------------------------------* *& Form IMPRESORA *&---------------------------------------------------------------------* FORM impresora . CALL FUNCTION 'GET_PRINT_PARAMETERS' EXPORTING authority = space copies = '1' cover_page = space data_set = space department = space destination = 'LOCL' expiration = '1' immediately = space * in_archive_parameters = space * in_parameters = space layout = space mode = space new_list_id = 'X' no_dialog = 'X' user = sy-uname IMPORTING out_parameters = mstr_print_parms valid = mc_valid EXCEPTIONS archive_info_not_found = 1 invalid_print_params = 2 invalid_archive_params = 3 OTHERS = 4. IF mstr_print_parms-pdest = space. mstr_print_parms-pdest = 'LOCL'. ENDIF. mstr_print_parms-linsz = 180. mstr_print_parms-paart = 'X_65_180'. ENDFORM. " IMPRESORA *&---------------------------------------------------------------------* *& Form ADJUNTO *&---------------------------------------------------------------------* * Obtener PDF y adjuntar *----------------------------------------------------------------------* FORM adjunto . DATA: v_len LIKE sy-index, v_long LIKE sy-index, v_queda LIKE sy-index, v_offset LIKE sy-index. SELECT * FROM nast WHERE kappl = 'EF' AND kschl = 'NEU' AND objky = p_ebeln. ENDSELECT. IF sy-subrc = 0. * Se buscan las órdenes spool correspondientes a los nº de documento * que vamos a tratar, y se actualizan en las tablas de tratamiento, para * luego generar los ficheros PDF PERFORM buscar_spool USING p_ebeln. ** Se genera un fichero PDF por cada uno de los documentos a tratar * PERFORM imprimir_pdf USING p_ebeln. IF sy-subrc = 0. CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF' EXPORTING src_spoolid = gv_spool IMPORTING pdf_bytecount = pbyte TABLES pdf = it_pdf_output. LOOP AT it_pdf_output. TRANSLATE it_pdf_output USING ' ~'. CONCATENATE v_buffer it_pdf_output INTO v_buffer. ENDLOOP. TRANSLATE v_buffer USING '~ '. DO. it_mess_att = v_buffer. APPEND it_mess_att. SHIFT v_buffer LEFT BY 255 PLACES. IF v_buffer IS INITIAL. EXIT. ENDIF. ENDDO. ENDIF. ENDIF. ENDFORM. " ADJUNTO *&---------------------------------------------------------------------* *& Form CARGAR_REGISTRO *&---------------------------------------------------------------------* * Carga del registro que configura el mail *----------------------------------------------------------------------* FORM cargar_registro . CLEAR objpack-transf_bin. objpack-transf_bin = ''. objpack-head_start = 1. objpack-head_num = 0. objpack-body_start = 1. objpack-body_num = tab_lines. objpack-doc_type = 'HTM'. objpack-obj_descr = doc_chng-obj_descr. APPEND objpack. objhead = 'Envío mail'. ENDFORM. " CARGAR_REGISTRO |
#2
|
||||
|
||||
Yo tenia mas o menos el mismo error esta rutina te puede ayudar con tu problema.
form send_file_as_email_attachment tables it_message it_attach using p_mtitle p_format p_filename p_attdescription p_sender_address p_sender_addres_type changing p_error p_reciever. data: ld_error type sy-subrc, ld_reciever type sy-subrc, ld_mtitle like sodocchgi1-obj_descr, ld_format type so_obj_tp , ld_attdescription type so_obj_nam , ld_attfilename type so_obj_des , ld_sender_address like soextreci1-receiver, ld_sender_address_type like soextreci1-adr_typ, ld_receiver like sy-subrc. data: t_packing_list like sopcklsti1 occurs 0 with header line, t_contents like solisti1 occurs 0 with header line, t_attachment like solisti1 occurs 0 with header line, t_object_header like solisti1 occurs 0 with header line, w_cnt type i, w_sent_all(1) type c, w_doc_data like sodocchgi1. ld_mtitle = p_mtitle. ld_format = p_format. ld_attdescription = p_attdescription. ld_attfilename = p_filename. ld_sender_address = p_sender_address. ld_sender_address_type = p_sender_addres_type. * Fill the document data. w_doc_data-doc_size = 1. * Populate the subject/generic message attributes w_doc_data-obj_langu = sy-langu. w_doc_data-obj_name = 'SAPRPT'. w_doc_data-obj_descr = ld_mtitle . w_doc_data-sensitivty = 'F'. * Fill the document data and get size of attachment clear w_doc_data. read table it_attach index w_cnt. w_doc_data-doc_size = ( w_cnt - 1 ) * 255 + strlen( it_attach ). w_doc_data-obj_langu = sy-langu. w_doc_data-obj_name = 'SAPRPT'. w_doc_data-obj_descr = ld_mtitle. w_doc_data-sensitivty = 'F'. clear t_attachment. refresh t_attachment. t_attachment[] = it_attach[]. * Describe the body of the message clear t_packing_list. refresh t_packing_list. t_packing_list-transf_bin = space. t_packing_list-head_start = 1. t_packing_list-head_num = 0. t_packing_list-body_start = 1. describe table it_message lines t_packing_list-body_num. t_packing_list-doc_type = 'RAW'. append t_packing_list. * Create attachment notification t_packing_list-transf_bin = 'X'. t_packing_list-head_start = 1. t_packing_list-head_num = 1. t_packing_list-body_start = 1. describe table t_attachment lines t_packing_list-body_num. t_packing_list-doc_type = 'PDF'. t_packing_list-obj_descr = ld_attdescription. t_packing_list-obj_name = ld_attfilename. t_packing_list-doc_size = t_packing_list-body_num. " * 255. append t_packing_list. call function 'SO_DOCUMENT_SEND_API1' exporting document_data = w_doc_data put_in_outbox = 'X' sender_address = ld_sender_address sender_address_type = ld_sender_address_type commit_work = 'X' importing sent_to_all = w_sent_all tables packing_list = t_packing_list contents_bin = t_attachment contents_txt = it_message receivers = t_receivers exceptions too_many_receivers = 1 document_not_sent = 2 document_type_not_exist = 3 operation_no_authorization = 4 parameter_error = 5 x_error = 6 enqueue_error = 7 others = 8. * Populate zerror return code ld_error = sy-subrc. * Populate zreceiver return code loop at t_receivers. ld_receiver = t_receivers-retrn_code. endloop. endform. "send_file_as_email_attachment
__________________
Cordialmente Fabián Leonardo Velásquez P. Consultor SAP ABAP Bogota - Colombia |
#3
|
|||
|
|||
hola !! muchas gracias por la respuesta, voy a ver si le echo un ojo antes de cambiar todo porque bastante me ha costado que funcione así que no sólo de pensar en cambiar la función y todo.. uuuffff
Nada, he probado con lo tuyo y sigue dándome ese error.... Úlima edición por poketina fecha: 04/08/10 a las 07:56:08. |
#4
|
|||
|
|||
Bueno, por lo que he visto, el fallo que me da puede ser del logo que viene incluido en el sapscript...
Esto por un lado.. y ahora veo que si yo cambio algo en el pedido (por ejemplo la cantidad), no se me genera nueva orden de spool sino q me sigue mostrando siempre la orden de spool anterior.. Cómo puedo hacer para que al graabar el pedido se me genere una nueva orden de spool ???? gracias !!!! |
#5
|
|||
|
|||
Hola de nuevo..
He conseguido que me adjunte bien el pdf al mail pero ahora tengo un problema.. Yo estoy lo estoy haciendo desde el método POSTED de la badi ME_PURCHDOC_POSTED, cada vez que se le da a grabar un pedido. El caso es que yo dentro de mi programa, para crearme la orden de spool llamo a la transacción ME9F, pero no me genera nueva orden de spool porque me dice que el pedido XXX está abierto.. Cómo puedo hacer para que me la genere ?? Gracias !! |
#6
|
||||
|
||||
Eso es del SMARTFORM
Hola.
Espero que no llegue tarde la respuesta. Imagino que haces un smartform, lo conviertes a PDF y luego creas el mail. La spool se crea al crear el Smartform, y no te crea una nueva por algún parámetro que le indicas. Posteala, ahora de memoria no me acuerdo cual es. Saludos y suerte.
__________________
Barrio Rodriguez, Jonathan. _____________________________________
"No sigas a quien haya encontrado la verdad sino a quien la busque"
|
Herramientas | Buscar en Tema |
Desplegado | |
|
|