金蝶云星空数据库根据仓库和仓位查询内码(SQL脚本)
SELECT a.仓库ID, a.仓库名称, d.仓位ID, d.仓位名称,c.内码 FROM ( SELECT a.FSTOCKID '仓库ID', b.FNAME '仓库名称' FROM T_BD_STOCK a INNER JOIN T_BD_STOCK_L b ON a.FSTOCKID = b.FSTOCKID --仓库列表 ) a LEFT JOIN ( SELECT FENTRYID '仓位值表FENTRYID', FSTOCKID '仓库ID' FROM dbo.T_BD_STOCKFLEXITEM ) b ON b.仓库ID = a.仓库ID LEFT JOIN ( SELECT FDETAILID '内码', FENTRYID '仓位值表FENTRYID', FFLEXENTRYID '仓位表FENTRYID' FROM T_BD_STOCKFLEXDETAIL ) c ON c.仓位值表FENTRYID = b.仓位值表FENTRYID LEFT JOIN ( SELECT loc.FID AS '仓位ID', locCol1L.FNAME '仓位名称', locCol1.FENTRYID '仓位表FENTRYID' FROM T_BAS_FLEXVALUESDETAIL loc LEFT JOIN T_BAS_FLEXVALUESENTRY locCol1 ON (loc.FF100004 = locCol1.FENTRYID) LEFT JOIN T_BAS_FLEXVALUESENTRY_L locCol1L ON locCol1.FENTRYID = locCol1L.FENTRYID ) d ON d.仓位表FENTRYID = c.仓位表FENTRYID WHERE a.仓库名称='备品仓' AND d.仓位名称='B2/01-01-01-001A'
FF100004中的 100004 是仓位值集。
仓位ID就是业务单据上的库位/仓位ID,也是【即时库存】的库位/仓位。