‎2007 Feb 23 8:41 PM
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.
‎2007 Feb 23 9:11 PM
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 .
‎2007 Feb 23 8:46 PM
Hi,
Please try this.
v_procname = 'proc1'.
perform procname using v_procname.
form procname using p_procname.
do something.
endform.
Regards,
Ferry Lianto
‎2007 Feb 23 8:51 PM
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.
‎2007 Feb 23 9:11 PM
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 .
‎2007 Feb 23 9:17 PM
‎2007 Feb 23 9:19 PM
‎2007 Feb 23 9:15 PM
In the example i gave above, you can use the variable LV_FRM to carry different FORMNAMES.
Thanks and regards,
Ravi :).
.