on 05-02-2008 3:53 PM
Hi,
This is sunil, plz help me, How to call subroutines in a sap script and use at first, at last calculate totals with coding
Regards,
sunil kumar.t
Hi,
Chk out the below code:
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,
value1 type kbert.
Read int_cond table WITH KEY 'KOMVD-KBERT'.
IF SY-SUBRC EQ 0.
value = int_cond-value.
ENDIF.
value1 = value1 + value.
Read outt_cond table with key 'TOT_PRICE'.
IF SY-SUBRC EQ 0.
outt_cond-value = value1.
Modify outt_cond index SY-TABIX.
ENDIF.
ENDFORM.
Regards,
Narendra.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Calling ABAP Subroutines:
You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out
calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.
Syntax in a form window:
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
......
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
......
/: ENDPERFORM
INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
The subroutine must be defined in the ABAP/4 report as follows:
FORM form TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
...
ENDFORM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
see these links.
1.http://saptechnical.com/Tutorials/Smartforms/PassingTableData/Script1.htm
2.http://saptechnical.com/Tutorials/Smartforms/ControlBreak/demo.htm
please reward me if useful.
thanks,
gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This may give you some idea:
http://www.sap-img.com/sapscripts/sapscript-how-to-calculate-totals-and-subtotals.htm
Regards,
Ravi Kanth Talagana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.