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

Wrong Cumulative total in Smartforms

former_member207873
Participant
0 Likes
2,379

Hi Experts,

I am having an issue with the calculation of cumulative total in each page of the smartforms.

Suppose Page 1 is having line items,

1) 1000.00

2) 2000.00

Subtotal coming as 5000. (because 1000 + 2000 + 3000 (which is in the next page) )

Expected: 3000.

Page 2 is having line items

1) 3000

2) 2000

Subtotal coming as 10000.(1000 + 2000 + 3000 + 2000 + 2000 (which is on the next page))

Expected (8000)

What i noticed while debugging is that the sum is happening including the next page first line item.

Note: v_suntotal is the field which calculates the total in every page in the smartform.

Hi Experts,

I am having an issue with the calculation of cumulative total in each page of the smartforms.

Suppose Page 1 is having line items,

1) 1000.00

2) 2000.00

Subtotal coming as 5000. (because 1000 + 2000 + 3000 (which is in the next page) )

Expected: 3000.

Page 2 is having line items

1) 3000

2) 2000

Subtotal coming as 10000.(1000 + 2000 + 3000 + 2000 + 2000 (which is on the next page))

Expected (8000)

What i noticed while debugging is that the sum is happening including the next page first line item.

Note: v_suntotal is the field which calculates the total in every page in the smartform.

7 REPLIES 7
Read only

VenkatRamesh_V
Active Contributor
0 Likes
1,921

Hi,

View this link.

https://scn.sap.com/thread/954419

http://scn.sap.com/thread/1454650

Hope it helpful,

Regards,

Venkat.V

Read only

0 Likes
1,921

I already have a look on those threads. But not able to solve my issue with those.

Read only

Former Member
0 Likes
1,921

Hi P.D,

Follow This Steps for creating subtotal for each Page:

  • Create A variable in Global Definitions by name V_SUBTOT.
  • Goto Table->Expand Main Area->Expand Row->Expand Last Cell->Text Will be visible.
  • Right click on the text->Create-->Flow Logic-->Program Lines.
  • Write the Code for calculating Subtotals.

          v_subtot = v_subtot + wa.

  • Double lick on the Table->Click on Table Tab.
  • Right click on %LTYPE1->Insert->Empty Line UnderNeath.
  • %LTYPE2 will be created.
  • Double lick on Footer->Create Table Line.
  • Give Line type as  %LTYPE2.
  • Automatically 1 cell will be created under Footer
  • Right click on Cell->Create Text
  • Write Text as &v_subtot(c)&.
  • After Printing the subtotal, We need to clear the value.

For Better Clarification Check the Below Scree Shots.

Regards ,

Surya

Read only

0 Likes
1,921

You got me wrong. I need cumulative sum.

1st page: 100

               200

               ___

               300

2nd Page 200

               300

               ___

               800

Here issue is that page breaking is not working properly. It is considering the second page 1st line item value also while summing.

Read only

0 Likes
1,921

any help on this?

Read only

Former Member
0 Likes
1,921

Not sure how efficient this would be. but seeing that you are still stuck with same problem i can give you a trick. While processing the first page make sure that you are having a constant number of items to sum up in one page i.e. for eg if 8 items are being printed in one page then sum up the 8 items and force the smartform to next page using 'COMMAND' to trigger the next page. This way you can write logic and makes sure each page has same number of items and your subtotal would be correct.

Read only

0 Likes
1,921

Hi Syed,

It is not possible to have fixed line items. Any other solutions ? If you could suggest how to check programmatically a page break has happened or not, that would be great!