‎2007 Sep 17 7:44 AM
Hi,
How do we code for subtotal in sap script. The scenario is i have to total the extended price field (dmbtr) and that is subtotal.
Another doubt: how do i code division operator . ie. dividing quantity by extended price? in sap script i know i have to introduce a variable. kindly give me how do i code.
‎2007 Sep 17 7:59 AM
Hi,
Actually you cannot code division operator directly in the SAP Script form.SAP Script consists of two things i) SAP Script form(use SE71 to explore it) and ii) Driver program.
Script form(or) Layout set:
-
It specifies the layout of the output(where to put what).
Driver program:
-
It will have all the logic(for example selecting records from required tables for displaying the layout set and processing logic, for eg: Multiplication, division etc).
so, in your case you need to calculate the sub total in the driver program using a global variable and use the same variable name in the Layout set at the required position for printing the subtotal in output.
For eg: For your case consider w_qty(quantity variable), w_ext_prc(extended price) and if w_sub_tot is the subtotal field.
you can code the following logic in the driver program.
w_sub_tot = w_ext_prc / w_qty.
In the Layout set, you can use the &w_qty& to print the subtotal value in the output.
Hope this helps.....
‎2007 Sep 17 8:00 AM
hi,
u can use SUM keyword in script.
as
/: If &itab-pernr&.
/: sum.
/:
and to declare a variable use && as
for ex: &&suresh = 13.
/: write &&suresh.
if helpful reward some points.
with regards,
Suresh Aluri.
‎2007 Sep 17 8:10 AM
Hi,
Check the following link:
http://sap-img.com/sapscripts/sapscript-how-to-calculate-totals-and-subtotals.htm
Regards,
Bhaskar