on 01-16-2007 12:12 PM
Hi Experts,
I want to do some small mathematical calculations in the Script form. I want to subtract one field vale from other field & display the result. How can i do it? I must write a procedure for that or is there any other method.
Regards
Rajendra
In the Script form u cannot do any caluclations, u can only assign values.
U can use perform and endperform, and do the required calculations in the program.
For the details abt the perform use the following link
http://help.sap.com/saphelp_47x200/helpdata/en/d1/803279454211d189710000e8322d00/frameset.htm
Let me know if u face any problem.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
Do the Calculation by writing a perform inside the SAPSCRIPT
perform calc in program ZPROGRAM using &W_INPUT1&
&W_INPUT2&
changing &W_OUTPUT&
In the ZPROGRAM.
FORM CALC TABLES INVAR STRCTURE ITCSY
OUTVAR STRCTURE ITCSY.
data: var1 type i,
var2 type i,
result yupe i.
READ TABLE INVAR with key FIELD = 'W_INPUT1'
if sy-subrc = 0.
var1 = INVAR-VALUE.
endif.
READ TABLE INVAR with key FIELD = 'W_INPUT2'
if sy-subrc = 0.
var2 = INVAR-VALUE.
endif.
Result = VAR2 - Var1.
READ TABLE OUTVAR with key FIELD = 'W_OUTPUT'
if sy-subrc = 0.
OUTVAR-VALUE = Result.
endif.
Modify OUTVAR index SY-Tabix.
ENDFORM.
So, in the SAPSCRIPT, the 'W_OUTPUT' will have the Difference of &W_INPUT1& and &W_INPUT2&
Regards
Sudheer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Do the Calculation by writing a perform routine inside the SAPSCRIPT
Sample Code
perform sub_calc in program <ZPROGRAM> using &W_INPUT1&
&W_INPUT2&
changing &W_OUTPUT&
and in the Program
FORM SUB_CALC TABLES INVAR STRCTURE ITCSY
OUTVAR STRCTURE ITCSY.
............ Your Code
ENDFORM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you ca nachive in two ways
1. doing the calculation in print program before displaying that.
2. writing the code in layout... editor by using the elemetn (NAME CALCULATE )there alos you can. call the elemet when u reqire. example as follows
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CALCULATE'
EXCEPTIONS
ELEMENT = 1
WINDOW = 2.
IF SY-SUBRC NE 0.
PERFORM PROTOCOL_UPDATE.
ENDIF.
Message was edited by:
Naresh Reddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.