MUNDOSAP

Regresar   MUNDOSAP > DESARROLLO > Programación ABAP IV
Nombre de Usuario
Contraseña
Home Descargas Registrar FAQ Miembros Calendario Buscar Temas de Hoy Marcar Foros Como Leídos




 
Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Viejo 23/03/11, 11:31:22
Bmamba Bmamba is offline
Member
 
Fecha de Ingreso: jun 2008
Mensajes: 91
Question Adjuntar excel a email en fondo

Hola,

Necesito crearme un programa para ejecutar en fondo, en el cual a partir de los datos de una tabla interna me cree un excel que adjuntaré en un email.

Alguién podría guiarme con los pasos que tengo que realizar?
Cómo puedo crear ese excel sin poder bajarlo a local, ya que se ejecuta en fondo? Alguna función para crear un excel en servidor?

Gracias por adelantado,
Responder Con Cita
  #2  
Viejo 23/03/11, 16:20:22
gib8107 gib8107 is offline
Member
 
Fecha de Ingreso: may 2006
Mensajes: 44
Puedes probar con esto

claro hay configuracion que tu BASIS tiene que hacer


*&---------------------------------------------------------------------*
*& Report YMAIL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT YMAIL.
CONSTANTS:
CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
DATA:P_EMAIL TYPE SOMLRECI1-RECEIVER.
DATA:IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA:IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA:IT_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
IT_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
IT_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
W_CNT TYPE I,
W_SENT_ALL(1) TYPE C,
W_DOC_DATA LIKE SODOCCHGI1,
GD_ERROR TYPE SY-SUBRC,
GD_RECIEVER TYPE SY-SUBRC.
PERFORM ARMA_EMAIL.
FORM ARMA_EMAIL.
PERFORM ARMA_TABLA_ATTACH.
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES IT_MESSAGE IT_ATTACH
USING
P_EMAIL
'LOG.DE ERRORES Y FOLIOS GENERADOS POR EL MOTOR DE SALDAJE'
'XLS'
'FILENAME'
' '
' '
' '
CHANGING GD_ERROR
GD_RECIEVER.
PERFORM EJECUTA_PROGRAMA_INICIO_MAIL.
ENDFORM.
FORM ARMA_TABLA_ATTACH.
* ENCABEZADOS
CONCATENATE 'ARTICULO' 'DESCRIPCION' 'FOLIO' 'LISTA' 'MENSAJE' INTO
IT_ATTACH-LINE SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH-LINE INTO IT_ATTACH-LINE.
APPEND IT_ATTACH.
DO 10 TIMES.
CLEAR IT_ATTACH.
* DETALLE
CONCATENATE 'ARTICULO' 'DESCRIPCION' 'FOLIO' 'LISTA' 'MENSAJE' INTO
IT_ATTACH-LINE SEPARATED BY CON_TAB.
APPEND IT_ATTACH.
ENDDO.
* Agrega el Mensaje que contendra el cuerpo del texto
REFRESH IT_MESSAGE.
IT_MESSAGE = 'DESCRIPCION DEL CUERTPO'.
APPEND IT_MESSAGE.
ENDFORM. "ARMA_TABLA_ATTACH
*
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
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_EMAIL LIKE SOMLRECI1-RECEIVER,
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.
LD_EMAIL = P_EMAIL.
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 IT_ATTACHMENT.
REFRESH IT_ATTACHMENT.
IT_ATTACHMENT[] = PIT_ATTACH[].
* Describe the body of the message
CLEAR IT_PACKING_LIST.
REFRESH IT_PACKING_LIST.
IT_PACKING_LIST-TRANSF_BIN = SPACE.
IT_PACKING_LIST-HEAD_START = 1.
IT_PACKING_LIST-HEAD_NUM = 0.
IT_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES IT_PACKING_LIST-BODY_NUM.
IT_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND IT_PACKING_LIST.
* Create attachment notification
IT_PACKING_LIST-TRANSF_BIN = 'X'.
IT_PACKING_LIST-HEAD_START = 1.
IT_PACKING_LIST-HEAD_NUM = 1.
IT_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_ATTACHMENT LINES IT_PACKING_LIST-BODY_NUM.
IT_PACKING_LIST-DOC_TYPE = LD_FORMAT.
IT_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
IT_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
IT_PACKING_LIST-DOC_SIZE = IT_PACKING_LIST-BODY_NUM * 255.
APPEND IT_PACKING_LIST.
*Adiciona las direcciones de correo a usar para enviar la informacion
REFRESH IT_RECEIVERS.
DO 5 TIMES.
CLEAR IT_RECEIVERS.
IT_RECEIVERS-RECEIVER = .
IT_RECEIVERS-REC_TYPE = 'U'.
"t_receivers-express = ' '.
IT_RECEIVERS-COM_TYPE = 'INT'.
IT_RECEIVERS-NOTIF_DEL = 'X'.
IT_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND IT_RECEIVERS.
ENDDO.
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 = IT_PACKING_LIST
CONTENTS_BIN = IT_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
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.
* Populate zerror return code
LD_ERROR = SY-SUBRC.
* Populate zreceiver return code
LOOP AT IT_RECEIVERS.
LD_RECEIVER = IT_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM.
*
FORM EJECUTA_PROGRAMA_INICIO_MAIL.
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = 'X'
AND RETURN.
ENDFORM.


