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

Variable Procedure Name

Former Member
0 Likes
681

Is there a way to call a procedure name based on a variable. I.e.


  procname = 'proc1'.
    perform procname.

form proc1.
*  do something.
endform.

I want to do this to avoid a bunch of case statements.

1 ACCEPTED SOLUTION
Read only

raviprakash
Product and Topic Expert
Product and Topic Expert
0 Likes
653

Hi Jerry,

Its possible to call a FORM by passing the name of the FORM to a variable. Here is the code:-

<b>DATA: lv_frm(30) TYPE c.

lv_frm = 'TEST_PERFORM'.

PERFORM (lv_frm) in program (sy-repid).

&----


*& Form test_perform

&----


  • text

----


FORM test_perform.

WRITE 'DONE'.

ENDFORM. "test_perform</b>

NOTE: I have tested the code and it works. Also please reward points if you are satisfied with the solution :).

Thanks and regards,

RAVI .

6 REPLIES 6
Read only

ferry_lianto
Active Contributor
0 Likes
653

Hi,

Please try this.

v_procname = 'proc1'.

perform procname using v_procname.

form procname using p_procname.

  • do something.

endform.

Regards,

Ferry Lianto

Read only

0 Likes
653

Thanks for the response. I don't think that's what I need.

Given


loop at itab into l_s_xx
 case l_s_xx-id.
   when 'abc' .
     perform abc.
   when 'def'.
     perform def.
...
...
  endcase.

I

want to just call a procedure that has the same name as the value of the field being evaluated without having to call it specifically.

Thanks for any help.

Read only

raviprakash
Product and Topic Expert
Product and Topic Expert
0 Likes
654

Hi Jerry,

Its possible to call a FORM by passing the name of the FORM to a variable. Here is the code:-

<b>DATA: lv_frm(30) TYPE c.

lv_frm = 'TEST_PERFORM'.

PERFORM (lv_frm) in program (sy-repid).

&----


*& Form test_perform

&----


  • text

----


FORM test_perform.

WRITE 'DONE'.

ENDFORM. "test_perform</b>

NOTE: I have tested the code and it works. Also please reward points if you are satisfied with the solution :).

Thanks and regards,

RAVI .

Read only

0 Likes
653

Very satisifed!! Ten points to Ravi.

Read only

raviprakash
Product and Topic Expert
Product and Topic Expert
0 Likes
653

Thanks Jerry

Read only

raviprakash
Product and Topic Expert
Product and Topic Expert
0 Likes
653

In the example i gave above, you can use the variable LV_FRM to carry different FORMNAMES.

Thanks and regards,

Ravi :).

.