AX – D365FO – How to use Normal Table as Temp Table?

setTmp() : has nothing to do with deletion at all. It turns a buffer to a temporary one, therefore it saves records to memory/on disk instead of into database. If you delete everything from the temporary buffer, it doesn’t delete anything in database, obviously.

So any data manipulations will be lost once the execution of this method is over and actual table content will not be affected.

Will use doInsert() to bypass any validation rules which are not required for temporary table.

As an example, we will use the vendor table to insert and display a couple of temporary
records without affecting actual data.

1. In AOT, create a new class called VendTableTmp with the following code:


class VendTableTmp
{
}
server static void main(Args _args)
{
   VendTable vendTable;

   vendTable.setTmp();
   vendTable.AccountNum = ’1000′;
   vendTable.Name = ‘Vendor 1′;
   vendTable.PartyId = ’1′;
   vendTable.doInsert();
   vendTable.clear();
   vendTable.AccountNum = ’1002′;
   vendTable.Name = ‘Vendor 2′;
   vendTable.PartyId = ’2′;
   vendTable.doInsert();
   while select vendTable
   {
    info(strfmt(“%1 – %2″,vendTable.AccountNum,vendTable.Name));
   }
}

2. Run the class to see results:

1000 Vendor 1

1002 Vendor 2

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...