******





SMTP Configuration Guide

Purpose

The kernel of the SAP Web Application Server supports SMTP (Simple Mail Transfer Protocol). This enables e-mail exchange between the SAP system and each SMTP mail server, without having to use additional external components. The SAP system sends the outbound e-mails to a separate mail server, whilst the e-mails in the inbound direction can be received by any number of mail servers.
Exchanging faxes and text messages (pager/SMS) using SMTP is also possible. For this, faxes and messages are packed as e-mails. For the send process, the mail server analyzes the domain of the recipient addresses and either forwards the e-mails to an internal fax-/text message server (for example ) or to an external provider (for example ). For receiving, the fax-/text message server or provider sends e-mails to addresses that have the domain of the SAP system (for example ).
Prerequisites

The mail server in question must be SMTP-compatible.
If you want to send text messages in the SAP system, the names of the corresponding data transfer services (such as SMS) have to be defined in transaction SA14.
Process Flow

Settings for the Profile Parameters (Transaction RZ10)

You have to adjust the profile of the SAP Web Application Server if you want to use the SMTP function. The SAPconnect send job can only be scheduled for servers on which SMTP has been activated. For this reason, you must activate SMTP for all of the SAP system’s application servers.
The following profile parameters have to be configured. The placeholder <*> stands for the sequence number (starting at zero) of frequently occurring parameters.
icm/server_port_<*> = PROT=SMTP,PORT=<port>
Parameter opens a TCP/IP port for receiving mails through the SMTP plug-in. <port> describes the number of the port that is to be used. The port cannot yet be used by another program on this host. If no mails are to be received in this SAP system (including notifications about the status), set <port> to 0.
Optionally, you can use TIMEOUT to define a maximum waiting time (in seconds) to be applied until the mail server responds.
is/SMTP/virt_host_<*> = <host>:<port>,<port>,...;
This parameter defines a for receiving mails. If all incoming mails (including status notifications) are to be received and processed by one single client of the SAP system, this parameter is not required. In this instance, is/SMTP/virt_host_0 = *:*; is used by default. If multiple clients are to be used as recipients, a virtual host has to be created for each of these clients. <host> describes the name of the host to which the incoming mails are addressed. You can enter * here if the mails are to be sent independently of the host being addressed. <port> describes the number of the port to which the incoming mails are addressed.

For UNIX, the profile parameters may look like this:
rdisp/start_icman = true
icm/server_port_0 = PROT=HTTP,PORT=1080
icm/server_port_1 = PROT=HTTPS,PORT=1443
icm/server_port_2 = PROT=SMTP,PORT=25000,TIMEOUT=180
icm/server_port_3 = PROT=SMTP,PORT=25001,TIMEOUT=180
is/SMTP/virt_host_0 = *:25000;
is/SMTP/virt_host_1 = *:25001;
For more information, see .
User Maintenance (Transaction SU01)

Service user
You have to create a service user for processing incoming mails in every SAP system client in which you want to receive mails (or status notifications). Call transaction SU01 to create a user with type Service and assign the profile S_A.SCON to this user.
User addresses
Every user that is to receive e-mails in an SAP system requires an Internet mail address. This is also used as a sender address. Enter the Internet mail address for a user in transaction SU01, under E-Mail on the tab page Address.
Assigning the Client (Transaction SICF)

Every SAP system client that is to receive and process incoming mails (or status notifications) must have an SMTP server. One SMTP server (SAPconnect) has already been created in transaction SICF and is delivered with every SAP system. Use this to create the first client and then create another SMTP server for each additional client. Configure the following settings on the SMTP servers:
Host data
Enter the sequence number of a parameter is/SMTP/virt_host_<*> from the profile. If you have only created one client and therefore have not specified this parameter type, enter 0.
Service data
Enter the client to which the mails received through the virtual mail host are to be forwarded, and then enter the logon data of the system user that you created for the incoming mails.
Handler list
Enter CL_SMTP_EXT_SAPCONNECT at position 1.

Note that each SMTP server must be activated (Service/Virt. Host ® Activate) after being created or changed. Inactive servers are grayed out.
SAPconnect Administration (Transaction SCOT)

