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

Dynamic Perform not calling

Former Member
0 Likes
1,844

Hello all

There is something interesting i like to share with you all and get your ideas!!

this is about calling a perform dynmaically, its used very wide in SAP

here is a common form of use.

lets  say we have two reports: y_main and another report y_caller

inside y_main there is a form

report y_main.

form trigger.

break-point.

endform.

and inside the y_caller

report y_caller.

**Standard use!

perform trigger in program y_main if found.

this will work for sure!!

but what we want is dynamic call!!

DATA: lv_form_name type tnapr-ronam value 'TRIGGER',

           lv_prog_name type tnapr-pgnam value 'Y_MAIN'.

perform (lv_form_name) in PROGRAM lv_prog_name IF FOUND.

this code above will not work very interestingly!!!

but the code below works

DATA: ls_tnapr type tnapr.

ls_tnapr-ronam = lv_form_name.

ls_tnapr-pgnam = lv_prog_name.

perform(ls_tnapr-ronam) IN PROGRAM (ls_tnapr-pgnam) IF FOUND.

how come??

when you call with type of a structure the dynamic call works otherwise it wont!!

Did anyone see this before?

1 ACCEPTED SOLUTION
Read only

deependra_shekhawat3
Contributor
0 Likes
1,751

Hi Solen,

DATA: lv_form_name type tnapr-ronam value 'TRIGGER',

           lv_prog_name type tnapr-pgnam value 'Y_MAIN'.

perform (lv_form_name) in PROGRAM (lv_prog_name) IF FOUND.


i think , It will work now.  if same thing you will do with routine it won't work.




Regards

Deeps




Hello all

There is something interesting i like to share with you all and get your ideas!!

this is about calling a perform dynmaically, its used very wide in SAP

here is a common form of use.

lets  say we have two reports: y_main and another report y_caller

inside y_main there is a form

report y_main.

form trigger.

break-point.

endform.

and inside the y_caller

report y_caller.

**Standard use!

perform trigger in program y_main if found.

this will work for sure!!

but what we want is dynamic call!!

DATA: lv_form_name type tnapr-ronam value 'TRIGGER',

           lv_prog_name type tnapr-pgnam value 'Y_MAIN'.

perform (lv_form_name) in PROGRAM lv_prog_name IF FOUND.

this code above will not work very interestingly!!!

but the code below works

DATA: ls_tnapr type tnapr.

ls_tnapr-ronam = lv_form_name.

ls_tnapr-pgnam = lv_prog_name.

perform(ls_tnapr-ronam) IN PROGRAM (ls_tnapr-pgnam) IF FOUND.

how come??

when you call with type of a structure the dynamic call works otherwise it wont!!

Did anyone see this before?

5 REPLIES 5
Read only

deependra_shekhawat3
Contributor
0 Likes
1,752

Hi Solen,

DATA: lv_form_name type tnapr-ronam value 'TRIGGER',

           lv_prog_name type tnapr-pgnam value 'Y_MAIN'.

perform (lv_form_name) in PROGRAM (lv_prog_name) IF FOUND.


i think , It will work now.  if same thing you will do with routine it won't work.




Regards

Deeps




Read only

0 Likes
1,751

Interesting that i did not notice that !!

thanks guys

I will try that now

it makes good sense to me:)

ı was so sure that i did not miss anything

Read only

Former Member
0 Likes
1,751

Hello Solen,

I tried it on my end and it's working.

REPORT y_main.

FORM trigger.

breakpoint.

ENDFORM.

-----------------------------------------------------------------------------------------------

REPORT y_caller.

DATA: lv_form_name TYPE tnapr-ronam VALUE 'TRIGGER',

            lv_prog_name TYPE tnapr-pgnam VALUE 'Y_MAIN'.

PERFORM (lv_form_name) IN PROGRAM (lv_prog_name) IF FOUND.

Read only

0 Likes
1,751

trixa

in your example

you have tried in your own report

please try it on calling a form in another report

In mine it does not work

I do not think it will work on yours too

Read only

0 Likes
1,751

Solen,

Deependra and Trixa are right : when you use perform (lv_form_name) in PROGRAM lv_prog_name IF FOUND., SAP tries to call the standard program LV_PROG_NAME (if you start SE38, and display the program LV_PROG_NAME, you'll see it doesn't exist); it won't call the program whose name is in the variable lv_prog_name. That's a frequent error I do. Note that you added IF FOUND, which prevents a runtime error; if you remove IF FOUND, you'll see in the short dump that it says clearly "program LV_PROG_NAME does not exist".