cancel
Showing results for 
Search instead for 
Did you mean: 

Subtotal on each page for a value

Former Member
0 Kudos

Hello together,

i hope somebody can help me.

I need a subtotal of all value on each page.

I have this structure

Subform1

- Subform_item

--positionnumber

--pricevalue

- Footersubform

--subtotalvalue

i have for example 3 Pages on page one i have 3 positions on page 2 and 3 5 positions with some price value.

Now i will subtotal of page 1 at the end witch containe my 3 pricevalues from page1

Then i will a subtotal on page 2 which containe the subtotal of page 1 and the sum of the pricevalues from page 2-

On Page 3 i also need a subtotal which contain the subtotal from page 1 & 2 and the pricevalue of page 3.

Page1

pricevalue 10,11

pricevalue 10,12

pricevalue 10,13

--subtotal = 30,36

Page2

pricevalue 4,00

pricevalue 4,00

pricevalue 2,00

pricevalue 2,00

pricevalue 2,00

subtotal = 44,36

Page3

pricevalue 1,00

pricevalue 1,00

pricevalue 1,00

pricevalue 1,00

pricevalue 1,00

subtotal = 49,36

I have a footer subform with a field subtotal

and there i try to calculate it.

I try some different examples, but nothing works correct.

This is my last try, but doesn't calculate what i want

var fields = xfa.layout.pageContent(xfa.layout.page(this), "field", 0);

var total = 0;

for (var i=0; i <= fields.length-1; i++) {

if (fields.item(i).name == "ZZPR00_GES") {

total = total + fields.item(i).rawValue;

}

}

this.rawValue = total;

Thanks in advantage for some help.

Best regards

Florian

Edited by: Florian Martin on Sep 20, 2011 2:38 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

rakesh_m2
Contributor
0 Kudos

Hello Florian,

the code which you have written will calculate subtotal of that page.

remove total = 0; just declare the variable.

if you want to initialize the total variable, do it in initialize event

Thanks,

Rakesh.

Former Member
0 Kudos

Hello Rakesh,

if i remove the the "var total = 0 ;" then my field on the PDF is empty,

If i only declare it in initialized, then i also get nothing.

Do you have any other idea?

If it is helpfully for you to help me, then i can send you the form, the interface and a example xsd file.

Regards

Florian

rakesh_m2
Contributor
0 Kudos

Hello Florian,

for each page, the value of total is getting initialized to 0 in your case. You could declare a variable instead and proceed with it.

If you want me to see your form, please send it to me, i can try.

Thanks,

Rakesh.

Former Member
0 Kudos

Ok i send you the files per mail.

thank you for your help

Regards

Florian

rakesh_m2
Contributor
0 Kudos

Hello Florian,

As I told you create a variable called total in "Edit -> Form Properties -> Vairables"

use that variable, then your problem will be solved.

Let me know, if you see any issues.

Thanks,

Rakesh.

Former Member
0 Kudos

Yes, i do that, but i only get nothing.

I delte "var total = 0;"

Then i add "total" to the global var in the form properties, but i also get nothing.

Maybe it is a bug in my Designer 9.

Which Version do you use?

Regards

rakesh_m2
Contributor
0 Kudos

Hello Florian,

While using that variable, are you using total or total.value.?

Rakesh.

Former Member
0 Kudos

I try following:

var fields = xfa.layout.pageContent(xfa.layout.page(this), "field", 0);
for (var i=0; i <= fields.length-1; i++) {
if (fields.item(i).name == "ZZPR00_GES") {
total.value = total.value + fields.item(i).rawValue;
}
}
this.rawValue = total.value;

or

var fields = xfa.layout.pageContent(xfa.layout.page(this), "field", 0);
for (var i=0; i <= fields.length-1; i++) {
if (fields.item(i).name == "ZZPR00_GES") {
total = total + fields.item(i).rawValue;
}
}
this.rawValue = total.value;

or

var fields = xfa.layout.pageContent(xfa.layout.page(this), "field", 0);
for (var i=0; i <= fields.length-1; i++) {
if (fields.item(i).name == "ZZPR00_GES") {
total = total + fields.item(i).rawValue;
}
}
this.rawValue = total;

I dont understand why it is everytime empty.

Do you have another script for calculating the subtotal?

Thanks for your help

Florian

rakesh_m2
Contributor
0 Kudos

Hello Florian,

try this script.

var page = xfa.layout.page(this);

var fields;

for(var j = 1; j <= page; j++)

{

fields = xfa.layout.pageContent(xfa.layout.page(this)-j, "field", 0);

for (var i=0; i <= fields.length-1; i++) {

if (fields.item(i).name == "ZZPR00_GES") {

total = total + fields.item(i).rawValue;

}

}

}

this.rawValue = total;

Thanks,

Rakesh.

Former Member
0 Kudos

Hello Rakesh,

it don't work.

But next week, i can ask somebody from adobe direct.

I hope he can solve my problem, if i get a sollution, i will post it.

Thanks your help!

rakesh_m2
Contributor
0 Kudos

Hello Florain,

the code which I posted will work. I have emailed you an custom interface and form, which does the same. Execute the form directly, you could see the subtotal in the textfield created in the bottom.

Please let me know, if you still see some issues.

Thanks,

Rakesh.

Former Member
0 Kudos

Hello,

now i know the problem.

If you start the Designer 9 directly in Windows and import the form and click on preview you see 10 Sites with 2 positions on every site.

the subtotal is correct.

If you open the Designer with the Transaktion SFP and click on preview you get 5 Sites with more position on every site.

The subtotal is wrong.

If you print it from SAP and have a look in the spool, you also see 5 sites with more then 2 position on every site.

I think this is the reason why you Rakesh have no problems with the subtotal.

I am in contact with SAP and i told them this issue.

If i have a sollution i will post it in this thread.

Regards

Former Member
0 Kudos

Hello,

now the problem ist solved.

The correct coding is

var fields; 
var total = 0;
var page = xfa.layout.page(this);

for(var j = 0 ; j < page; j++)
{
	fields = xfa.layout.pageContent(j, "field", 0);
	for (var i=0; i < fields.length; i++) 
	{
		if (fields.item(i).name == "ZZPR00_GES") 
		{		
			total = total + fields.item(i).rawValue;			
		}
	}
}
this.rawValue = total;

Additionaly all scripts must have "Client and Server".

In fom properties Tab "default" Option Server you must select "dynamic XML form".

If not, you got some problems with the numbers of pages.

Regards

jens_blueher
Discoverer
0 Kudos

Hello Martin,

one small question to the calculation of the subtotal.

Which event where the Javascript coding are stored should be used for the calculation ???

Thanks in advance and kind regards

Jens