Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Difference between sy-repid and sy-cprog

Former Member
0 Likes
6,135

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,680

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

5 REPLIES 5
Read only

ferry_lianto
Active Contributor
0 Likes
2,680

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

Read only

0 Likes
2,680

Thank you very much

Read only

RichHeilman
Developer Advocate
Developer Advocate
2,680

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 procedure’s 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 procedure’s 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

Read only

Former Member
0 Likes
2,681

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

Read only

Former Member
0 Likes
2,680

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