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

Subtotal in smartforms

Former Member
0 Likes
457

Hi,

I am facing problem in calculating subtoal of all the line items on separate pages.My Requirement is i have to calculate subtotal of line item on the first page at the first page end after that on the second page i need subtotal of all the amount(NETWR) present on all the line items on the second page subsequently.No of line items are not fixed on all the pages.It may be 4 on 1st page and 5 on second page.

Regards,

Mukesh Kumar

4 REPLIES 4
Read only

Former Member
0 Likes
430

you can use the sort option and use the SORT BEGIN and SORT END events in the table.After the event node is created,under the node add a code section to calculate the subtotals and output it.

Read only

Former Member
0 Likes
430

hi,

you create a program line in the table and calculate the sum by using

<b>var = var + wa-netwr</b>.then write the var in the window below the main window.

after writing create another program line and clear the variable.

Hope this will do.

Read only

Former Member
0 Likes
430

try to use condn....

sfsy-page ne sfsy-formpages

in coding node just sum on the basis of cond.

ex---

loop at itab.
w_sum = w_sum  + itab-netwr.
endloop.
if sfsy-page ne sfsy-formpages.
clear: w_sum.
endif.

where w_sum is sum of line item...

kishan negi

Read only

Former Member
0 Likes
430

hi ,

try this code

<b>In scripts and smartforms how to calculate totals and subtotals?</b>

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.

if this helps u ,reward the points,

shan