Calling a Method in a class dynamicly using dynamic-function - Forum - OpenEdge Development - Progress Community

Calling a Method in a class dynamicly using dynamic-function

 Forum

Calling a Method in a class dynamicly using dynamic-function

This question is not answered

11.3 --> 11.7

After converting to 11.7 the following statement seems to give an error:

User-defined function 'getMsgQueueProperty' invoked dynamically but could not be found. (5639) Procedure:"ProcessMessageReadyIn oomsg.msgQueue"

the statement is:

      dtzDocumentDate            = datetime-tz(dynamic-function("getMsgQueueProperty" in source-procedure,msgQueue.msgQueueGID,'DocumentDate'))

-------------

This is how it is called:

* msgQueue.cls has the Method getMsgQueueProperty.

in msgQueue there is another method that calls:

oDocument = NEW msgDocument(oMeasuringTicket,msgQueue.msgQueueGID).

in msgDocument I need to Call the method getMsgQueueProperty and untill now it has worked using dynamic-function(....

How would I do this now in 11.7 ? I want to Call a method in the Source-procedure (witch is a class).

All Replies
  • Here it is:

    Two classes, A and B.

    Class A:

    def property AGuid as char ....

    constructor ()

    Method Public logical doStuff ():

    :

    : some stuff that sets the AGUID property....

    :

    oB = New B (THIS-OBJECT).

     Return somestuff.

    END.

    Method Public character getStuff (input icGID as char, input icName as char):

     :

     Return theReturn.

    END.

    Class B:

    constructur (input oA as class A):

     find somestuff where iID = oA:AGuid...... no-lock ....

     aVariable = oA:getStuff('Something',aintegerfromthefind).

    end.

    I am not sure if this made it more informativ....:-) but I need to Reference the class A from within class B.

  • Obviously, there is SomeStuff missing, but one of the questions was the scope of oB, which I don't see defined anywhere.

    Personally, I avoid doing things in constructors that could possibly fail, e.g., newing another class.  If the constructor fails, you are left with an undefined reference.  You might try moving such things to an Initialize method, both for this reason and because it might making it more clear.

    Is somestuff a temp-table or DB table or what?  What is it's scope?  (I encapsulate TTs within a class).

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • In fact, I meet the same issues here, dynamic-function not work for the source-procedure of a class,

  • I meet the same issue here. We use the source-procedure handle for a class, Dynamic-function(method name, sour-procedure for a class). This works before 11.7, but it fails in 11.7. Could anyone give me some advice? Otherwise, we might change too many codes in our application

  • Sorry Thomas, there is a lot of stuff going on, and the class A is started from another program with

    CLASS A INHERITS Ahelper  USE-WIDGET-POOL:.....

       FINALLY:

         DELETE OBJECT B  NO-ERROR.

       END FINALLY.

    The same is within class B, everything is deleted.

    The somestuff is a Find that sends back the result to B. I have done a workaround by putting the same method in B so that it will work, but I would like to have that method in A....

  • ..Just want to know, has the original issue that dynamic-function not work for a source-procedure of a class been resolved..

    Thanks!

  • Where is that finally block?
     
    In A’s constructor, a method, the destructor?
    Von: goo [mailto:bounce-goo@community.progress.com]
    Gesendet: Dienstag, 8. August 2017 09:24
    An: TU.OE.Development@community.progress.com
    Betreff: RE: [Technical Users - OE Development] Calling a Method in a class dynamicly using dynamic-function
     
    Update from Progress Community
     

    Sorry Thomas, there is a lot of stuff going on, and the class A is started from another program with

    CLASS A INHERITS Ahelper  USE-WIDGET-POOL:.....

       FINALLY:

         DELETE OBJECT B  NO-ERROR.

       END FINALLY.

    The same is within class B, everything is deleted.

    The somestuff is a Find that sends back the result to B. I have done a workaround by putting the same method in B so that it will work, but I would like to have that method in A....

    View online

     

    You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

    Flag this post as spam/abuse.

     

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • a

  • Ups... sorry Mike, the FINALLY Block is done in the Method...

  • OK.  Still confused as there are too many moving parts coming and going here.  I hope you realize that a FINALLY block is NOT a destructor block.  It will run immediately after the main body of the block completes.  Could that be your problem?

    You could try actually debugging this!  Step through each statement and watch the value of your variables.  Or use the Dynamic Object monitor and look to see what objects are coming and going at each statement.  I'm pretty convinced it is something in your code that is causing the problem, and not a bug.

  • I do realize that finally will do that, but if you all mean that THIS-OBJECT will be past correctly, it has to be something else.. 

    I see another question on the same topic has been added to the forum... others that has used dyn-func in source-procedure .. I am not alone :-)

    Sendt fra min iPhone

    Den 8. aug. 2017 kl. 14.59 skrev Laura Stern <bounce-stern@community.progress.com>:

    Update from Progress Community
    Laura Stern

    OK.  Still confused as there are too many moving parts coming and going here.  I hope you realize that a FINALLY block is NOT a destructor block.  It will run immediately after the main body of the block completes.  Could that be your problem?

    You could try actually debugging this!  Step through each statement and watch the value of your variables.  Or use the Dynamic Object monitor and look to see what objects are coming and going at each statement.  I'm pretty convinced it is something in your code that is causing the problem, and not a bug.

    View online

     

    You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

    Flag this post as spam/abuse.

  • You should NOT use SOURCE-PROCEDURE for classes. You should not use it to determine what the instantiating class is. It may do what you want today, but it is not intended to do that.
     
    If you want to know what class instantiated/NEW’ed this class, then pass that value in via a property  or constructor.
     
    If you want to publish something to the whole session, do a PUBLISH “event” IN a session super-procedure.
     
  • Seems like this has been misunderstood. I understand that we should not use source-procedure... I am only saying....

    Just forget it, I have found a workaround 

    Sendt fra min iPhone

    Den 8. aug. 2017 kl. 15.46 skrev Peter Judge <bounce-pjudge@community.progress.com>:

     Update from Progress Community
    <4TW97ZQFKRYJ-jpg_2D00_70x70x2-jpg>
    Peter Judge

    You should NOT use SOURCE-PROCEDURE for classes. You should not use it to determine what the instantiating class is. It may do what you want today, but it is not intended to do that.
     
    If you want to know what class instantiated/NEW’ed this class, then pass that value in via a property  or constructor.
     
    If you want to publish something to the whole session, do a PUBLISH “event” IN a session super-procedure.
     

    View online

     

    You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

    Flag this post as spam/abuse.

  • It seems that in the 11.7 progress, source-procedure for class is not supported. Our codes works well before 11.7 progress, we use the Dynamic-Function(method name, source-procedure for a class) in all our codes... Passing the instance will be a big trouble to change our codes... Source-procedure is only changed in 11,7, I am not sure whether progress is intended to change the  Source-procedure in 11.7 or only by mistakes during the 11.7

  • This Community post has discussed several aspects of your issue and has identified an object-oriented approach for resolving it.  However, to your question as to whether the ABL supports the use of source-procedure for classes the answer is, no it does not.

    During the initial design of the object-oriented extensions to the ABL, the development team discussed whether the invocation syntax should work for both the procedural ABL and the object-oriented ABL.  This approach was rejected.  It was for that reason that an ABL application RUNs an external procedure and NEWs a class and invokes an internal procedure via the “RUN IN” syntax and invokes a method via object-reference: method () syntax.  The intent was to allow both coding models to work seamlessly together but with different syntax.

    Your approach of using SOURCE-PROCEDURE to get access to the procedure handle underlying our implementation of an object instance took advantage of a bug in our implementation.  It was never our intent to support for such a facility.    The regression you observed was caused by a performance related change we made in 11.7.0.

    The OpenEdge development team needs to investigate this issue to close this loop hole in the invocation logic ensuring that an application cannot invoke a method using procedural constructs.

    Evan Bleicher

    Sr. Development Manager

    Progress Software