起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 735|回复: 16

【搞定】难道DecisionBroker代理的数据集不能用代码设计 维/项定义吗?**

[复制链接]
发表于 2007-3-13 10:44:03 | 显示全部楼层 |阅读模式
用窗体的“决策数据集控件”是可以的,代码如下:
procedure TMainGLFZZDYBB.Button2Click(Sender: TObject);
var
    ddd: TDecisionDimensionDef;
    dsd: TDecisionSummaryDef;
begin
    DataSetJCSJJ2.Close();

    DataSetJCSJJ2.DecisionDef.DimensionDefs.Clear();
    ddd:=DataSetJCSJJ2.DecisionDef.DimensionDefs.Add;
    ddd.FieldName:= 'ccus_id';
    ddd.TableName:= 'VIEW_das';
    ddd.FieldType:= TFieldType.ftString;
    ddd.DisplayName:='客户编码';
    ddd.IsPrimaryKey := False;
    ddd.IsAgg := False;
    ddd.DimType :=TDecisionDimType.dtDataDim;
    ddd.DimStyleDefType :=TDecisionDimstyleDefType.dfColDim;
    ddd.DimIndexDef := 0;
    ddd.ShowSubTotal := False;
    ddd.CustomDim.FieldType :=TCustomDimType.cdtString;
    ddd.BinType := TBinType.binNone;

    ddd:=DataSetJCSJJ2.DecisionDef.DimensionDefs.Add;
    ddd.FieldName:= 'Periodid';
    ddd.TableName:= 'VIEW_das';
    ddd.FieldType:=TFieldType.ftString;
    ddd.DisplayName:='期间';
    ddd.IsPrimaryKey := False;
    ddd.IsAgg := False;
    ddd.DimType :=TDecisionDimType.dtDataDim;
    ddd.DimStyleDefType := TDecisionDimstyleDefType.dfColDim;
    ddd.DimIndexDef := 0;
    ddd.ShowSubTotal := False;
    ddd.CustomDim.FieldType := TCustomDimType.cdtString;
    ddd.BinType := TBinType.binNone;

    DataSetJCSJJ2.DecisionDef.SummaryDefs.Clear();
    dsd:=DataSetJCSJJ2.DecisionDef.SummaryDefs.Add();
    dsd.FieldName := 'SUM(VIEW_das.md_f)';
    dsd.TableName := 'VIEW_das';
    dsd.FieldType := TFieldType.ftString;
    dsd.DisplayName :='aaaaasfsaf';
    dsd.Origin := 'md_f';
    dsd.IsPrimaryKey := False;
    dsd.IsAgg := True ;
    dsd.SummType := TdecisionSummtype.dtAggSumm;
    dsd.SummFlags := TSummFlags.sfSum;

    DataSetJCSJJ2.Database.URL:= 'Biz:\ZWXT\financeSys.Database';
    DataSetJCSJJ2.SQL.Text:='SELECT VIEW_das.ccus_id AS "客户编码", VIEW_das.Periodid AS "会计期间", SUM(VIEW_das.md_f) AS "合计_分录借方" FROM VIEW_das WHERE VIEW_das.ino_id = ''0'' GROUP BY VIEW_das.ccus_id, VIEW_das.Periodid ORDER BY VIEW_das.ccus_id, VIEW_das.Periodidne';
    DataSetJCSJJ2.DecisionDef.ShowFieldName := False;
    DataSetJCSJJ2.DecisionDef.SummAreaWidth := 1;
    DataSetJCSJJ2.DecisionDef.SummAreaHeight := 1;
    DataSetJCSJJ2.DecisionDef.MaxDims := 5;
    DataSetJCSJJ2.DecisionDef.MaxSums := 10;
    DataSetJCSJJ2.DecisionDef.MaxCells := 0;
    DataSetJCSJJ2.DecisionDef.DecisionType := TDecisionType.dctStatistics;
    DataSetJCSJJ2.DecisionDef.DatabaseURL := 'Biz:\ZWXT\financeSys.Database';
    DataSetJCSJJ2.DecisionDef.OriginalSQL.Text := 'SELECT * FROM VIEW_das WHERE VIEW_das.ino_id = ''0''';

    DataSetJCSJJ2.Open();
end;
回复

使用道具 举报

 楼主| 发表于 2007-3-13 10:45:32 | 显示全部楼层
但是用DecisionBroker代理的数据集就是有报错:
procedure TMainGLFZZDYBB.Button3Click(Sender: TObject);
var
    ddd: TDecisionDimensionDef;
    dsd: TDecisionSummaryDef;
