Yes, you can dynamically change the X++ select. It's possible to build dynamical functions aswell. I've done this a few times.

Try something like:

xppCompiler compiler = new xppCompiler();
str sql = 'void sql{select .....}'

if(compiler.compile)
      runbuf(sql);

Regards,
Morten 
-----Original Message-----
From: ozzage [mailto:[EMAIL PROTECTED]
Sent: 21. desember 2004 20:23
To: development-axapta@yahoogroups.com
Subject: [development-axapta] Re: How to read temporary table ?



There's no way of dynamically changing an X++ select, but there is a
trick which can achieve the same effect, as long as you know in
advance what your possibilities are.

For instance, using your example below:

Declare a boolean for each "possibility"

boolean     filterDim5;
boolean     filterItemId;

In your code, set them to true or false depending on whether you need
to apply the particular associated 'where' clause.

Write the while select as follows:

while select sum(postedqty), sum(deducted) from InventSum
join    InventTable
group by ItemGroupId
where   inventsum.ItemId    == inventtable.ItemId
&&      (!filterDim5        || inventTable.Dimension[5] == "XX")
&&      (!filterItemId      || inventTable.ItemId       like "*test*")
{
    // Processing here
}

If filterDim5 is set to false, then the Dimension[5] filter is
irrelevant as the !filterDim5 will return true for every row.  If it's
set to true, then the other part of the _expression_ (the dimension
criteria) must be true for the row to be returned.  Ditto for the
second option.  You can set none, one, or both booleans to true and
get the required results.

This method lets SQL server do the work instead of returning all the
possible records to Axapta and then filtering them out in your code -
much faster :)

Hope that helps

Andrew Jones
HGH Business Consultancy

--- In development-axapta@yahoogroups.com, "anton_tjiptadi"
<[EMAIL PROTECTED]> wrote:
>
>
> gee thanks man, why didn't of think of that ? hehe....
>
> One more thing, in my insert method I used select statement,
> >    while select sum(postedqty), sum(deducted) from inventSum
> >    join inventTable group by itemgroupid
> >    where inventsum.ItemId==inventtable.ItemId
> >    {
> >             tmpTable.ItemGroupId = inventTable.ItemGroupId;
> >             tmpTable.InventQtyPosted = inventsum.PostedQty;
> >             tmptable.InventQtyDeducted = inventsum.Deducted;
> >             tmptable.insert();
> >           }
>
> the problem is I want to extend the criteria but with variables,
> something like this ->
> str1 = " and dimension5_ == 'XX'"
> str2 = " and itemid like == '*test*"
>
> so in the select, can be extend like this -> "where... " + str1 + str2
>
> I already try like that but.. ppfffffhhhh....
>
> I knew I can use Conection method and SQL Statement, so I can just
> wrote ordinary SQL statement, but that's another story, right now I
> want to use X++ rule :)
>
>
> thanks again for the reply :)
>
>
>
>
>
> In development-axapta@yahoogroups.com, Melega Árpád <[EMAIL PROTECTED]>
> wrote:
> >
> > Hello!
> >
> > 
> >
> > Try this!
> >
> > 
> >
> > tmp_mlr_invt_sum Process_InventSum(str _Branch, str _ItemGroup)
> >
> > {
> >
> >       /.../
> >
> > }
> >
> >
> >
> > public boolean fetch()
> > {
> >       /.../
> >
> > 
> >
> > //insert data to temp table
> > _tmpTab.setTmpData(this.Process_InventSum(BranchId,ItemGroup));
> >
> > 
> >
> >             /.../
> >
> > }
> >
> > 
> >
> > Best regards,
> >
> > Arpad Melega
> >
> > 
> >
> > ________________________________
> >
> > From: anton_tjiptadi [mailto:[EMAIL PROTECTED]
> > Sent: Monday, December 20, 2004 2:50 AM
> > To: development-axapta@yahoogroups.com
> > Subject: [development-axapta] How to read temporary table ?
> >
> > 
> >
> >
> >
> > Hi, I created a temporary table, but when i can't get fetch it in
> my
> > report.
> >
> > this is my step :
> > I. crate a method in my report.
> > Process_InventSum(str _Branch, str _ItemGroup)
> > {
> >    InventSum           InventSum;
> >    InventTable         InventTable;
> >    tmp_mlr_invt_sum    tmpTable;
> >    ;
> >
> >    while select sum(postedqty), sum(deducted) from inventSum
> >    join inventTable group by itemgroupid
> >    where inventsum.ItemId==inventtable.ItemId
> >    {
> >             tmpTable.ItemGroupId = inventTable.ItemGroupId;
> >             tmpTable.InventQtyPosted = inventsum.PostedQty;
> >             tmptable.InventQtyDeducted = inventsum.Deducted;
> >             tmptable.insert();
> >           }
> >      
> > return tmpTable;
> > }
> >
> > II. Override method Fetch in that report
> > public boolean fetch()
> >       {
> >           queryrun    qr;
> >           boolean     ret;
> >           Tmp_mlr_invt_sum    _tmpTab;
> >           ;
> >      
> >           if (element.args().caller())
> >           {
> >               cls_InvSum = element.args().caller();   // calling
> class
> >               BranchId = cls_InvSum.parmBranch();
> >               ItemGroup = cls_InvSum.parmItemGroup();
> >           }
> >      
> >           //insert data to temp table
> >           this.Process_InventSum(BranchId,ItemGroup);
> >            
> >           while select * from _tmpTab
> >           {
> >               DS_Tmp_MLR_Invt_Sum = qr.get(tablenum
> > (tmp_mlr_invt_sum));
> >     
> >               element.send(DS_Tmp_MLR_Invt_Sum);
> >               ret = true;
> >           }
> >      
> >           return ret;
> > }
> >
> > It seems the insert method running (I trace it in debug), but in my
> > fetch method, in statement "while select .... ", they just pass it
> > like there is no record in my table.
> >
> >
> > rgds,
> > Anton
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Sponsor
> >
> > ADVERTISEMENT
> > click here
> <http://us.ard.yahoo.com/SIG=129p8n7j6/M=294855.5468653.6549235.300117
> 6/D=groups/S=1705006764:HM/EXP=1103615058/A=2455396/R=0/SIG=119u9qmi7/
> *http:/smallbusiness.yahoo.com/domains/>
> >
> >  <http://us.adserver.yahoo.com/l?
> M=294855.5468653.6549235.3001176/D=groups/S=:HM/A=2455396/rand=5091559
> 80>
> >
> > 
> >
> > ________________________________
> >
> > Yahoo! Groups Links
> >
> > *      To visit your group on the web, go to:
> >       http://groups.yahoo.com/group/development-axapta/
> >        
> > *      To unsubscribe from this group, send an email to:
> >       [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]
> subject=Unsubscribe>
> >        
> > *      Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/> .
> >
> >
> >
> > [Non-text portions of this message have been removed]







Yahoo! Groups Links













Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to