‎2006 Oct 19 3:29 PM
Hi all,
in a function module call I want to pass the calling report's name as an import parameter. I want to do this dynamically so that the 'call function ....' code can be copied to any report.
I found two SY-fields, sy-repid and sy-cprog. So far both always contain the running report's name.
Is there an important difference between the two? Is one perhaps deprecated?
Regards,
Eric
‎2006 Oct 19 3:35 PM
Hello,
If you use sy-repid in the FM, you're always the function group of the FM.
You need to pass an input parameter with sy-repid value to have the right calling program in the FM.
Regards
sebastien
‎2006 Oct 19 3:32 PM
Hi Eric,
SY-REPID:
Name of the current ABAP program. For externally-called procedures, it is the name of the main program of the procedure. If you pass SY-REPID as an actual parameter to an external procedure, the formal parameter does not contain the name of the caller, but that of the main program of the procedure. To avoid this, assign SY-REPID to an auxiliary variable and use that in the call, or use the system field SY-CPROG.
SY-CPROG:
The name of the calling program in an external routine, otherwise the name of the current program.
For more information, please check this links.
http://help.sap.com/saphelp_nw2004s/helpdata/en/7b/fb96c8882811d295a90000e8353423/content.htm
http://help.sap.com/saphelp_46c/helpdata/en/7b/fb96c8882811d295a90000e8353423/content.htm
Hope this will help.
Regards,
Ferry Lianto
‎2006 Oct 19 3:35 PM
‎2006 Oct 19 3:34 PM
From help.....
SY-CPROG
In externally called procedures, the name of the calling program, otherwise the name of the current program. If an externally called procedure calls another external procedure, SY-CPROG keeps the name of the first main program and is not given the name of the main program of the further caller.
SY-REPID
Name of current ABAP program. With externally called procedures this is the name of the procedures main program.
If SY-REPID was transferred to an external procedure as an actual parameter before Release 6.10, the formal parameter was not given the name of the caller, but the name of the procedures main program. SY-REID had to be transferred to an auxiliary variable before the call or you had to use SY-PROG.
As of Release 6.10, SY-REPID is a separate constant that is no longer part of the structure SYST or SY. It can be transferred to external procedures directly.
Regards,
Rich Heilman
‎2006 Oct 19 3:35 PM
Hello,
If you use sy-repid in the FM, you're always the function group of the FM.
You need to pass an input parameter with sy-repid value to have the right calling program in the FM.
Regards
sebastien
‎2006 Oct 19 3:35 PM
SY-REPID : It is name of the current program
SY-CPROG : Name of the calling program. It would be same as SY-REPID if it is the current program.
But for example check the below.
REPORT ZREP.
start-of-selection.
write : / sy-repid, sy-cprog.
submit zrep1 and return.
REport zrep1.
start-of-selection.
write : / sy-repid, sy-cprog.
The output would be.
zrep zrep
zrep1 zrep