web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 32

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
    RE: How to Clear a Temp Table

    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,069 Most Valuable Professional on at
    RE: How to Clear a Temp Table

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,028

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 878 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 579 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans