Skip to Content

SAP Screen Personas 2.0 - How to embed IF conditions in scripts

Note: This article is about SAP Screen Personas 2.0. If you are looking for more information about SAP Screen Personas 3.0, please go to the SAP Screen Personas 3.0 Portal.

In our article SAP Screen Personas - How to fetch data from another screen, we have shown how you can use Personas to navigate to another screen, copy important data from this screen and finally navigate back to update fields of the current screen. All this without re-rendering, so that it feels to the end-user as if they are remaining on the original screen.

In our SU01D demo scenario this works nicely as long you enter an existing username. However, if the username doesn’t exist, the script execution is interrupted with an error message and the current screen, in this case an error popup, is shown.

You might agree that this is not the most beautiful solution. Fortunately, Personas offers IF conditions that you can use in scripts. This handles such situations in a way that contributes to the overall usability enhancements you are building.

To see how all this works, please have a look at the video. It starts with the "Quick View" flavor shown in the How To mentioned at the beginning of the document and enhances it to support handling of popup messages.

Step-by-step:

  1. Show how the existing flavor works with a known user and an unknown user
  2. Switch to edit-mode
  3. Double click the Script Button
    1. Select the Copy Value action
    2. Copy the id of the control
    3. Add a new action
    4. Convert the new action into an IF condition
      1. Select "is not empty"
      2. Enter the copied control id
    5. (Important) Move the action below the "Refresh Screen" and "above the first "Copy Value" action
    6. Convert all actions below the IF into conditional action
  4. Save & Exit
  5. Test with a known user and an unknown user
  6. Bring the transaction to the state when the error popup is shown
  7. Switch into edit-mode
  8. Copy the id of the label containing the error (and remember the id of the button that needs to be clicked)
  9. Cancel editing
  10. Close the popup
  11. Switch to edit-mode
    1. Add a new label to show the error message
    2. Double click the Script Button
    3. Add a new action
    4. Convert the new action into an IF condition
      1. Select "is not empty"
      2. Enter the copied control id of the error message
    5. Add an additional actions to
      1. Copy the error message
      2. Push the button
      3. Paste the value into the label that has been added before
    6. Make all actions condition actions for the last IF
  12. Save & Exit
  13. Show how the new flavor works with a known user and an unknown user

As usual, if you want to learn more or discuss anything related to how to make your SAP GUI screens more functional using SAP Screen Personas, please start a discussion in the SAP GUI space on SCN.

Tags: