‎2009 May 26 7:21 AM
hi all,
i have the sap script in which i want to add two variables so in that can i use this?
sum = var1 + var2.
is it possible?
if no then what is the alternate for this?
thanxx....
‎2009 May 26 7:31 AM
‎2009 May 26 7:34 AM
Yes very much possible.
You can write like this in the window where you want to perform the calculation.
/: DEFINE lv_var ____________ (what ever way you want).
or you can say
/: PERFORM calucalte_sum IN PROGRAM ZTEST_CALCULATE USING ____ CHANGING ____
and in the program ZTEST_CALCUALTE you can write the FORM, ENDFORM and pass it back to the script.
Regards,
S.Dakshna Nagaratnam.
‎2009 May 26 7:39 AM
one way is to create a program(ztest_add) and in the attributes declare it as sub routine pool in SE38.
u do ur calculation part here. and call this in ur sap script.
plz chk this link where it is explained:
http://help.sap.com/saphelp_470/helpdata/EN/d1/803279454211d189710000e8322d00/content.htm
‎2009 May 26 7:40 AM
Hi
In script need to code like this:
/: PERFORM GET_SUM IN PROGRAM Z_TEST
/: USING &VAR1&
/: CHANGING &VAR2&
/: CHANGING &SUM&
/: ENDPERFORM.
After this you can use the value &SUM& in that window
In program Z_TEST code like this :
FORM get_address TABLES input_tab STRUCTURE itcsy
output_tab STRUCTURE itcsy.
DATA: lv_sum LIKE bseg-dmbtr,
lv_var1 LIKE bseg-dmbtr,
lv_var2 like bseg-dmbtr.
READ TABLE input_tab WITH KEY name = 'VAR1'.
IF sy-subrc = 0.
lv_var1 = input_tab-value.
ENDIF.
READ TABLE input_tab WITH KEY name = 'VAR2'.
IF sy-subrc = 0.
lv_var2 = input_tab-value.
ENDIF.
lv_sum = lv_var1 + lv_var2.
READ TABLE output_tab WITH KEY name = 'SUM'.
IF SY-SUBRC = 0.
output_tab-value = lv_sum.
MODIFY output_tab TRANSPORTING value
WHERE name = 'SUM'.
ENDIF.
‎2009 May 26 7:43 AM
hi,
try this
/: PERFORM Sum IN PROGRAM ZSum
/: USING &var1&
/: USING &var2&
/: CHANGING &var3&
/: ENDPERFORM
‎2009 May 26 11:43 AM