SAPscripts How to calculate Totals and Subtotals

I have some doubs in BDC and SMART FORMS.  I want to change the material number using the transaction code MM02 through BDC.

In scripts and smartforms how to calculate totals and subtotals?

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.

I have given a rough outline, please be aware of the variable conversions as Int_cond-value and outt_cond-value are characters.

SAPscripts Tips by: Raj

Fast Links:
SAPscripts FAQ
FAQ for Sap Scripts

SAP Books
SAP Certification, Functional, Basis Administration and ABAP Programming Reference Books

SAP Scripts Tips
SAP Sapscripts Tips and Tricks

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.