Skip to Content

Dynamic Perform not calling

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?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 05, 2016 at 07: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




    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 05, 2016 at 07: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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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".