cancel
Showing results for 
Search instead for 
Did you mean: 

Explain me this code

Former Member
0 Kudos

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

var total = 0;

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

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

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

}

}

this.rawValue = total;

Accepted Solutions (1)

Accepted Solutions (1)

harman_shahi
Contributor

Hi Ankesh,

Basically this code is calculating the SUM of the PRICE fields contained in the Previous Page. Please see my comments in the code below:

//Get all fields contained in the Previous page (xfa.layout.page(this)-1   means previous page)
var fields = xfa.layout.pageContent(xfa.layout.page(this)-1, "field", 0);

var total = 0;

//Loop through all the fields
for (var i=0; i <= fields.length-1; i++) {

//If the field name is PRICE
if (fields.item(i).name == "PRICE") {


//Then add the value of the field to the Total
total = total + fields.item(i).rawValue;
}
}
//Set the calculated Total value in "this" field.  "This" field is referring to the field that is actually calling this code.
this.rawValue = total;

Hope this helps,

harman

Answers (1)

Answers (1)

Former Member
0 Kudos

thanks for explaining and actually i am doing development in abap/4 so i dont have much idea about java script but as u have explained in beautiful manner , i am very much thankful for ur effort.