用FR做报表,必须要明白点SQL,而且对ERP数据库也要有一定的了解,清楚每个字段的含义,否则多表关联你也是搞不定的,下面是模板数据集语句:
SELECT * FROM (SELECT t1.FBillNo,u1.FName AS FCustID,case when u1.FName='零售户' then '预测订单' else '销售订单' end as FCustID1,t1.FDate,
u2.FName AS FEmpID,
case when t1.FMultiCheckLevel1=16403 or t1.FMultiCheckLevel1=16507 then '昆嵛路工厂'
else '四产路工厂' end
AS fparentid,t2.FEntryID,t100.FNumber,t100.FName,t100.FModel,
CASE WHEN t2.FUnitID=0 THEN '' ELSE u4.FName END AS FUnitID,
t2.FAuxQty As FQty,t2.FDate AS FOutStockDate,t2.FAdviceConsignDate,u5.FBOMNumber,t1.FInterID
,t2.FAuxStockQty as FStockQty,t51.FName as FCUUnitID,t2.FQty/t51.FCoefficient as FCUQty,
t2.FStockQty/t51.FCoefficient as FCUStockQty
,cast(t2.finterid as varchar)+cast(t2.fentryid as varchar) finteridfentryid,t800.fqty fstockqty1,t800.fcheckdate,t2.FHaveMrp,t1.FExchangeRate,t2.fauxpricediscount
FROM SEOrder t1 INNER JOIN SEOrderEntry t2 ON t1.FInterID = t2.FInterID and t1.fstatus in (1,2,3)
and t1.FChangeMark=0 AND Isnull(t1.FClassTypeID,0)<>1007100 and t2.FMrpAutoClosed in ${是否手工行关闭} left outer join icmo t900 on t900.FOrderInterID =t2.FInterID and t900.FSourceEntryID=t2.FEntryID and t900.fitemid=t2.fitemid
left outer join (select b.FICMOInterID,b.fitemid,b.fqty,a.fcheckdate from icstockbill a join icstockbillentry b
on a.finterid=b.finterid where a.ftrantype=2 and a.fstatus=1) t800 on t800.FICMOInterID=t900.finterid
LEFT OUTER JOIN t_Organization u1 ON t1.FCustID=u1.FItemID
LEFT OUTER JOIN t_Emp u2 ON t1.FEmpID=u2.FItemID
LEFT OUTER JOIN t_ICItem t100 ON t2.FItemID = t100.FItemID
LEFT OUTER JOIN t_MeasureUnit u4 ON t2.FUnitID = u4.FItemID
LEFT OUTER JOIN t_MeasureUnit t51 ON t100.FProductUnitID=t51.FItemID
LEFT OUTER JOIN ICBOM u5 ON t2.FBomInterID = u5.FInterID ) tt
WHERE 1=1 and tt.FOutStockDate>='${开始日期}' and tt.FOutStockDate<='${结束日期}'
and tt.FCustID1='销售订单' and tt.FNumber>'3.01'
${if(len(fparentid)==0,"","and fparentid = '"+fparentid+"'")}
order by ${cname} ${orderby}
|