cancel
Showing results for 
Search instead for 
Did you mean: 

Change value of a table field at runtime

Former Member
0 Kudos

Hi,

In my ADOBE form, i have a field called Name inside a Table . At runtime i need to change the value of field from, lets say 'Blue' to 'Green'. I have tried using the replace statement against the field Name as follows :

Replace("Blue", "Blue", "Green")

This does not work.

Can anyone suggest how to use Replace statement for Tables fields ?

Thanks

Aditi

Accepted Solutions (1)

Accepted Solutions (1)

chintan_virani
Active Contributor
0 Kudos

In the initialize event of the table you can write following JavaScript code:-

Table1.Row1.Name.rawValue = "Green";
// Assuming Table1 is tablename, Row1 is the row where you have a field called Name

Chintan

Former Member
0 Kudos

Hi Chintan,

Thanks for your promt reply. My scenario is like this:

The field Name value is getting populated dynamically in the form .it is having have multiple values like this:

White

Grey

Purple

Blue

Black

Here I need to replace Blue value with Green value. wouldnt there be any looping required in the table ?

Thanks

Aditi

chintan_virani
Active Contributor
0 Kudos

Can't the value "Green" be passed from backend since you do are not changing this in front end (Adobe) based on some condition?

Anyways YES you will need to do looping if you have a dynamic table and do not know the no. of rows at designtime.

For exact code on looping check Pradeep's reply here -->

Chintan

Former Member
0 Kudos

Thanks Chintan,

Pradeep's reply might help me here.

Regards

Aditi

Answers (2)

Answers (2)

OttoGold
Active Contributor
0 Kudos

The backend solution (ABAP coding) is the best possibility, SAP recommends doing it this way (me too) bevause the script won´t slow down the form performance itself. Of course you can do this through scripting using Chintans example of code (Table1.Row1.Name.rawValue = "Green";).

You would place a script in the subform event initialize, the subform is the row subform/ parent of the field of the field you need to change. I would use JavaScript. I would use code like this:

if (this.fieldWithYourColors.rawValue == "Green) this.fieldWithYourColors.rawValue = "Red"; ("this" means the row subform)

or you´d better create a scripting object, create a function there and call it from the event like: scoReplace.replace(this.fieldWithYourColors, "Green", "Red"); where scoReplace is the name of your custom scripting object and in the body of the function you place the above line of code, only the values are taken from the passed variables.

Otto

OttoGold
Active Contributor
0 Kudos

Hello, how did you solve the problem? Maybe you can share the solution with us? Otto

Former Member
0 Kudos

Hi Otto,

I did manage to resolve this, but not through scripting . I had to make changes at the interface level itself as the scipting was not working for this issue.Following was the sample code written in Interface using fieldsymbol

loop at it_itab assigning <fs> where colour = 'Blue'

<fs>-colour = 'Green'.

endloop.

Do let me know if u had similar issue and u were able to get it right with scripting.

Regards

Aditi