on 05-30-2011 2:36 PM
Hola!!!
Retomando un query sobre ventas por productos
SELECT
T0.[DocDate],
T0.[DocNum],
T1.[ItemCode],
T1.[Dscription],
T1.[VendorNum],
T1.[Quantity],
T1.[Price],
T1.[LineTotal],
T2.[SlpName]
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
WHERE T0.[DocDate] >=[%0] and T0.[DocDate] <=[%1]
me di cuenta, que me esta tomando saldos iniciales que no me interesan tenerlos en cuenta. ya que estos estan creados como factura de clientes tipo servicio, por lo cual anexe al query and T0.[DocType]='I' , pero no obtuve los resultados esperados porque me siguen registrando estos saldos, además habia creado otra consulta teniendo en cuenta la serie pero no me sale las facturas que se hicieron manuales:
SELECT
T3.[SeriesName],
T0.[DocNum] as 'COD_FACT',
T0.[CardCode] as 'COD_CLIENTE',
T0.[CardName] as 'NOMBRE DE CLIENTE',
T0.[DocDate] AS ' FECHA DE FACTURA',
T1.[ItemCode] AS 'COD_ARTICULO',
T1.[Dscription] AS 'DESCRIPCION',
T1.[Quantity] AS ' CANTIDAD',
T1.[GrossBuyPr] AS ' PRECIO DE COSTO',
(T1.[Quantity]*T1.[GrossBuyPr])as 'TOTAL COSTO',
T1.[PriceBefDi] AS 'PRECIO UNITARIO',
T1.[Price] AS 'PRECIO TRAS EL DESCUENTO',
T1.[LineTotal] AS 'PRECIO TOTAL DE ARTICULO',
T2.[SlpName] AS 'NOM_EMPLEADO'
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
INNER JOIN NNM1 T3 ON T0.Series = T3.Series
WHERE T0.[DocType]='I' AND (T0.[DocDate] >=[%0] AND T0.[DocDate] <=[%1]) and left(T3.[SeriesName],3) in ('1P','2P','1E','2E','1C','2C','11P','12P','11E','12E','12C','11C')
Edited by: jcarito on May 30, 2011 8:36 AM
tampoco jajajaj
además probe ....
/* SELECT FROM [dbo].[OINV] P0 WHERE 1=1 */
DECLARE @FD DATETIME, @TD DATETIME
SET @FD = /* AND P0.DocDate */ '[%0]'
SET @TD = /* AND P0.DocDate */ '[%1]'
SELECT T0.[DocDate],
T0.[DocNum],
T1.[ItemCode],
T1.[Dscription],
T1.[VendorNum],
T1.[Quantity],
T1.[Price],
T1.[LineTotal],
T2.[SlpName] FROM OINV T0 left JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry left JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode WHERE @FD >=[%0] and @TD <=[%1] and T1.[Dscription] not like 'SALDOS INICIALES'
y nada..no me los lista pero si voy por el drilldown a la factura #1 se va a la factura 1 de saldos iniciales
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Carito,
Tu problema es que estas haciendo el DrillDown sobre el campo DocNum, con esto SAP considera el Número de documento que tiene el registro, pero sobre el objeto principal y no sobre el SubObjeto.
Deberias agregar el campo DocEntry, para hacer el drilldown, puesto que este campo te va a traer la información correcta.
slds.
Bueno Finalmente asi quedo resuelto mi informe...gracias a las personas que amablemente me colaboraron:
SELECT
T3.[SeriesName],T0.[DocEntry],
T0.[DocNum] as 'COD_FACT',
T0.[CardCode] as 'COD_CLIENTE',
T0.[CardName] as 'NOMBRE DE CLIENTE',
T0.[DocDate] AS ' FECHA DE FACTURA',
T1.[ItemCode] AS 'COD_ARTICULO',
T1.[Dscription] AS 'DESCRIPCION',
T1.[VendorNum],
T1.[Quantity] AS ' CANTIDAD',
T1.[GrossBuyPr] AS ' PRECIO DE COSTO',
(T1.[Quantity]*T1.[GrossBuyPr])as 'TOTAL COSTO',
T1.[PriceBefDi] AS 'PRECIO UNITARIO',
T1.[Price] AS 'PRECIO TRAS EL DESCUENTO',
T1.[LineTotal] AS 'PRECIO TOTAL DE ARTICULO',
T2.[SlpName] AS 'NOM_EMPLEADO'
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
LEFT JOIN NNM1 T3 ON T0.Series = T3.Series
WHERE T0.[DocType]='I' AND (T0.[DocDate] >=[%0] AND T0.[DocDate] <=[%1])
UNION ALL
SELECT
T3.[SeriesName],T0.[DocEntry],
T0.[DocNum] as 'COD_FACT',
T0.[CardCode] as 'COD_CLIENTE',
T0.[CardName] as 'NOMBRE DE CLIENTE',
T0.[DocDate] AS ' FECHA DE FACTURA',
T1.[ItemCode] AS 'COD_ARTICULO',
T1.[Dscription] AS 'DESCRIPCION',
T1.[VendorNum],
-T1.[Quantity] AS ' CANTIDAD',
-T1.[GrossBuyPr] AS ' PRECIO DE COSTO',
-(T1.[Quantity]*T1.[GrossBuyPr])as 'TOTAL COSTO',
-T1.[PriceBefDi] AS 'PRECIO UNITARIO',
-T1.[Price] AS 'PRECIO TRAS EL DESCUENTO',
-T1.[LineTotal] AS 'PRECIO TOTAL DE ARTICULO',
T2.[SlpName] AS 'NOM_EMPLEADO'
FROM ORIN T0
INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
LEFT JOIN NNM1 T3 ON T0.Series = T3.Series
WHERE T0.[DocType]='I' AND (T0.[DocDate] >=[%0] AND T0.[DocDate] <=[%1])
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
faltaria revisar la parte de las notas credito...y en esas estoy no cerrare el post hasta terminarlo.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
y gracias a mi querido amigo julio jajaja
SELECT
T3.[SeriesName],T0.[DocEntry],
T0.[DocNum] as 'COD_FACT',
T0.[CardCode] as 'COD_CLIENTE',
T0.[CardName] as 'NOMBRE DE CLIENTE',
T0.[DocDate] AS ' FECHA DE FACTURA',
T1.[ItemCode] AS 'COD_ARTICULO',
T1.[Dscription] AS 'DESCRIPCION',
T1.[Quantity] AS ' CANTIDAD',
T1.[GrossBuyPr] AS ' PRECIO DE COSTO',
(T1.[Quantity]*T1.[GrossBuyPr])as 'TOTAL COSTO',
T1.[PriceBefDi] AS 'PRECIO UNITARIO',
T1.[Price] AS 'PRECIO TRAS EL DESCUENTO',
T1.[LineTotal] AS 'PRECIO TOTAL DE ARTICULO',
T2.[SlpName] AS 'NOM_EMPLEADO'
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
LEFT JOIN NNM1 T3 ON T0.Series = T3.Series
WHERE T0.[DocType]='I' AND (T0.[DocDate] >=[%0] AND T0.[DocDate] <=[%1])
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
estoy en revision pero lo mas probable es que este bien, gracias felipe
SELECT
T3.[SeriesName],
T0.[DocNum] as 'COD_FACT',
T0.[CardCode] as 'COD_CLIENTE',
T0.[CardName] as 'NOMBRE DE CLIENTE',
T0.[DocDate] AS ' FECHA DE FACTURA',
T1.[ItemCode] AS 'COD_ARTICULO',
T1.[Dscription] AS 'DESCRIPCION',
T1.[Quantity] AS ' CANTIDAD',
T1.[GrossBuyPr] AS ' PRECIO DE COSTO',
(T1.[Quantity]*T1.[GrossBuyPr])as 'TOTAL COSTO',
T1.[PriceBefDi] AS 'PRECIO UNITARIO',
T1.[Price] AS 'PRECIO TRAS EL DESCUENTO',
T1.[LineTotal] AS 'PRECIO TOTAL DE ARTICULO',
T2.[SlpName] AS 'NOM_EMPLEADO'
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
INNER JOIN NNM1 T3 ON T0.Series = T3.Series
WHERE T0.[DocType]='I' AND (T0.[DocDate] >=[%0] AND T0.[DocDate] <=[%1]) and left(T3.[SeriesName],3) in ('1P','2P','1E','2E','1C','2C','11P','12P','11E','12E','12C','11C')
union all
SELECT
'Manual',
T0.[DocNum] as 'COD_FACT',
T0.[CardCode] as 'COD_CLIENTE',
T0.[CardName] as 'NOMBRE DE CLIENTE',
T0.[DocDate] AS ' FECHA DE FACTURA',
T1.[ItemCode] AS 'COD_ARTICULO',
T1.[Dscription] AS 'DESCRIPCION',
T1.[Quantity] AS ' CANTIDAD',
T1.[GrossBuyPr] AS ' PRECIO DE COSTO',
(T1.[Quantity]*T1.[GrossBuyPr])as 'TOTAL COSTO',
T1.[PriceBefDi] AS 'PRECIO UNITARIO',
T1.[Price] AS 'PRECIO TRAS EL DESCUENTO',
T1.[LineTotal] AS 'PRECIO TOTAL DE ARTICULO',
T2.[SlpName] AS 'NOM_EMPLEADO'
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
WHERE T0.[DocType]='I' AND (T0.[DocDate] >=[%0] AND T0.[DocDate] <=[%1] )and T0.[Series] = '-1'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Lo he probado tambien...lo he probado todo jajaja, ps mira que el problema tiene que ver al llamar el DocNum ese problema tambien lo he tenido con informes de Proveedores, porque si utilizo el siguiente query
SELECT T0.[DocEntry]
FROM OINV T0 inner join inv1 T1 on T0.[DocEntry]= T1.[DocEntry] WHERE T0.[DocDate] >=[%0] and T0.[DocDate] <=[%1]
no tengo ningun inconveniente me sale lo que necesito, el problema es que necesito tambien mostrar el verdadero numero de factura porque ese docentry es un numero interno del sistema...hay otro campo que guarde este numero???
Por que no creo que se ha la fecha..seleccione desde febrero del 2010 y me sigo saliendo los saldos iniciales mmmmmm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bueno lo que pasa es que con SAP arrancamos desde el 2010 entonces se cargaron las cuentas por pagar con una cuenta de saldos iniciales con fechas de contabilización de diciembre del año 2009, auque algunas tienen fechas de vencimiento con fecha del 2010, y como te decia en la OINV encontraria estas facturas con numeracion (SALINI)saldos iniciales, notas debito y algunas facturas que se pasaron manuales, todas estas con algo en comun y es que comienzan todas desde 1 para el mismo periodo de año.
Y con respecto a notas credito debito, si necesito tenerlo en cuenta pero primero necesito verificar esos saldos que me tienen pensando el porque????
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Lo cambie y sigue saliendo igual, la cuestion puede ser que la numeracion tanto de saldos iniciales,notas debito y las facturas manuales comenzaron desde 1? sera que puede ser eso?
voy a seguir revisando
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Y si lo pones de esta manera
WHERE YEAR(T0.[DocDate]) = '2010' AND MONTH(T0.DocDate) IN ('1','2','3','4')
Que otra caracteristica tienen los saldos iniciales?
Es raro que te los tome siendo que estas filtrando por DocType.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola felipe, ps resulta que los saldos iniciales estan cargados con fecha de diciembre del 2009 y las fechas que selecciono para que me visualice el informe es todo el año 2010, asi que por ese lado no pude
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Buenos dias
Creo que lo primero que debes hacer, es que el query solo te muestre los saldos iniciales, para asi posteriormente tener en cuenta lo que no hay que tomar para que estos saldos aparezcan.
Generalmente el saldo inicial es todo lo inferior a una fecha, podrias modificar esta parte
WHERE T0.[DocDate] > '[%0]' and T0.[DocDate] <= '[%1]'
Slds
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.