‎2007 Jun 20 7:02 PM
Hi Expert,
is is possible to execute a command written in a variable string?
For example:
va_command type string.
A = 10.
B = 2.
C = 6.
va_command = '( A + B ) / C'.
RESULT = <i><b>EXECUTE</b></i> (va_command).
in result i have "2".
Any hints will be rewarded.
Thanks in advance.
Fabio.
‎2007 Jun 20 7:05 PM
‎2007 Jun 20 7:05 PM
‎2007 Jun 20 7:10 PM
Thanks for the response Rich!
I have to do the user the possibility to dynamycally change formula in a BW routine without maintain ABAP code or FOX formula...my idea is to write the Formula in an infoObject field and translate it in a abap commad in the routine.
‎2007 Jun 20 7:15 PM
Ok, not sure if this will help you or not, but its good to know anyway. Test this program, all it is doing is generating a program at runtime and calling a subroutine with the code in it.
report zrich_0001 .
types: t_source(72).
data: routine(32) value 'TEMP_ROUTINE',
program(8),
message(128),
line type i.
data: isource type table of t_source,
xsource type t_source.
data: a type i value 10,
b type i value 2,
c type i value 6,
result type i.
xsource = 'REPORT ZTEMP_PROGRAM.'. append xsource to isource.
xsource = 'FORM TEMP_ROUTINE using a b c result.'.
append xsource to isource.
xsource = 'result = ( a + b ) / c. '. append xsource to isource.
xsource = 'ENDFORM.'. append xsource to isource.
generate subroutine pool isource name program
message message
line line.
if sy-subrc = 0.
perform (routine) in program (program) using a b c result.
else.
write:/ message.
endif.
write:/ result.
Regards,
Rich Heilman
‎2007 Jun 20 7:18 PM
‎2007 Jul 02 7:27 PM
‎2007 Jun 20 7:14 PM
Hi,
You need to use subroutine or macro for this.
ex.
report z_test.
data : v_result type i.
define execute.
v_result = ( &1 + &2 ).
v_result = v_result / &3.
end-of-definition.
execute 3 3 3.
write : v_result.
aRs