Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Script Totals

Former Member
0 Kudos
108

Hi,

In my script im displaying the extended price.

extended price = (order qty * price)

extended price = (order qty * condition amount)

those r displaying correctly and based on that im doing sub totals using the perform.it's also fine.

here my problem is i need to calculate the totals(sum of all subtotals)

this total i need to display in footer.

here my question is how do i get totals.

In my requirement i have 2 possibilities.

1. the billing document may have the promocode or not.we r displaying the condition amount based on promo code.

if there is no promo code it's calculating the extended price (order qty * price)

so in this situation im not having the subtotal.

the extended price is stored in 'v_price'.

in this situation how do i get totals?

i coded in se71 like

in main window after displaying price

/: DEFINE &V_TOTAL&

/: &V_TOTAL& = &V_TOTAL& + &V_PRICE&

in footer

&V_TOTAL&

but i didn't get the value.is it correct process na or any process is there ?

Thanks,

Srinivas.

6 REPLIES 6

Former Member
0 Kudos
49

HI,

To calculate totals and sub totals in sap scripts you have to use subroutines.

Say if you have to add the unit price (KOMVD-KBERT) then in the main window whereever tat value is picked write this routine

/: DEFINE &TOT_PRICE&

/: PERFORM F_GET_PRICE IN PROGRAM <subroutine prog name> /:USING &KOMVD-KBERT& /:CHANGING &TOT_PRICE& /:ENDPERFORM

Then write the variable where ever you want it to be printed (mostly it will be in footer window)

Then create subroutine pool program and you have to write the code.

FORM F_GET_PRICE tables int_cond structure itcsy

outt_cond structure itcsy. data : value type kbert.

statics value1 type kbert.

Read int_cond table index 1.

value = int_cond-value.

value1 = value1 + value.

Read outt_cond table index 1.

outt_cond-value = value1.

Modify outt_cond index 1.

ENDFORM.

To know more, have a look at this thread ..

Kishore.

Former Member
0 Kudos
49

Hello Srinivas,

Chk the following link.It might solve your problem.

http://www.sap-img.com/sapscripts/sapscript-how-to-calculate-totals-and-subtotals.htm

REgards,

Vasanth

Former Member
0 Kudos
49

Hi Srini,

You need to write the Perform for this one, follow this one to get the totals .

Perform GET_TOTAL in Program < Program name >

using &V_TOTAL&

&V_PRICE&

changing &V_TOTAL&.

First Declare a Global Variable V_TOTAL in the Program , and write the FOrm and Endform .in between the Form and endform you need to caliculate and send back the result to the Script. then the total will be available in the Script

Regards

Sudheer

Former Member
0 Kudos
49

write a subroutine field as using and total field as changing

in this subroutine declare a variable as static variable

and add field every time and store it in static variable

Former Member
0 Kudos
49

Hi Kishore,

i tried for this also.my code is

/:DEFINE &V_EXTPR_TOT&

/:PERFORM GET_EXTPR_TOT IN PROGRAM ZSP_SD_ORDCM

/:USING &KOMVD-KBETR&

/:CHANGING &V_EXTPR_TOT&

/:ENDPERFORM

in footer im displaying the variable.

&V_EXTPR_TOT&

se38 coding

FORM get_extpr_tot TABLES it_input STRUCTURE itcsy it_output STRUCTURE itcsy.

DATA: v_extpr_tot TYPE kbetr.

STATICS v_extpr_tot1 TYPE kbetr.

READ TABLE it_input INDEX 1.

MOVE it_input-value TO v_extpr_tot.

v_extpr_tot1 = v_extpr_tot1 + v_extpr_tot.

READ TABLE it_output INDEX 1.

MOVE v_extpr_tot1 TO it_output-value.

  • WRITE v_extpr_tot1 TO it_output-value LEFT-JUSTIFIED.

MODIFY it_output INDEX 1.

*

ENDFORM. "GET_EXTPR_TOT

Former Member
0 Kudos
49

but i didn't get the value.