DEFINE SHARED TEMP-TABLE in Class .NET [Progress Developer S

Posted by Robert Timothy on 28-Apr-2016 23:13

Hi guys, I'm new in this forum and want to ask your advice about TEMP-TABLE in PDSOE 11.

I have a migration project from .p to .cls. It seems that TEMP-TABLE can't be defined to PUBLIC and SHARED TEMP-TABLE is not allowed either.

Is there any workaround to make TEMP-TABLE in a class to be "SHARED/PUBLIC"?

Thank you.

All Replies

Posted by Mark Davies on 29-Apr-2016 00:43

Hi Robert,

It probably depends on what your intention is with this temp-table. If it used to be shared it probably means that you needed to somehow share the data between different procedures in a session?

So, a few ways depending on how you intend to use your temp-table:

1. You can define it in your class and have a method to output the temp-table to whatever else needs it. You would probably do this as BY-REFERENCE / BIND - you will have to share the instance of the object with your temp-table in it

2. If this is session-wide you might want to make it STATIC and use it that way

3. Go all OO on it and create a class object that does all the work on the temp-table, such as CRUD and worker methods and then only interact with the class to work on the temp-table. This class would probably be static or you alternatively you just need to keep your instance available throughout the session or processes where you need it.

When migrating to OO it is always best to plan ahead - this takes a bit more time, usually much more than what you are used to with procedural coding, but it allows you to break it up into smaller components that makes them far more reusable in the end.

Hope that helps

Posted by Simon L. Prinsloo on 29-Apr-2016 00:50

If you need access to it in derived classes, you can make it protected.

If you need the "SHARED" effect, you define it normally in the code where it would normally be "NEW SHARED" and you define it REFERENCE-ONLY in the code where you will reference it. (The definition of the TEMP-TABLE / DATASET is the only place left n the language where I prefer to use include files.)

There after you bind to it by passing it as a parameter TABLE .... BIND. 

Another way will be to have the full definition on both side and pass the table as a proper table and then pass it as parameter TABLE .... BY-REFERENCE. This prevents the table from being copied and just pass the reference, but it is more prone to problems where you invoke one method an work with the passed table, but end up referencing the empty local table in a later call. It is however much more flexible in that it allows you to pass TABLE-HANDLES on either side (or both), enabling you to make more generic code.

Posted by Thomas Mercer-Hursh on 29-Apr-2016 09:10

Please don't.  The whole idea of OO is encapsulation of behavior within an object.  The TT should be an implementation detail which you are free to change latter without impacting any of the classes which use this class.  You should provide methods which perform the needed operations on the temp-table and leave the TT entirely internal to the class.

As Simon notes, the one possible exception, which is not actually an exception, is access by subclasses, but even there proceed with caution.

Posted by marian.edu on 29-Apr-2016 10:14

Finally, was about to say amen to that but then thought about what the Darwin equivalent will be :)


Don’t see why peoples seems to be under impression that by simply moving from procedural to OO their code simply will become somehow better… yet, they just try to replicate the same situation they had before, how is that going to be any better and why it’s worth the effort beats me.

For me a static property (unless is a constant, public read only) is as worst as a shared variable :)

Marian Edu

Acorn IT 
+40 740 036 212

Posted by Robert Timothy on 02-May-2016 02:34

Thank you for your advice especially on BY-REFERENCE / BIND and methods, I just figured out how to send-and-get TEMP-TABLE field by using a "Global Class". It takes more time to collect and distinct which variable or TEMP-TABLE that can be re-use in other classes. But I believe that it can save more time in the future.

Thank you,

Robert Timothy

This thread is closed