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, ...
Suggested Answer

How to Clear a Temp Table

(1) ShareShare
ReportReport
Posted on by 34

I'm trying to use a temp table as the data source for a report.  My challenge is that the table records are not clearing which is causing the number of labels that we end up printing to increase with every report run.

I've tried clear, delete and remove at the end of the below range phrase, but nothing is working.  The temp table has one index with 4 columns as shown below.  I've tried single table commands as well.  My goal with the below snippet is to end up with either an empty or missing TAS_Packing_Labels_TEMP.

range clear table TAS_Packing_Labels_TEMP;
clear field 'SOP Number' of table TAS_Packing_Labels_TEMP;
clear field 'SOP Type' of table TAS_Packing_Labels_TEMP;
clear field 'Component Sequence' of table TAS_Packing_Labels_TEMP;
clear field 'Line Item Sequence' of table TAS_Packing_Labels_TEMP;
range start table TAS_Packing_Labels_TEMP;
fill field 'SOP Number' of table TAS_Packing_Labels_TEMP;
fill field 'SOP Type' of table TAS_Packing_Labels_TEMP;
fill field 'Component Sequence' of table TAS_Packing_Labels_TEMP;
fill field 'Line Item Sequence' of table TAS_Packing_Labels_TEMP;
range end table TAS_Packing_Labels_TEMP;
clear table TAS_Packing_Labels_TEMP;

What am I doing wrong?

Categories:
I have the same question (0)
  • Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    The clear keyword clears any range set for the records, but doesn’t affect the table buffer. So you are missing remove command at the end of this 

    remove range table TAS_Packing_Labels_TEMP;

  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,137 Most Valuable Professional on at

    I would do 

    clear range table TAS_Packing_Labels_TEMP;

    remove range table TAS_Packing_Labels_TEMP;

    This will ensure there is no range (ranged to entire table) before removing the records.

    FYI.

    Rather than clearing and filling field by field when setting ranges, use clear table and fill table. It is simpler and future proof. If you ever add extra segments to the key, the code will still work without needing to be updated.

    See this article

    https://winthropdc.wordpress.com/2018/02/21/dexterity-future-proof-range-setting/

    Regards 

    David 

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans