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!
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.
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.
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
Tim, thank you for the reference to SOURCE-PROCEDURE. Your feedback on the limitations and risks associated with this HANDLE are duly noted.
SOURCE-PROCEDURE is extremely funny, when you call a .p from an object instance ......
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)