Plex 2E

  • 1.  How to get the calling (Parent) function's name/Implementation name.

    Posted Feb 05, 2018 09:30 AM

    Hi. Is there a way to get the calling (Parent) function's name (or implementation name) in the called function (Child)? I have played with meta code and can get the child's name/implementation name and the functions it may call, but not what called it. ( FNC Calls FNC, FNC generated call to FNC, FNC meta calls FNC...)

     

    I have tried using the Generate and build Options - "generate usage triples" but no success. (We are on r7.2.1   (Build 24.001).)

     

    If not I will have to add additional parameters to the function and modify all places called. (Possible but not preferable.)  

     

    Thank you.



  • 2.  Re: How to get the calling (Parent) function's name/Implementation name.
    Best Answer

    Broadcom Employee
    Posted Feb 07, 2018 04:07 AM

    Note: This will work for only current function not parent. We will update on how to get parent's function IMPL name.

     

    Hi,

     

    To retrieve the implementation name of current function, please refer the Plex help topic 'Getting the Implementation Name of a Function' for details.

     

    For quick reference, below is help topic snippet:

     

    Getting the Implementation Name of a Function

     

    This example shows how you can retrieve the implementation name of the current function in order to display it on the screen at run-time:

     

    Seq Get Function's Implementation Name

    +For Each Property Target FNC impl name NME

      +++Define Field: Function id

      +++Set Value To Current Field: Function id

      ++Name Defined Field: Function Id, Panel<Function Id>

    Put Panel<Function Id>

     

    This code should be placed outside any meta-loops. This ensures that the current object of the initial +For Each Property Target loop is the function in which the code is placed.

     

    Thank you.


    Regards,

    Arun Painuly

    CA Technologies



  • 3.  Re: How to get the calling (Parent) function's name/Implementation name.

    Posted Feb 07, 2018 04:49 AM

    Thank you Arun for the reply.

    I am able to get the current function detail but not the function that called the current functions. There doesn't seem to be a way via meta data to do this.

     

    Thank you.



  • 4.  Re: How to get the calling (Parent) function's name/Implementation name.

    Posted Feb 08, 2018 09:14 AM

    Hi,

     

    Remember, meta code is executed at code generation time.  Even if meta code could somehow get this information, what happens if a function is called by more than one function?  At run time how would you know which is the correct one?

     

    If you have to add a parameter, it seems like this would be relatively easy if your functions inherit from a common abstract.  If not, you could create an abstract that has the Function name as an input parameter and have all of your existing functions inherit from it.  The abstract could also get the impl name or function name for the current function and load it into a local variable.  Then, map the local variable on the call to the next function.  Another way to make it easy is to use default parameter mapping based on variables.  Hope that helps.

     

    Dean Eshleman

    Everence



  • 5.  Re: How to get the calling (Parent) function's name/Implementation name.

    Posted Feb 08, 2018 09:23 AM

    Thank you Dean. That was what I was thinking, but when I saw the meta link "FNC meta calls FNC" I though that it may be possible.

     

    I added the "current function name" meta code to the parent functions (all 103) and added the additional parameter to the child function. 

     

    Thank you for your time.



  • 6.  Re: How to get the calling (Parent) function's name/Implementation name.

    Posted Feb 08, 2018 10:08 AM

    On the IBM-i you can use API functions (QWVRCSTK) to get the call stack.  You just have to remove the bottom one or two, and you should have the implementation name of what called the program.

    Getting the call stack can be fuzzy on client programs if you are using child sites, or non-modal dialogs.

     

    If you want this in all cases, you could add the parameter to your standards layer, and anything that inherited from it would have the parameter, and could have code to populate a field to map to the parameter.



  • 7.  Re: How to get the calling (Parent) function's name/Implementation name.

    Posted Feb 10, 2018 05:09 PM

    I think you will need to do this from the platform system interfaces - like Jeremy has mentioned for IBM i.

     

    Some ideas if you are generating for Windows environment:

     

    get the name of calling application