Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
rjovel
Active Participant

Una de las herramientas que podemos aprovechar para alertas que SAP no trae es el SQL Mail.

aqui encontrara como en tres pasos hacer alertas via correo con cuerpo HTML, para notificaciones tipo

  1. descuentos no autorizados o por cierto rango
  2. transferencias entre almacenes
  3. devoluciones o notas de credito
  4. cualquier aviso que requiera.
  5. cualquier reporte que necesite automatizar su envio (esto via un job de sql)

en tres pasos simples sabra como hacerlo.

1 . configurar el sql server

http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-...

2 . crear un stored procedure para crear el email

USE "tu db"

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

create  PROCEDURE [dbo].[alarmaX]

AS

    SET NOCOUNT ON;

--ENVIAR NOTIFICACION POR CORREO

DECLARE @tableHTML  NVARCHAR(MAX) ;

SET @tableHTML =

    N'<H1>A Continuacion se detallan las Actividades de los Tecnicos</H1>' +

    N'<table border="1">' +

    N'<tr><th>Fecha</th><th>Cliente</th><th>Nombre Cliente</th><th>Articulo</th><th>Descripcion</th><th>Serie</th><th>Tecnico</th>' +

    N'<th>Notas</th>' +

        CAST ( ( select    td= convert(char,t0.CntctDate,103), '',

                        td= isnull(t1.customer,' ') , '',

                        td= isnull(t1.custmrName,' ') , '',

                        td= isnull(t1.itemCode,' ') , '',

                        td= isnull(t1.itemName,' ') , '',

                        td= isnull(t1.internalSN,' ') , '',

                        td= isnull((select ousr.U_NAME from OUSR with(nolock) where INTERNAL_K=t0.AttendUser),' '), '',

                        td= isnull(t0.Notes, ' ') , ''

                from    oclg t0 with(nolock)

                        full join

                        OSCL t1 with(nolock)

                        on t0.parentId=t1.callID

                where    convert(char,t0.CntctDate,103)=convert(char,GETDATE(),103)

                        and t0.AttendUser in (214,215,216,217,218)

                order by t0.AttendUser

       

   

    FOR XML PATH('tr'), TYPE

    ) AS NVARCHAR(MAX) ) +

    N'</table>' ;

EXEC msdb.dbo.sp_send_dbmail

    @profile_name='EC', --ese es el nombre que le pusiste al perfil del sql mail en el paso anterior

    @blind_copy_recipients='mail@mail.com;mail2@mail.com',    ----direcciones a quienes enviara el correo, separados por punto y coma (;)

    @subject = 'Aqui va el titulo del correo',

    @body = @tableHTML,

    @body_format = 'HTML' ;

3. usando el transact ejecutar la alarma (alerta)

IF @object_type= '23' and @transaction_type ='A'

BEGIN

IF ( lo que uds quieran evaluar para que mande la alerta )

    BEGIN

   exec alarmaX

    END

END

espero le sirva.

Labels in this area