begin
    DecisionBrokerJCSJJ1.DataSet.Close();
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.DimensionDefs.Clear();  //出错语句
    ddd:=TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.DimensionDefs.Add;
    ddd.FieldName:= 'ccus_id';
    ddd.TableName:= 'VIEW_das';
    ddd.FieldType:= TFieldType.ftString;
    ddd.DisplayName:='客户编码';
    ddd.IsPrimaryKey := False;
    ddd.IsAgg := False;
    ddd.DimType :=TDecisionDimType.dtDataDim;
    ddd.DimStyleDefType :=TDecisionDimstyleDefType.dfColDim;
    ddd.DimIndexDef := 0;
    ddd.ShowSubTotal := False;
    ddd.CustomDim.FieldType :=TCustomDimType.cdtString;
    ddd.BinType := TBinType.binNone;

    ddd:=TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.DimensionDefs.Add;
    ddd.FieldName:= 'Periodid';
    ddd.TableName:= 'VIEW_das';
    ddd.FieldType:=TFieldType.ftString;
    ddd.DisplayName:='期间';
    ddd.IsPrimaryKey := False;
    ddd.IsAgg := False;
    ddd.DimType :=TDecisionDimType.dtDataDim;
    ddd.DimStyleDefType := TDecisionDimstyleDefType.dfColDim;
    ddd.DimIndexDef := 0;
    ddd.ShowSubTotal := False;
    ddd.CustomDim.FieldType := TCustomDimType.cdtString;
    ddd.BinType := TBinType.binNone;

    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.SummaryDefs.Clear();
    dsd:=TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.SummaryDefs.Add();
    dsd.FieldName := 'SUM(VIEW_das.md_f)';
    dsd.TableName := 'VIEW_das';
    dsd.FieldType := TFieldType.ftString;
    dsd.DisplayName :='aaaaasfsaf';
    dsd.Origin := 'md_f';
    dsd.IsPrimaryKey := False;
    dsd.IsAgg := True ;
    dsd.SummType := TdecisionSummtype.dtAggSumm;
    dsd.SummFlags := TSummFlags.sfSum;

    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).Database.URL:= 'Biz:\ZWXT\financeSys.Database';
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).SQL.Text:='SELECT VIEW_das.ccus_id AS "客户编码", VIEW_das.Periodid AS "会计期间", SUM(VIEW_das.md_f) AS "合计_分录借方" FROM VIEW_das WHERE VIEW_das.ino_id = ''0'' GROUP BY VIEW_das.ccus_id, VIEW_das.Periodid ORDER BY VIEW_das.ccus_id, VIEW_das.Periodidne';
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.ShowFieldName := False;
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.SummAreaWidth := 1;
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.SummAreaHeight := 1;
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.MaxDims := 5;
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.MaxSums := 10;
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.MaxCells := 0;
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.DecisionType := TDecisionType.dctStatistics;
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.DatabaseURL := 'Biz:\ZWXT\financeSys.Database';
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.OriginalSQL.Text := 'SELECT * FROM VIEW_das WHERE VIEW_das.ino_id = ''0''';

    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).Open();
end;
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-13 10:47:34 | 显示全部楼层
报错信息为:

abc.jpeg

24.4 KB, 下载次数: 313

回复 支持 反对

使用道具 举报

发表于 2007-3-13 11:54:43 | 显示全部楼层
正在处理,有结果马上跟贴告知
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-13 11:56:45 | 显示全部楼层
谢谢
回复 支持 反对

使用道具 举报

发表于 2007-3-13 15:04:10 | 显示全部楼层
需要在这句  DecisionBrokerJCSJJ1.DataSet.Close();  后门添加代码,参考如下:

TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.BeginUpdate;
try
....


需要在这句前面添加 TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).Open(); 前面添加代码,参考如下:
finally
  TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.EndUpdate;
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-13 15:20:28 | 显示全部楼层
谢谢!
加上这两句代码后前面出现的错误消失了,现在又出现了一个新的错误:这个DecisionBrokerJCSJJ1.DataSet我本来定义过一个项叫“会计科目”,现在运行过程中提示找不到"会计科目 field",难道
TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.DimensionDefs.Clear();不能清除原来的定义么?还是需要别的语句?

abc.jpeg

21.02 KB, 下载次数: 276

回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-13 15:26:48 | 显示全部楼层
DecisionBrokerJCSJJ1.DataSet的最开始维/项定义:

abc.jpeg

57.38 KB, 下载次数: 273

回复 支持 反对

使用道具 举报

发表于 2007-3-13 16:00:45 | 显示全部楼层
楼主,这样,你在 DecisionBrokerJCSJJ1.DataSet.Close();  之后就执行
TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.SummaryDefs.Clear();
TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).Database.URL:= ''
TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).SQL.Text:=''
TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.DatabaseURL := '';
    TDecisionDataSet(DecisionBrokerJCSJJ1.DataSet).DecisionDef.OriginalSQL.Text :=''

其实就是清空原先的定义然后看看

另外,如果还不行,
1、请告知错误停在那句
2、告知studio的版本号
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-13 16:07:27 | 显示全部楼层
楼主,我按你说的做还是不行,错误停在:DecisionBrokerJCSJJ1.DataSet.Open();这一句,
我们studio的版本号是:3.0.0.1564
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-12-26 22:16 , Processed in 0.044932 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表