Query Stock con ubicaciones

Para el encargado del almacen, es indispensable tener reportes actualizados de stock de sus productos, y mas aun si los maneja con ubicaciones. Desde aqui te vamos a dar un Query para que te puedas guiar y hacer reportes aun mejor elaborados.




SELECT distinct T0.ItemCode, T2.ItemName,
T0.DistNumber 'Lote', t0.ExpDate, t4.WhsCode, T4.BinCode, T3.OnHandQty, t6.WhsName
from
OBTN T0
inner join OBTQ T1 on T0.ItemCode = T1.ItemCode and T0.SysNumber = T1.SysNumber
inner join OITM T2 on T0.ItemCode = T2.ItemCode
inner join OBBQ T3 on T0.ItemCode = T3.ItemCode and T0.AbsEntry = T3.SnBMDAbs
inner join OBIN T4 on T3.BinAbs = T4.AbsEntry
inner join OWHS T6 on T6.WhsCode = t4.WhsCode
where
T1.Quantity > 0
AND T3.OnHandQty > 0
and T0.ItemCode = '0002010001' -- Aqui pones el codigo de tu producto
order by
T0.ItemCode, T2.ItemName,
T0.DistNumber , t0.ExpDate, t4.WhsCode,
T4.BinCode, T3.OnHandQty

Esperamos que sea de gran ayuda.

9 comentarios:

  1. de mucha ayuda, gracias a quien corresponda

    ResponderBorrar
  2. De mucha ayuda para saber el stock en ubicaciones, pero al tener artículos en una bodega sin ubicaciones no los muestra.

    ResponderBorrar
  3. Creo que este Query tambien les puede ayuda
    SELECT T0.[ItemCode],
    Cast (T1.[ItemName] as Varchar(60)) 'Nombre del artículo' ,
    T0.[BinAbs] ID_Interno,
    T2.[BinCode],
    T0.[WhsCode] Almacen,
    T0.[OnHandQty] 'Stock en Ubicación'
    FROM OIBQ T0
    INNER JOIN OITM T1 ON T0.[ItemCode] = T1.[ItemCode]
    INNER JOIN OBIN T2 ON T0.[BinAbs] = T2.[AbsEntry]
    INNER JOIN OITW T3 ON T0.[ItemCode]=T3.[ItemCode] and T0.[WhsCode]=T3.[WhsCode]
    WHERE T0.[WhsCode] ='AG' and T3.[DftBinEnfd] ='Y'
    ORDER BY T0.[ItemCode]

    ResponderBorrar
  4. como puedo obtener la relacion de las tablas de business one?

    ResponderBorrar
  5. Buenos días, alguien que me ayude con este código, es para un reporte que sale de las entregas. cuando le quiero meter la ubicación no solo me jala la ubicación del lote que se hizo la entrega si no todas la ubicaciones del lote ??? se puede hacer alguien sabe como ???? help....

    SELECT

    T0."CardCode" AS "CODIGO CLIENTE",
    T0."CardName" AS "NOMBRE CLIENTE",
    T0."NumAtCard" AS "OC",
    T0."DocNum" AS "REMISION",
    T0."DocDate" AS "FECHA",
    T0."DocDueDate" AS "FECHA ENTREGA",
    T0."Comments" AS "OBS. DE PEDIDO",
    T1."ItemCode" AS "CODIGO PRODUCTO",
    T1."Dscription" AS "NOMBRE DEL PRODUCTO",
    T1."unitMsr" AS "UNIDAD MEDIDA",
    T1."WhsCode" AS "CLASIFICACION",
    T1."U_TS_Fabricante" AS "FABRICANTE",
    T1."FreeTxt" AS "OBS. PARTIDA",
    T2."SlpName" AS "AGENTE",
    T3."Quantity" AS "CANTIDAD",
    T3."BatchNum" AS "LOTE",
    T4."MnfDate" AS "MANUFACTURA",
    T4."U_TS_pneto" AS "PESO NETO",
    T4."ExpDate" AS "CADUCIDAD",
    T8."BinCode" AS "UBICACION",


    --DIRECCION CPQ
    T10."CompnyName" AS "NOMBRE LA SOCIEDAD",
    T10."Phone1" AS "NUMERO DE TELEFONO",
    T10."RevOffice" AS "RFC",
    T11."Street" AS "CALLE",
    T11."StreetNo"AS "NUMERO",
    T11."Block" AS "COLONIA ",
    T11."City" AS "CIUDAD",
    T11."State" AS "ESTADO",
    T11."Country" AS "PAIS",
    T11."ZipCode" AS "CODIGO POSTAL"

    FROM ODLN T0
    INNER JOIN DLN1 T1 ON T0."DocEntry" = T1."DocEntry"
    INNER JOIN OSLP T2 ON T0."SlpCode" = T2."SlpCode"
    INNER JOIN IBT1 T3 ON T1."ItemCode" = T3."ItemCode" AND T0."ObjType" = T3."BaseType"
    AND T0."DocEntry" = T3."BaseEntry" AND T1."LineNum" = T3."BaseLinNum" AND T3."Direction" = 1
    INNER JOIN OBTN T4 ON T4."ItemCode" = T3."ItemCode" AND T4."DistNumber" = T3."BatchNum"
    INNER JOIN OITM T5 ON T1."ItemCode" = T5."ItemCode"
    INNER JOIN OITB T6 ON T5."ItmsGrpCod" = T6."ItmsGrpCod"
    INNER JOIN OBBQ T7 ON T7."SnBMDAbs" = T4."AbsEntry" --aquí--
    INNER JOIN OBIN T8 ON T7."BinAbs" = T8."AbsEntry"



    CROSS JOIN OADM T10
    CROSS JOIN ADM1 T11

    --WHERE T0. "DocEntry"= {?DocKey@} AND T0. "ObjType" = '{?ObjectId@}'

    ResponderBorrar