2016 Apr 05 7:45 AM
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?
2016 Apr 05 8:06 AM
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
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
2016 Apr 05 8:06 AM
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
2016 Apr 06 1:42 PM
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
2016 Apr 05 8:25 AM
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.
2016 Apr 05 2:04 PM
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
2016 Apr 05 7:55 PM
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".
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |