Expand my Community achievements bar.

Calculate two values (SAP HRFORMS)

Avatar

Level 1

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

14 Replies

Avatar

Former Community Member

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

Avatar

Level 1

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

Avatar

Former Community Member

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

Avatar

Level 1

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

Avatar

Former Community Member

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

Avatar

Level 1

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

Avatar

Former Community Member

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

Avatar

Level 1

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

Avatar

Former Community Member

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

Avatar

Former Community Member

Lets go back to basics .....can you describe the behaviour that you are trying to achieve?

Also in the script editor we can do a syntax check ....my guess is that there is a syntax error and your script is not running. Click the button highlighted below. If there is an error it will highlight the offending line in pink.

screen1.png

Paul

Avatar

Level 1

Hi Paul,

th preview is using Acrobat 7 static PDF this might not be enough to display the debug window. But in your opinion the code is ok?

This might than be one of the many problems using the latest version of the SAP Payslip for germany.

Thanks a lot for your help

Angela

Avatar

Former Community Member

We have gone through so many iterations that I am loosing track ...can you email the form to

LiveCycle8@gmail.com and I will have a look.

Paul

Avatar

Level 1

Hi all,

I am facing exactly the same problem as described above. This seems to be a standard requirement when you want to print the SAP payslips and then run them through an enveloping machine. The SAP FAQ does not help very much. It only says: Simply add the current page number (xfa.layout.page(this)) to G_TOTAL_PAGECOUNT. Nor did I find a solution anywhere else on the web.

My first attempts were pretty much the same as Angela's. I now noticed, that when I call the PDF preview for my form, I get the following error message:

"Fehler: Unterschiedliche Argumente im Eigenschaft- oder Funktionsargument"

Sorry, my LiveCycle Designer only speaks German. In English, it should be something like: "Error: Different argments in property or function argument".

The FormCalc code I entered in the calculate event of a subform is:

 

overallPageCount

= $record.G_TOTAL_PAGECOUNT.value +

$layout.page($)

(plus various other versions which all returned the same error)

I guess there is some kind of type conversion problem here. When I assign the G_TOTAL_PAGECOUNT to a text field, I get a number on my form, which is correct. But I have no idea how to get this script running.

Any ideas?