buen día
necesito ayuda con un informe de cartera que baje desde sap y lo edite en crystal para filtrarlo por zonas y por clientes y visualizarlo en sap móvil. es sencillo pero no se por que aveces muestra los resultados y otras veces no.
Envío el archivo del SQL en el siguiente link.
/*SELECT FROM [dbo].[OUSR] P0*/
/*SELECT FROM [dbo].[OUSR] P0*/
declare @Moneda as nvarchar(30)
/* WHERE */
set @Moneda = /* P0.UserID */ '{?1@Moneda}' /*parametros*/
/* set @Moneda = 1*/
declare @Zona as nvarchar(30)
set @Zona = '{?2@Zona Empleado}' /*parametros*/
declare @Usuario as nvarchar(30)
/* WHERE */
/*declare @select_user_code as nvarchar(30) */
/* set @Usuario = /* P0.USER_CODE */ '{?3@select_user_code}'
set @Usuario = (select T1.Internal_K FROM OUSR T1 WHERE T1.USER_CODE= @Usuario)
set @select_user_code = 'manager'*/
SELECT T0.Code, T0.Name, T0.U_RefDoc, T0.U_TransId, T0.U_DocType, T0.U_DocSubtype, T0.U_Moneda, T0.U_preFolio, T0.U_numFolio, T0.U_CodigoSocio, T0.U_NombreSocio, T0.U_GrupoSocio, T0.U_Tel1, T0.U_EmpleadoVentas, T0.U_Cobrador, T0.U_DireccionEnvio, T0.U_CodigoEnvio, T0.U_dirFactura, t0.U_nit,
CASE @Moneda WHEN 1 THEN T0.U_ValDoc ELSE T0.U_ValDocSC END as U_ValDoc, T0.U_ValDocFC,
CASE @Moneda WHEN 1 THEN T0.U_ValAbonado ELSE T0.U_ValAbonadoSC END as U_ValAbonado, T0.U_ValAbonadoFC,
CASE @Moneda WHEN 1 THEN T0.U_ValARecaudar ELSE T0.U_ValARecaudarSC END as U_ValARecaudar, T0.U_valARecaudarFC, T0.U_DiasVencido,
CASE @Moneda WHEN 1 THEN T0.U_ValSinVencer ELSE T0.U_ValSinVencerSC END as U_ValSinVencer,
CASE @Moneda WHEN 1 THEN T0.U_Int1 ELSE T0.U_Int1SC END as U_Int1,
CASE @Moneda WHEN 1 THEN T0.U_Int2 ELSE T0.U_Int2SC END as U_Int2,
CASE @Moneda WHEN 1 THEN T0.U_Int3 ELSE T0.U_Int3SC END as U_Int3,
CASE @Moneda WHEN 1 THEN T0.U_Int4 ELSE T0.U_Int4SC END as U_Int4,
T0.U_DocDate, T0.U_DocDueDate, T0.U_CreateDate, T0.U_Territorio, T0.U_Comentario, T0.U_Usuario, T0.U_RefDoc2, T0.U_AbrDocType Tipo, T0.U_Serie, T0.U_CheqDev, convert(date, t0.U_DocDate) as F1, convert(date, t0.U_DocDueDate) as F2,T1.U_SN_desde, T1.U_SN_hasta, T1.U_empleVenta1, T1.U_empleVenta2, T1.U_recau, T1.U_territo, T1.U_fechaCombo,convert(date, T1.U_fechaDesde) U_fechaDesde, convert(date,T1.U_fechaHasta) U_fechaHasta, convert(date,T1.U_fechaVenci1) U_fechaVenci1, convert(date,T1.U_fechaVenci2) U_fechaVenci2, T1.U_intervDia, T1.U_rompimiento, T1.U_grupoSN
FROM [dbo].[@OK1_CARTROMP] T0
inner join [dbo].[@OK1_REPORCARTE] T1 on T0.U_Usuario = T1.U_Usuario
WHERE /*T0.U_Usuario =@Usuario and*/ ISNULL(t0.U_TransID,'') <> '' and T0.U_EmpleadoVentas = @Zona
ORDER BY U_DocDueDate ASC
```