‎2008 Feb 15 6:41 PM
Hi all,
I need solution to execute a arithmatic operation which is stored in a variable.
For Example:
data : var type string.
var = ABS('-3').
Now by means of the variable var i need to get the absolute value of -3
ie my output should be 3 if i print the variable "var".
Please help.
Regards,
Vijayakumar
‎2008 Feb 15 6:47 PM
Hello,
Do like this.
REPORT ZV_SDN_3 .
DATA: STR TYPE STRING.
DATA: STR1 LIKE STR,
INT TYPE I,
LEN TYPE I.
STR = ABS('-3')..
LEN = STRLEN( STR ).
DO LEN TIMES.
IF NOT STR+INT(1) IS INITIAL.
IF STR+INT(1) CA '0123456789'.
CONCATENATE STR1 STR+INT(1) INTO STR1.
ENDIF.
ENDIF.
ADD 1 TO INT.
ENDDO.
WRITE: STR1.
Hope this will solve ur issue.
Cheers,
Vasanth
‎2008 Feb 18 2:10 PM
Hi,
I think my example has little bit of misguidance . The real concept is the formula is stored in the string.
i.e var = 'ABS('-3')'.
Now if i display the variable var , I need the output as 3.
Please help.
Regards,
Vijayakumar
‎2008 Feb 18 2:12 PM
‎2008 Feb 15 6:56 PM
You could generate ABAP code on the fly. Do F1 on GENERATE SUBROUTINE POOL.
Rob