‎2010 Jul 14 7:28 AM
Hi Friends,
I have a requirement such that, based on some conditions, a = b + c, or a = b + d, or a = a - c, or a = a + c, and so on... All variables are of currency type (13,2).
Now, the logic of this condition-based equation comes from table ( i.e. if a = a - c, then 'a' , '-' and 'c' are maintained in a custom table).
I want to populate a text by concatenating 'a' '-' 'c' such that the text equals 'a - c'. Now I want to equate a with text (a = text )to get the value as that of (a - c).
If you can throw some light on this please...
Thanks in advance,
Birendra
‎2010 Jul 14 8:01 AM
Hi,
You can achieve this by using field symbols... Just analyze the following sample code..
PARAMETER : w_a TYPE i
, w_b TYPE i
, w_symbol TYPE c
.
DATA : w_text_A(10) TYPE c
, w_text_B(10) TYPE c
, w_c TYPE i
.
FIELD-SYMBOLS : <FS_A>,<FS_B>,<FS_C>.
w_text_A = 'W_A'.
w_text_B = 'W_B'.
WRITE : w_a, w_b, w_c.
WRITE /.
ASSIGN (w_text_A) TO <FS_A>. " assigns the value of field name(w_a) contained in variable(w_text_a)
ASSIGN (w_text_b) TO <FS_B>. " assigns the value of field name(w_b) contained in variable(w_text_b)
CASE W_SYMBOL.
WHEN '-'.
W_C = <FS_A> - <FS_B>.
WHEN '+'.
W_C = <FS_A> + <FS_B>.
WHEN '/'.
W_C = <FS_A> / <FS_B>.
WHEN '*'.
W_C = <FS_A> * <FS_B>.
WHEN OTHERS.
ENDCASE..
WRITE : w_a, w_b, w_c.
copy paste to SE38 and try.You will get what you want.....
Thanks and Regards,
Senthil Kumar Anantham..
‎2010 Jul 14 9:06 AM
‎2010 Jul 14 9:18 AM