[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.axapta.programming

Looping through table buffer multiple times

Christoph Malherbe

12/20/2005 12:49:00 PM

Hi all,

How does one reset the cursor position in a table buffer if one wanted to
process the table buffer twice in a while loop?

Example

CustTable tableBuffer;

;

while (tableBuffer)
{}

tableBuffer.???? //reset position in table buffer

while (tableBuffer)
{}

Regards,

--
Christoph Malherbe
Solutions Architect
xpedia consulting
Cell: +27 82 805 0776
www.xpedia.co.za
3 Answers

mortenm

12/20/2005 1:50:00 PM

0

Hi,

Why do you need to reset it? You could do it like this example:

static void Job1(Args _args)
{
CustTable custTable;
;

while select custTable
where custTable.CustGroup == "TRANSP"
{
info(strfmt("Loop 1: %1 %2",
custTable.AccountNum,
custTable.Name));
}

while select custTable
where custTable.CustGroup == "TRANSP"
{
info(strfmt("Loop 2: %1 %2",
custTable.AccountNum,
custTable.Name));
}
}

Regards,
Morten Mile
"Christoph Malherbe" wrote:

> Hi all,
>
> How does one reset the cursor position in a table buffer if one wanted to
> process the table buffer twice in a while loop?
>
> Example
>
> CustTable tableBuffer;
>
> ;
>
> while (tableBuffer)
> {}
>
> tableBuffer.???? //reset position in table buffer
>
> while (tableBuffer)
> {}
>
> Regards,
>
> --
> Christoph Malherbe
> Solutions Architect
> xpedia consulting
> Cell: +27 82 805 0776
> www.xpedia.co.za

Christoph Malherbe

12/20/2005 2:03:00 PM

0

Hi Morten,

I'm looking for the equivalent of .moveFirst etc. on an ADO recordset.

Why? Couple of reasons, curiosity and laziness being two of them. }-)
--
Christoph Malherbe
Solutions Architect
xpedia consulting
Cell: +27 82 805 0776
www.xpedia.co.za


"mortenm" wrote:

> Hi,
>
> Why do you need to reset it? You could do it like this example:
>
> static void Job1(Args _args)
> {
> CustTable custTable;
> ;
>
> while select custTable
> where custTable.CustGroup == "TRANSP"
> {
> info(strfmt("Loop 1: %1 %2",
> custTable.AccountNum,
> custTable.Name));
> }
>
> while select custTable
> where custTable.CustGroup == "TRANSP"
> {
> info(strfmt("Loop 2: %1 %2",
> custTable.AccountNum,
> custTable.Name));
> }
> }
>
> Regards,
> Morten Mile
> "Christoph Malherbe" wrote:
>
> > Hi all,
> >
> > How does one reset the cursor position in a table buffer if one wanted to
> > process the table buffer twice in a while loop?
> >
> > Example
> >
> > CustTable tableBuffer;
> >
> > ;
> >
> > while (tableBuffer)
> > {}
> >
> > tableBuffer.???? //reset position in table buffer
> >
> > while (tableBuffer)
> > {}
> >
> > Regards,
> >
> > --
> > Christoph Malherbe
> > Solutions Architect
> > xpedia consulting
> > Cell: +27 82 805 0776
> > www.xpedia.co.za

Luegisdorf

12/20/2005 3:03:00 PM

0

Hi Christoph

The example from Morten is the prefred way to select records in Axapta. As I
know there are no function like moveFirst and so on. But you can use a query
object instead a simple buffer:

queryRun queryRun;
query query = new query();

CustTable custTable;
;
query.addDataSource(tablenum(CustTable));

while (queryRun.next())
{
custTable = queryRun.get(tablenum(CustTable));
// do something with the buffer ...
}

queryRun.reset()

while (queryRun.next()) // another loop process
{
custTable = queryRun.get(tablenum(CustTable));
// do something other with the buffer ...
}

You talked about curiosity of existing double records? This should not
happen; but there are problems with ä and a, u and ü a.s.o. because axapta
doesn't make differences between ä and a but SQL makes it. That means if you
have the following statement:

select firstonly custTable where custTable.AccountId = 'a';

... can retrieve the customer with the AccountId 'ä' (of course, if a
customer with this ID exists). If that's the problem you may be fighting
with, I highly recommend to avoid from having existing keys with a and ä
(like "Maier" and "Mäier").

Best regards
Patrick



"Christoph Malherbe" wrote:

> Hi Morten,
>
> I'm looking for the equivalent of .moveFirst etc. on an ADO recordset.
>
> Why? Couple of reasons, curiosity and laziness being two of them. }-)
> --
> Christoph Malherbe
> Solutions Architect
> xpedia consulting
> Cell: +27 82 805 0776
> www.xpedia.co.za
>
>
> "mortenm" wrote:
>
> > Hi,
> >
> > Why do you need to reset it? You could do it like this example:
> >
> > static void Job1(Args _args)
> > {
> > CustTable custTable;
> > ;
> >
> > while select custTable
> > where custTable.CustGroup == "TRANSP"
> > {
> > info(strfmt("Loop 1: %1 %2",
> > custTable.AccountNum,
> > custTable.Name));
> > }
> >
> > while select custTable
> > where custTable.CustGroup == "TRANSP"
> > {
> > info(strfmt("Loop 2: %1 %2",
> > custTable.AccountNum,
> > custTable.Name));
> > }
> > }
> >
> > Regards,
> > Morten Mile
> > "Christoph Malherbe" wrote:
> >
> > > Hi all,
> > >
> > > How does one reset the cursor position in a table buffer if one wanted to
> > > process the table buffer twice in a while loop?
> > >
> > > Example
> > >
> > > CustTable tableBuffer;
> > >
> > > ;
> > >
> > > while (tableBuffer)
> > > {}
> > >
> > > tableBuffer.???? //reset position in table buffer
> > >
> > > while (tableBuffer)
> > > {}
> > >
> > > Regards,
> > >
> > > --
> > > Christoph Malherbe
> > > Solutions Architect
> > > xpedia consulting
> > > Cell: +27 82 805 0776
> > > www.xpedia.co.za