cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Screen Personas: How to run a script before a transaction is executed

Former Member
0 Kudos

Hi,

Is there a way to run a script to populate certain fields before that particular transaction is run?

For Example: When i create a SO i have certain fields i populated [Custom & Standard] on the overview screen and when i go to change/display i want those fields to be populated. I did write a script in the initial screen to copy the fields[from different screens] and paste it on the overview screen but when i go to other tabs n back the fields populated initially disappear.

Also would like something that populates these fields for change/display mode by running the  script and just not when they go though a particular main screen.

Thanks!!

Mary

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I understand what you're trying to do, I think - I do the same thing myself. And yes, I get the same effect of custom fields losing their values when you visit another screen and then return. - here's the scenario...

From the start screen, have a script button that runs a transaction, say GUIT. On that initial screen is a custom field. Your script then visits another screen within the same transaction (press the "forward" button on the toolbar) - copies the value displayed in a standard field (e.g. the "12345" in the top left input field) navigates back to the initial GUIT screen (press the back button on the toolbar) and pastes the copied value. The effect of this is that a standard field from elsewhere in a multi-screen transaction is made visible on the initial screen of that transaction. I've wanted to do this with vendor master display, for a real life example.

This works fine, but as soon as, within the transaction you navigate elsewhere and then come back, the custom field has lost its value. Here it is in video. I display the script at the beginning - you will probably need to view full screen to see the script!

More commonly for me, on the start screen I have a custom field containing, say, a cost center value and a "Display" button that runs KS03 to display the corresponding master data. When I return to the start screen from there, the cost center value has disappeared from the custom field. I'd love it to remain...

Steve.

Former Member
0 Kudos

In addition to Steve's scenario i would like to have these fields to retain their value when i save the document and  return back in change mode. i could go to the change mode  from any flavor not necessary my flavor and it should still work.

Mary

Former Member
0 Kudos

Does anyone have a solution for the above issue?

Former Member
0 Kudos

Issue resolved using on create handler..Thanks everyone for your valuable inputs

Former Member
0 Kudos

Hi Mary,

Would you mind elaborating more detail on "using handler" ?

Thanks a lot,

Tony

Former Member
0 Kudos

Tony,

Say we have a script button you want to execute/ pushed on every time a screen is loaded you can make use of on create handler. In my example,i had a bunch of  fields in the SO Overview screen i needed to be populated every time SO overview screen  is loaded. i had a script that goes to other tabs and copies the fields and return back to the overview screen and paste the values.

the issue is if you visit other tabs or screens and return to the overview screen, the fields that we populated have lost the value and become blank.

Here comes the on-create handler to the rescue.. this is used to run a particular script every time a screen loaded.

so you take the name of the script button and paste it in the on create handler in the main user area. this will push the script button every time the main screen[SO Overview] was loaded.

Regards,

Mary

Former Member
0 Kudos

Hi Mary,

Thanks a lot for your detail explanation. Really really appreciate it.

Best Regards,

Tony

Answers (1)

Answers (1)

TobiasQueck
Advisor
Advisor
0 Kudos

Hi Mary,

Your scenario sounds fine, in general, so I am not sure if there is a simple piece missing in your script or if I am misunderstanding your scenario. Could you please create a short video of how you are executing the script and if possible also attach the script to the discussion?

Cheers,

Tobias.