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: 

summing in scripts

Former Member
0 Kudos

hi friends,

can plz some one help me with summing in scripts. like, printing customer orders sub total, and grand total. i have gone throgh the documentation, iam not really ok with that.

with regards,

vijay

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos
/:SUMMING program symbol INTO sum symbol
As SAP script cannot define sum fields dynamically, the sum symbol must be in a structure of the calling program, which was declared with TABLES.

instead of that you populate in driver program and pass it to layout.

Former Member
0 Kudos

hi vijay thanks very much for ur reply, could u plz explain that step by step in detail.

with regards,

vijay

0 Kudos

/:SUMMING &NETPR& INTO V_TOTAL

loop

<b>write form for main window</b>

endloop.

for every time(loop pass) the value will be added to v_total ,this will be defined in script.

Former Member
0 Kudos

You can sum the total in the program that calls the script and print it in the script.

lets say you have an internal table and you writing as lines in the script.

01 10 usd

02 20 usd

etc...

99 10 usd

call funtion 'open_form'

loop at itab.

call funtion 'write_form

element = '100' (for lines)

g_total = g_total + itab-value.

at last.

call funtion 'write_form

element = '101' (for total)

endat.

endloop.

so at the end of all the line items printed, the element 101 will be called and the total is printed there.

For subtotals and totals on each page you have to come with a logic to sum in the wrapper program and pass it on to the SAP script.

Kannan