4

I have a program called Test.p. The program calls another program ServerTest.p via an appserver call.

In ServerTest.p, I want to know the name of the program that called (in this case Test.p). I tried using the program-name() function but it only gives me a stack trace for the current appserver.

How can I find out what program called ServerTest.p?

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
briddums
  • 1,826
  • 18
  • 31
  • 1
    Why do you want to do this? On the face of it you would be adding coupling between the client and the app server and that would seem like a very bad idea. Much like when developers use program-name() to change behavior within a session. – Tom Bascom Mar 19 '15 at 16:09
  • @TomBascom Because I have a program that is called via Appserver and I wanted to get a stack trace to find out where an error was originating from – briddums Jul 07 '15 at 06:11

2 Answers2

0

A simple and basic solution is to use an input parameter.

ServerTest.p

DEFINE INPUT  PARAMETER wpic-name AS CHARACTER  NO-UNDO.

/* wpic-name = "Test.p" */

Test.p

RUN ServerTest.p(INPUT "Test.p").
doydoy44
  • 5,720
  • 4
  • 29
  • 45
  • This is not a very good solution since it requires changing calling program as well as called program. (But I cannot produce a better one myself at this moment)... – Jensd Mar 18 '15 at 09:31
  • @Jensd: Thank's for your return. I totally agree with you, but like you, I have no better. That's why I said it was basic. :) We can improve it with an include that uses program-name() function in all callers programs to be more dynamic. – doydoy44 Mar 18 '15 at 09:39
0

You could use SOURCE-PROCEDURE:FILE-NAME. So in your case you could use

    if SOURCE-PROCEDURE:FILE-NAME EQ "Test.p" or 
       SOURCE-PROCEDURE:FILE-NAME EQ Test.r"  then
    do:
Kidn3r
  • 1
  • 2