What is the proper process to determine what object called a

Posted by Rom Elwell on 19-Oct-2015 12:41

I have the procedure procFooBar.  procFooBar can be called from any number of runtime objects including other procedures.  I want to perform selective logic in procFooBar only if it is called by the entity with a NAME attribute value of 'O30032.r'.

What is the correct ABL logic to add to procFooBar to check if the calling resource has a NAME attribute value of 'O30032.r'?

Thank you!

Posted by Tim Kuehn on 19-Oct-2015 13:07

First, tying logic to a specific calling procedure is always a bad idea. You should either pass a class w/configuration options that'll allow you to do what you want, or find some other way to communicate that context.

Second, if you _really_ want to do this, the SOURCE-PROCEDURE handle'll return the handle to the _last procedure called_, so if you set & save it immediately after calling the .p you can adjust your logic's behavior accordingly. If you check this handle after another .p is run, then it'l have that procedure's value instead.

All Replies

Posted by Tim Kuehn on 19-Oct-2015 13:07

First, tying logic to a specific calling procedure is always a bad idea. You should either pass a class w/configuration options that'll allow you to do what you want, or find some other way to communicate that context.

Second, if you _really_ want to do this, the SOURCE-PROCEDURE handle'll return the handle to the _last procedure called_, so if you set & save it immediately after calling the .p you can adjust your logic's behavior accordingly. If you check this handle after another .p is run, then it'l have that procedure's value instead.

Posted by pliscki on 19-Oct-2015 13:19

Hi Rom and Tim,

Be careful when using SOURCE-PROCEDURE as it returns the last caller procedure, either internal or external. Therefore its return might not be what you're expecting for.

If you're using OE 10.0A or above  it's better to use the object's attribute INSTANTIATING-PROCEDURE .

i.e: THIS-PROCEDURE:INSTANTIATING-PROCEDURE

http://documentation.progress.com/output/OpenEdge102b/oe102bhtml/wwhelp/wwhimpl/js/html/wwhelp.htm#href=dvref/21dvref-A-M.20.482.html

Posted by Rom Elwell on 19-Oct-2015 13:20

Tim, thank you for the reference to SOURCE-PROCEDURE.  Your feedback on the limitations and risks associated with this HANDLE are duly noted.

Posted by Mike Fechner on 19-Oct-2015 13:29

SOURCE-PROCEDURE is extremely funny, when you call a .p from an object instance ......

Posted by Rom Elwell on 19-Oct-2015 13:34

I've narrowed the scope of the use case so that we will only make use of SOURCE-PROCEDURE when procFooBar is called from another procedure and not from an instantiated class (object)

This thread is closed