‎2007 Sep 19 3:35 AM
‎2007 Sep 19 3:56 AM
You can use simple logic in print program :
you use internal table to get the data .
loop at itab.
at end of field.
calculate the values here.
call fm WRITE_FORM -> here use text element.
endat.
endloop.
use this text element in main window,now you will get sub totals.
Thanks
Seshu
‎2007 Sep 19 4:24 AM
hi,
data amt_sum like vbak-netwr value 0.
loop at l_sales.
at the end of( field )
amt_sum = amt_sum + l_sales-netwr.
endloop.
regards
siva
‎2007 Sep 19 4:24 AM
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.
reward for useful points
regards
Nagesh.Paruchuri
‎2007 Sep 19 5:23 AM
Hi
Try this I got it in one of the threads in sdn and it solved my problem.
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.