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

calling program

Former Member
0 Likes
2,579

hi guys,

suppose , we have 2 report programs, 'X' and 'Y'.

Now, progam 'X' is getting executed, during the execution, we submit program 'Y', later the control is taken back.

The issue i have is , during the execution of program 'Y' ,i want to know whether the program 'Y' is executed by itself or the program 'Y' is called from another program(like progam 'X' ).

If program 'Y' is called from another program, how can i know the name of the calling program???

plz help me as soon as possible...

points will be rewarded....

thnx, shivaa...

9 REPLIES 9
Read only

Former Member
0 Likes
1,903

check whether the program name is passing with the variable in the submit.

Read only

Former Member
0 Likes
1,903

Hi Shiva,

We can achieve this by using the system variable SY-CPROG.

SY-CPROG gives the name of the calling program.

Hope this helps you. \[removed by moderator\]

Any queries, get back to me.

Regards,

Chandra Sekhar

Edited by: Chandrasekhar Gandla on Jun 30, 2008 7:26 PM

Edited by: Jan Stallkamp on Jul 1, 2008 4:32 PM

Read only

Former Member
0 Likes
1,903

no, chandra sy-cprog is not showing correct value...

from program 'X', we call program 'Y'.

at some point in program, 'Y' I keep debug-point and check for sy-cprog value..instead of program 'X'., we r getting program 'Y'.

can you guys suggest me another way.....

Read only

0 Likes
1,903

May be u can use FM SYSTEM_CALLSTACK. By reading the call stack u can find out whether prog. Y is called by some other prog. or not.

CALL FUNCTION 'SYSTEM_CALLSTACK'

IMPORTING

ET_CALLSTACK = t_syst.

Regards,

Joy.

Read only

Former Member
0 Likes
1,903

Hello shivaprasad,

If you want to know whether your program 'Y' is executed by another then the system field is:

SY-CALLD

It contains X if the program was started using CALL TRANSACTION, CALL DIALOG, or SUBMIT u2026 [AND RETURN]. Space if the program was started using LEAVE TO TRANSACTION or using a transaction code from a screen. SY-CALLD is always space when a batch input session is being processed.

If you want to know what program has called your program then the system field is:

SY-CPROG

It contains the name of the calling program in an external routine, otherwise the name of the current program.

you can also check this system field SY-REPID

It returns the 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.

Hope you find it useful

Regards

Indu.

Edited by: Indu Rayepudi on Jun 30, 2008 7:42 PM

Read only

Former Member
0 Likes
1,903

no luck again, sy-cprog is giving the value of 'Y', not 'X'.

i dont understand why???

in program 'X', v have stmt---> submit Y and return.

when, program 'Y', is running i keep debug point and check for value sy-cprog, its still showing 'Y',not 'X'.

Read only

0 Likes
1,903

Try to call FM SYSTEM_CALLSTACK from prog. Y and in debug mode check the table t_syst's content.If should have an entry that indicates from where this prog. is getting called.

CALL FUNCTION 'SYSTEM_CALLSTACK'

IMPORTING

ET_CALLSTACK = t_syst.

Regards,

Joy.

Read only

Former Member
0 Likes
1,903

even wid FM SYSTEM_CALLSTACK, i am not getting 'X' value.....

Read only

0 Likes
1,903

Can you pl. tell me what are the entries u r getting when then the prog is called from another prog. in table t_syst?

CALL FUNCTION 'SYSTEM_CALLSTACK'

IMPORTING

ET_CALLSTACK = t_syst.