on 08-25-2009 3:27 AM
can I do the calculation in SAPScript form directly?
i want to do the calculation like this, (to show the unit price is divided by
&UPRICE& = &KOMVD-KBETR& / &KOMVD-KPEIN&
but it seems not work when i type this statement in the form (SE71)
how can i do?
or need to write in Program and pass the value to the form?
if need to wrie program, how can I loop it to get the unit price of the item, coz it don't point to the KOMVD-KSCHL..(means its value is empty)..
Hi sky,
you can perform calculations using subroutines.
Just go through this link, I hope it will help you.
[Subroutines|http://help.sap.com/saphelp_nw70/helpdata/en/d1/803279454211d189710000e8322d00/frameset.htm]
Regards,
Nidhi Kothiyal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Call a subroutine from your script and do the calculation and returened back the calculated value of price from subroutine.
Do like this
Code to be written in script
Perform f0100_calc in program ztest
Using &VA1&
Changing &VAR2&
endperform
Code to be written in program ztest (subroutine pool)
FORM f0100_calc TABLES p_input_table STRUCTURE itcsy (table to hold the values passed from script)
p_output_table STRUCTURE itcsy. (table to hold the values passed to script)
READ TABLE p_input_table WITH KEY name = u2018VAR1 (should be in samecase as in script').
If sy-subrc = 0.
VAR1 = VAR1 * 100 (do whatever calculation you want)
Endif.
READ TABLE p_output_table WITH KEY name = u2018VAR2'
IF sy-subrc = 0.
MOVE VAR1 TO p_output_table-value.
MODIFY p_output_table INDEX sy-tabix.
Endif.
Endform.
Hope this will help you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can not do any mathematical calculations in Script directly.
However, this can be done by using subroutine. You can either define a subroutine in the driver program or in any other program. And then you can call this subroutine in your script.
/:PERFORM calculate IN PROGRAM zcalculate
/:USING &fre_chrg&
/:CHANGING &netval&
/:ENDPERFORM
rgrds,
Shweta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Please try to code like this
PERFORM GET_PAY_OEXPL IN PROGRAM Z_report
USING &ZTERM1&
USING &ZTERM2&
CHANGING &Zsum&
then in report (subroutine )
code for the sum of these two number
regards
prashant.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sky,
If you need to do some few 1 line calculations in SAP Script , you can do it in the Script itself.There is no need to call a routine for that.Use Command Line symbol in the script and write your code .
For Eg :-
/: IF &UPRICE& = '0'.
/: &UPRICE& = &KOMVD-KBETR& / &KOMVD-KPEIN&
/: ENDIF.
Regards ,
Samreen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
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.
Thanks
manish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.