用class调用report报表时,初始化显示当前Form传达的值作为报表数据源下的过滤条件,
只要改写class中的queryRun就可以了!(*^__^*) 嘻嘻……
Form中的menuItem下的单击事件
void clicked()
{
args _a = new args();
YAM_UnqualifiedManageIQCLine _iqcLine;
YAM_UnqualifiedManageHead _IqcHead;
str 100 _iqcId;
set _set = new set (types::String);
setIterator it;//提取set容器结果集
;
super();
if(YAM_UnqualifiedManageHead_ds.mark())
{
_IqcHead = YAM_UnqualifiedManageHead_ds.getFirst(1);
while(_IqcHead)
{
while select _iqcLine
group by IQCId
where _iqcLine.ItemId == _IqcHead.ItemId
&& _iqcLine.NumberDocuments == _IqcHead.NumberDocuments
{
_set.add(_iqcLine.IQCId);
}
_IqcHead = YAM_UnqualifiedManageHead_ds.getNext();
}
}
else
while select _iqcLine
group by IQCId
where _iqcLine.ItemId == YAM_UnqualifiedManageHead.ItemId
&& _iqcLine.NumberDocuments == YAM_UnqualifiedManageHead.NumberDocuments
{
_set.add(_iqcLine.IQCId);
}
it = new setIterator(_set);
while(it.more())
{
if(!_iqcId)
_iqcId = it.value();
else
_iqcId += ',' + it.value();
it.next();
}
_a.parm(_iqcId);
new MenuFunction("YAM_Returnmatersingle",MenuItemType::Output).run(_a);
}
-----****************************************
Class Code(YAM_Returnmatersingle)
-------
class YAM_Returnmatersingle extends RunBaseReport
{
YAM_UnqualifiedManageIQCLine _ManageIQCLine;
Str 100 _iqcId;
set _set ;//modify by xyf 20091007
}
------
void initIqcid(str 100 IqcId)
{
_iqcId = IqcId;
}
-----
public identifiername lastValueElementName()
{
return reportstr("YAM_Returnmatersingle");
}
------
//modify by xyf 20091007
void new()
{
_set = new set(types::String);
}
------
public QueryRun queryRun() //modify by xyf 20091007
{
QueryRun ret;
sysLastValue sysLastValue;
str 100 curIqc,InitIqc;
;
ret = new queryRun(this.reportRun());
if(_iqcId )
{
/*
delete_from sysLastValue where sysLastValue.userId == CuruserId()
&& sysLastValue.elementName like '*YAM_UnqualifiedManage*'
|| sysLastValue.elementName like '*YAM_Returnmatersingle*'
|| sysLastValue.elementName == 'SysQueryForm'
|| sysLastValue.elementName == 'RunBaseQueryDialog';
*/
curIqc = this.reportRun().query().dataSourceNo(1).rangeField(fieldnum(ESGIQCLine,iqcId)).value();
sysquery::findOrCreateRange(ret.query().dataSourceNo(1),fieldnum(ESGIQCLine,iqcId)).value(_iqcId );
_set.add(curIqc);
if(_iqcId != curIqc)
if(curIqc && _set.in(_iqcId))
sysquery::findOrCreateRange(ret.query().dataSourceNo(1),fieldnum(ESGIQCLine,iqcId)).value(curIqc);
else
sysquery::findOrCreateRange(ret.query().dataSourceNo(1),fieldnum(ESGIQCLine,iqcId)).value(_iqcId);
else
sysquery::findOrCreateRange(ret.query().dataSourceNo(1),fieldnum(ESGIQCLine,iqcId)).value(_iqcId);
}
else
sysquery::findOrCreateRange(ret.query().dataSourceNo(1),fieldnum(ESGIQCLine,iqcId)).value(this.reportRun().query().dataSourceNo(1).rangeField(fieldnum(ESGIQCLine,iqcId)).value());
/**
else
ret.query().dataSourceNo(1).clearRange(fieldnum(ESGIQCLine,IqcId));
*/
ret = super();
return ret;
}
---------------------
static void Main(Args args)
{
YAM_Returnmatersingle YAM_Returnmatersingle;
str 100 _iqcId;
;
YAM_Returnmatersingle = new YAM_Returnmatersingle();
if(args)
{
_iqcId = args.parm();
YAM_Returnmatersingle.initIqcid(_iqcId);
}
if (YAM_Returnmatersingle.prompt())//弹出dialog之前赋值给Report数据源下的过滤条件,此时会调用重写RunBase的方法queryRun()
YAM_Returnmatersingle.run();
}
---*****************************************
Report Code(YAM_Returnmatersingle)
----------
public class ReportRun extends ObjectRun
{
}
-------------------
public boolean fetch()
{
ESGIQCLine ESGIQCLine;
;
queryRun = new queryRun(this);//queryRun为Report数据源系统自带的queryRun
while(queryRun.next())
{
ESGIQCLine = QueryRun.get(tablenum(ESGIQCLine));
// do something……………….
}
return true;
}