You have to configure SAPconnect settings for every client that is used for send processes.
Default Domain
Under Settings ® Default Domain, define the domain of the SAP system client. This allows for the following to take place:
1.[FONT='Times New Roman','serif'] [/font]The SMTP plug-in logs on to the mail server using the domain as ID.
2.[FONT='Times New Roman','serif'] [/font]The message ID of the outbound e-mails is assembled with this domain.
3.[FONT='Times New Roman','serif'] [/font]If an SAP user who does not have an Internet mail address sends an e-mail, a sender address consisting of the SAP user name and this domain is generated.
Nodes
Each client has an SMTP node. This node is created by the SAP system and cannot be deleted. The following steps need to be carried out to configure the node so that sending Internet mail is possible:
1.[FONT='Times New Roman','serif'] [/font]Make sure you are in the Node view.
2.[FONT='Times New Roman','serif'] [/font]Double-click the node name.
3.[FONT='Times New Roman','serif'] [/font]Choose Node in use.
4.[FONT='Times New Roman','serif'] [/font]In the Mail Host and Mail Port fields, specify the mail server to which the outbound mails are to be sent.
5.[FONT='Times New Roman','serif'] [/font]Next to Internet, choose Settings.
6.[FONT='Times New Roman','serif'] [/font]Enter the address area of the recipient addresses that are to be reached using this node. In general, * is used if all e-mails are to be sent using SMTP.
7.[FONT='Times New Roman','serif'] [/font]Enter the output format for SAP documents. We recommend that you use the following settings:
SAPscript/Smart Forms
PDF
ABAP list
HTM
Business Object / Link
HTM
RAW Text
TXT

8.[FONT='Times New Roman','serif'] [/font]Confirm your selection.
If you also want to configure the node for sending faxes:
1.[FONT='Times New Roman','serif'] [/font]Next to Fax, choose Settings.
2.[FONT='Times New Roman','serif'] [/font]Enter the address area of the recipient addresses that are to be reached using this node. In general, * is used if all faxes are to be sent using SMTP.
3.[FONT='Times New Roman','serif'] [/font]Enter the output format for SAP documents. We recommend that you use the following settings:
SAPscript/Smart Forms
PDF
ABAP list
PDF
Business Object / Link
TXT
RAW Text
TXT

4.[FONT='Times New Roman','serif'] [/font]Enter the domain of the fax server or fax provider under Conversion into Internet Address. The system generates the local part of the Internet address automatically. The address therefore takes this format: FAX=+RecipientNumber@Domain.
5.[FONT='Times New Roman','serif'] [/font]Confirm your selection.
If you also want to configure the node for sending text messages (pager/SMS):
1.[FONT='Times New Roman','serif'] [/font]Next to Pager (SMS), choose Settings.
2.[FONT='Times New Roman','serif'] [/font]Enter the address area of the recipient addresses that are to be reached using this node. In general, * is used if all text messages (pager/SMS) are to be sent using SMTP.
3.[FONT='Times New Roman','serif'] [/font]Enter the domain of the text message (pager/SMS) server or provider under Conversion into Internet Address. The system generates the local part of the Internet address automatically. The address therefore takes this format: SMS=+RecipientNumber@Domain.
4.[FONT='Times New Roman','serif'] [/font]Confirm your selection.
Send Job
E-mails sent from an SAP application are first stored in a queue. A periodical background process, the SAPconnect send job, gets the e-mails from this queue and sends them over the Internet. To schedule this job in SAPconnect: Administration, proceed as follows:
1.[FONT='Times New Roman','serif'] [/font]Choose View ® Jobs.
2.[FONT='Times New Roman','serif'] [/font]If no other job has been scheduled, choose Job ® Create.
3.[FONT='Times New Roman','serif'] [/font]Enter a job name and confirm it.
4.[FONT='Times New Roman','serif'] [/font]Select the variant SAP&CONNECTALL by positioning the cursor on it.
5.[FONT='Times New Roman','serif'] [/font]Choose Schedule Job.
6.[FONT='Times New Roman','serif'] [/font]Choose Schedule periodically.
7.[FONT='Times New Roman','serif'] [/font]Select the interval you require, such as 10 minutes.
8.[FONT='Times New Roman','serif'] [/font]Choose Create.
Inbound
If you want incoming e-mails that have a particular address or particular content to automatically start a program that processes these mails, you can configure this under Settings ® Inbound Processing.
If you want incoming e-mails that have a particular address or come from a particular sender to be automatically forwarded to another recipient or another distribution list, you can configure this under Settings ® Inbound Processing.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Reglas de Mensajes
no puedes crear nuevos temas
no puedes responder temas
no puedes adjuntar archivos
no puedes editar tus mensajes

El código vB está On
Las caritas están On
Código [IMG] está On
Código HTML está Off
Saltar a Foro


Husos Horarios son GMT. La hora en este momento es 17:17:05.


www.mundosap.com 2006 - Spain
software crm, crm on demand, software call center, crm act, crm solutions, crm gratis, crm web