Fijar lo siguientes atributos a la estructura de control de salida del formulario, parámetros CONTROL_PARAMETERS y OUTPUT_OPTIONS en el llamado del formulario .
control-getotf = 'X'. "con esto tendras el OTF para poder enviar el PDF
control-no_dialog = 'X' "Sin dialogo para selección de impresora
output-tdnoprev = 'X'. "sin vista previa
Te adjunto rutina para armar el envio del correo.
FORM ENVIAR_MAIL_Usuario.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
DATA L_NUM(3).
DATA LARGO TYPE I.
DATA SYSUBRC TYPE N.
Data: v_ADDRNUMBER like ADRC-ADDRNUMBER,
v_PERSNUMBER like ADRP-PERSNUMBER.
DATA: BEGIN OF correo OCCURS 24.
DATA: linea(255).
DATA: END OF correo.
DATA filesize TYPE I.
* TOMAR OTF Y PASARLO A PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = FILESIZE
TABLES
OTF = T_OTF
LINES = T_LINES
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1.
* File Name
DOC_CHNG-OBJ_NAME = 'MESSAGE'.
* Mail Subject
CONCATENATE 'Reclamo N° ' nast-objky
into DOC_CHNG-OBJ_DESCR
SEPARATED BY SPACE.
* PACKING INFO TEXT DATA
OBJTXT-LINE = 'Ver detalle de reclamo en Documento Adjunto.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
* CLEAR OBJHEAD.
* OBJHEAD = 'MiPDF.PDF'.
* APPEND OBJHEAD.
clear OBJPACK.
OBJPACK-TRANSF_BIN = ''.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
T_SOURCE_TAB = T_LINES
T_TARGET_TAB = OBJBIN
EXCEPTIONS
CONVERT_NOT_POSSIBLE = 1.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
READ TABLE OBJBIN INDEX TAB_LINES.
clear OBJPACK.
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-head_start = 1.
OBJPACK-head_num = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'PDF'.
OBJPACK-OBJ_NAME = 'COTIPDF'.
CONCATENATE 'Cotizac_' nast-objky Into OBJPACK-OBJ_DESCR.
* OBJPACK-OBJ_DESCR = 'Click para ver archivo'.
OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJBIN ).
APPEND OBJPACK.
* Completing the recipient list target recipent
clear RECLIST.
select single ADDRNUMBER PERSNUMBER
into (v_ADDRNUMBER, v_PERSNUMBER)
from USR21
where BNAME = sy-uname.
if sy-subrc eq 0.
select single SMTP_ADDR into RECLIST-RECEIVER
from ADR6
where ADDRNUMBER = v_ADDRNUMBER
and PERSNUMBER = v_PERSNUMBER.
if sy-subrc eq 0.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
Else.
* Si no encuentra el correo externo del usuario,
* mandamos al correo interno de SAP.
RECLIST-RECEIVER = sy-uname.
RECLIST-REC_TYPE = 'B'.
APPEND RECLIST.
endif.
ENDIF.
*
* Sending the document
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 = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
ENDFORM.
Con eso debería poder armar tu programa para que pueda correr en segundo plano.
Saludos
|