Application Development and Automation 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: 
Read only

Summing in SAP Script

Former Member
0 Likes
1,608

Hi all,

I have to add 3 program symbols to display total. can any bosy please say me how to add fields

example

, Excise Duty @ 16% ,,,,,,,,&J_1IEXCHDR-EXBED(16.2R)&

,, Education Cess @ 2% ,,,,,,,,&J_1IEXCHDR-ECS(16.2R)&

,, S & H Edu Cess @ 1% ,,,,,,,,&J_1IEXCHDR-EXADDTAX1(16.2R)&

want to display totla of all this

can anybody say how it can be done

Thanks in Advance

6 REPLIES 6
Read only

Former Member
0 Likes
1,192

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

Read only

Former Member
0 Likes
1,192

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.

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

Regards,

Bhaskar

Read only

Former Member
0 Likes
1,192

Hi

Define a Variable called Total like

/: DEFINE &TOTAL&

/ TOTAL = &J_1IEXCHDR-EXBED(16.2R)& + &J_1IEXCHDR-ECS(16.2R)& +

&J_1IEXCHDR-EXADDTAX1(16.2R)&

to display sum of them

/ &TOTAL(16.2R)&

Reward points for useful Answers

Regards

Anji

Read only

Former Member
0 Likes
1,192

hi,

for adding program symbol, we can work with sap script control command

<b>/: summing <program-symbol> into <total symbol></b>

the command should be specified just once then each time the specified symbol is formated and its current value is add to the total symbol.

sap script can not create the field for total dynamically, for that one tou explicitly define in script.

regards,

Ashokreddy.

Message was edited by:

Ashok Reddy

Read only

Former Member
0 Likes
1,192

Problem is solved by myself

Read only

0 Likes
838

How did you solve it?