cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically binding in Formcalc

former_member217677
Participant
0 Kudos

Hello,

please help with followting problem.

I need to change a binding of a text field (bedrate) dynamically depending of value of another field (FKART).

I can already change a caption of a field (bedrate) but not a value:

if ( xfa.form.data.#pageSet[0].Seite1.FKART.rawValue == "ZIFS") then

    bedrate.caption.value.#text = "Service Tax %";

    $ =?????

endif

How can I update binding for field (bedrate) to $.DATA.SUMS.SER_RATE?

Do I need to use "record" or smth else?

Thanks

Evgenij


Accepted Solutions (1)

Accepted Solutions (1)

former_member217677
Participant

Hello guys,

as you mentioned above, I changed a print program to link another field.

Thanks a lot for suggestions.

Evgenij

Florian
Active Contributor
0 Kudos

Hi Evgenij,

Please mark your question as answered. I think your question is solved.

If you got any questions about it, read this blog:

Regards

Florian

Answers (1)

Answers (1)

pavan_prabhu
Active Participant
0 Kudos

Hello Evgenij,

     Click on the BEDRATE field in DATA sub form of the table. Write the below Javascript code.

if ( this.parent.FKART.rawvalue == "ZIFS" )

{

   this.rawvalue = "changed value";

}

You can also do it in Formcalc as shown below.


if ( $.parent.FKART.rawvalue eq "ZIFS" ) then

$.rawvalue = "changed value"

endif

former_member217677
Participant
0 Kudos

Hello Pavan,

you mentioned  - $.rawvalue = "changed value".

But then "changed value" is a fix value, and  I need value from interface. I need to bind another field from my interface.

Currently I have under data binding for bedrate -  $.DATA.SUMS.BEDRATE.

But if FKART = ZIFS, I want to bind $.DATA.SUMS.SER_RATE to bedrate field and it doesnt work.

pavan_prabhu
Active Participant
0 Kudos

Hello Evgenij,


     You can do in Formcalc in Initialize event as shown below.


if ( $.parent.FKART.rawvalue eq "ZIFS" ) then

$.rawvalue = $.parent.SER_RATE.rawvalue

endif

Florian
Active Contributor
0 Kudos

The major thing is, what is the exact processing time, you need to change the value.

I mean if you know that before the form is processed it is much easier to do it in the driver-program.

There are more than one advantage out of that.

You can debug it,

it is easy to understand and

another developer will get into the thinking very fast.

In case you have to do it while a table is printed and you have to do it for every position dynamic then the above event won't work.

Here you can see the events:

LiveCycle ES2 * Adobe LiveCycle Designer ES2

I know, it is not the SAP Specific, but the events should be the same.

Regards

Florian

pavan_prabhu
Active Participant
0 Kudos

Hello Evgenij,

     I totally agree with Florian. For such kind of requirement it is always good to handle the code in the driver program or Form Interface. It even increases performance as compared to scripts.

Now coming to the script section, I mentioned the Initialization event since this processing will occur in buffer before the table has been approved in the layout. For your requirement even the script will work for every position because you are writing the script directly on the field itself(i.e the code will be triggered for each value in every row). I dont know about FormCalc debugging but if you want to explore how to debug Javascript you can refer the below link.

How do I set a value dynamically in SAP Adobe Forms using JavaScript - Stack Overflow

But the conclusion is that, for such a requirement even I would recommend the code change in the Driver program or Form Interface.