web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

populate tmp table from select statement then use it to populate another tmp table using query rdp

(0) ShareShare
ReportReport
Posted on by 47

Dear All,

I CREATED THIS PROCESS REPORT METHOD TO populate data on a temp table using select statement and then populate it to another temp table using query functions , but it can't populate my second temp table yet , would someone please help?

public void processReport()
{
    ADVChecks                     AdvChk  ;
    ADVCHKCheckStepsActual        AdvChekStpActul ;
    SG_NotesReceivableTmp       tmp ;
    
    TransDate                     NotesDate;
    ADVCHKStepID                  StepId ;
    ADVCHKStepType                Steptype ;
    ADVCHKStepGroupID             StepGroup ;
    ADVCheckGroupID               CheckGroup ;
    ADVCHKStepSequence              advseq ;







        // Query

        Query                   query;
        QueryRun                qr;
        QueryBuildDataSource    queryBuildDataSource , qbds , qbd;
        QueryBuildRange         queryBuildRange , qbr;
        QueryFilter  qf ;
        SG_NotesReceivableContract_Q    Contract ;

   Contract = this.parmDataContract();
   
   TmpDB.ADVCheckID 
   
   

    while Select AdvChk // 'Check_11-000010759'

    {

       while  select firstOnly AdvChekStpActul
        order by AdvChekStpActul.ADVCHKStepSequence desc
        where   AdvChekStpActul.ADVCheckID == AdvChk.ADVCheckID
          &&   AdvChekStpActul.TransDate <=  NotesDate
          &&   AdvChekStpActul.TransDate
          &&   AdvChekStpActul.Applied == 1

        {



        TmpDB.CustAccount =         AdvChk.CustAccount ;
        TmpDB.CustName =            AdvChk.CustName ;
        TmpDB.AmountCur =           AdvChk.AmountCur ;
        TmpDB.ADVNetAmount =        AdvChk.ADVNetAmount ;
        TmpDB.ADVCheckSource =      AdvChk.ADVCheckSource ;
        TmpDB.ADVCheckGroupID =     AdvChk.ADVCheckGroupID ;

        TmpDB.ADVCHKStepType =      AdvChekStpActul.ADVCHKStepType ;
        TmpDB.ADVCheckID =          AdvChekStpActul.ADVCheckID ;
        TmpDB.Voucher   =           AdvChekStpActul.Voucher ;
        TmpDB.ADVCHKStepID =        AdvChekStpActul.ADVCHKStepID ;
        TmpDB.TransDate =           AdvChekStpActul.TransDate ;
        TmpDB.ADVCHKStepGroupID =   AdvChekStpActul.ADVCHKStepGroupID ;
        TmpDB.ADVCHKStepSequence =  AdvChekStpActul.ADVCHKStepSequence ;
        TmpDB.LedgerName        =   DimensionAttributeValueCombination::getDisplayValue(AdvChekStpActul.LedgerDimension);
        TmpDB.LedgerDimension   = AdvChekStpActul.LedgerDimension ;



        TmpDB.insert() ;


            }
 }

     query = new Query();
      queryBuildDataSource = query.addDataSource(tablenum(SG_NotesReceivableTmp));
    
   qr = new QueryRun(query);
    qr.setRecord(tmp);
   
    while (qr.next())
    {
        tmp = qr.get(tablenum(SG_NotesReceivableTmp));
        
         TmpDB2.CustAccount =         tmp.CustAccount ;
        TmpDB2.CustName =            tmp.CustName ;
        TmpDB2.AmountCur =           tmp.AmountCur ;
        TmpDB2.ADVNetAmount =        tmp.ADVNetAmount ;
        TmpDB2.ADVCheckSource =      tmp.ADVCheckSource ;
        TmpDB2.ADVCheckGroupID =     tmp.ADVCheckGroupID ;

        TmpDB2.ADVCHKStepType =      tmp.ADVCHKStepType ;
        TmpDB2.ADVCheckID =          tmp.ADVCheckID ;
        TmpDB2.Voucher   =           TmpDB.Voucher ;
        

        TmpDB2.insert() ;


    }

}
        

I have the same question (0)
  • nmaenpaa Profile Picture
    101,172 Moderator on at

    Why can't you populate both temp tables at the same time?

    Anyway, when using temp tables with Query class, you must use QueryRun.setRecord(yourTempTable).

    www.schweda.net/blog_ax.php

  • m.salah297 Profile Picture
    47 on at

    because i want to filter the second one through query and i can't get the same filter on the first one through query

  • Verified answer
    Martin Dráb Profile Picture
    239,392 Most Valuable Professional on at

    For reference, this is clearly about the same thing as the thread filter a query after setting range. Here m.salah297 just decided not to use a query at all.

  • m.salah297 Profile Picture
    47 on at

    Dear all thanks it's done

  • nmaenpaa Profile Picture
    101,172 Moderator on at

    Could you please mark the helpful answer(s) as verified? Thanks! 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 606 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 356

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans