Highlighted

Calculate two values (SAP HRFORMS)

Avatar

Avatar

Angela-Icon

Avatar

Angela-Icon

Angela-Icon

20-08-2010

Dear All,

I need held calculating two values within HRFOMS.

I would like to have a screenfield with the value of the current page Therefore i got a global variable G_total_pagecount and i have the current page xfa.layout.page(this)

I tried  the following

data.#pageSet[0].Startseite.Titel_und_Anschrift.Allgemeine_Daten.Org_Daten.Seite_global::ready:layout

$.rawValue = $record.G_TOTAL_PAGECOUNT + xfa.layout.page(this)

and received no value

or

var page = parseInt(xfa.layout.page(this), 10); // , 10 erzwingt die Umwandlung als dezimalzahl

var global = parseInt(xfa.record.G_TOTAL_PAGECOUNT, 10)

var total = page + global:

this.rawValue = total.rawValue;

But both did not work

I would be happy to get any new idea

Angela

Replies

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

20-08-2010

Why don't you use the page n of m object in the custom library?

There is code there that does the same thing.

paul

Highlighted

Avatar

Avatar

Angela-Icon

Avatar

Angela-Icon

Angela-Icon

20-08-2010

Hi Paul

I can't use page n,m because

this is always related to a single personell number which means it

always starts ewith 1 if the next personellnumber is handled. But I need the Pagecount of the current page within the spoolfile. Therefore i got g_total_pagecount which gives me the number of pages for already handeled persons.

This is why i need to calculate

Thanks

Angela

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

20-08-2010

Are you getting any scripting errors in the javascript console? You have errors in your script for sure.

$.rawValue = $record.G_TOTAL_PAGECOUNT + xfa.layout.page(this)

The "this" in the expression is a javascript convention and this is a formcalc syntax so this will not work. You can try replacing this with $

var page = parseInt(xfa.layout.page(this), 10); // , 10 erzwingt die Umwandlung als dezimalzahl

var global = parseInt(xfa.record.G_TOTAL_PAGECOUNT, 10)

var total = page + global:

this.rawValue = total.rawValue

I think that global and page might be a key word so I woudl choose a different variable names. Also when you assign the this.rawValue to total.rawValue...total is not a field but a variable so you do not put the .rawValue on the end of it.

this.rawValue = total

or if you want you can say

this.rawValue = page + global

Hope that helps

Paul

Highlighted

Avatar

Avatar

Angela-Icon

Avatar

Angela-Icon

Angela-Icon

20-08-2010

Hi Paul,

first of all many thanks for your help. I normally do only Abap programming, bur unfortunatly I ended up with this HRFORMS Payslip. I have no idea how to decide to choose Formcalc or javascript. I only tried some small pieces which i got from the online help.

I did try the following

----- data.#pageSet[0].Startseite.Titel_und_Anschrift.Allgemeine_Daten.Org_Daten.Seitenzahl::ready:layout - (FormCalc, Client)

$.rawValue

= $record.G_TOTAL_PAGECOUNT + xfa.layout.page($)

=> id did not get a value in my field

than I tried

----- data.#pageSet[0].Startseite.Titel_und_Anschrift.Allgemeine_Daten.Org_Daten.Seitenzahl::calculate: - (JavaScript, Server)

var

1 = parseInt(xfa.layout.page(this), 10); // , 10 erzwingt die Umwandlung als dezimalzahl

var

2 = parseInt(xfa.record.G_TOTAL_PAGECOUNT, 10)

this.rawValue

= 1 + 2;

=> still no value

Last I tried

----- data.#pageSet[0].Startseite.Titel_und_Anschrift.Allgemeine_Daten.Org_Daten.Seitenzahl::ready:layout - (JavaScript, Client)

var

1 = parseInt(xfa.layout.page(this), 10); // , 10 erzwingt die Umwandlung als dezimalzahl

var

2 = parseInt(xfa.record.G_TOTAL_PAGECOUNT, 10)

this.rawValue

= 1 + 2;

Still no succsess

As I am working within HRFORM i only get limited Error Messages or warnings and for everything i tried i did not get a warning at all.

It would be really nice if you could tell me what i did wrong

Thanks in advance

Angela

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

20-08-2010

Lets stick with the javascript way.....The code looks Ok to me.....but it is set to run on the server ....I suggest changing it to the client.

Then you can add debug statements using app.alert to determine if you are getting any values back at all. Lets add these statements to the beginning of the script:

app.alert(parseInt(xfa.layout.page(this), 10));

app.alert(parseInt(xfa.record.G_TOTAL_PAGECOUNT, 10))

Paul

Highlighted

Avatar

Avatar

Angela-Icon

Avatar

Angela-Icon

Angela-Icon

20-08-2010

I changed the script to client and added the two alert rows

----- data.#pageSet[0].Startseite.Titel_und_Anschrift.Allgemeine_Daten.Org_Daten.Seitenzahl::calculate: - (JavaScript, Client)

app.alert(parseInt(xfa.layout.page(

this), 10));

app.alert(parseInt(xfa.record.G_TOTAL_PAGECOUNT

, 10))

var

1 = parseInt(xfa.layout.page(this), 10);

var

2 = parseInt(xfa.record.G_TOTAL_PAGECOUNT, 10)

this.rawValue

= 1 + 2;

nothing happened I did not get a debug window when i started the formprint i did not get it eighter when i tried the PDF Preview

is 'Calculate' perhaps the wrong event?

Thanks in advance

Angela

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

20-08-2010

The app.alerts will only work in preview .....Try putting it on the form ready event. That shoudl be the last event to fire before handing it to the user.

Paul

Highlighted

Avatar

Avatar

Angela-Icon

Avatar

Angela-Icon

Angela-Icon

20-08-2010

Hi Paul,

still no value and no debug window.

Are You too using HRFORMS? Is there perhaps something that i ´need to install before beeing able to see the debug window?

Angela

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

20-08-2010

No I do not have HRForms I am using native Designer. Are you using Acrobat to view the result? The app.alert creates a message Box so if you are not using Acrobat or Reader then the messages will not appear.

paul