Supply Chain Management Blogs by SAP
Expand your SAP SCM knowledge and stay informed about supply chain management technology and solutions with blog posts by SAP. Follow and stay connected.
cancel
Showing results for 
Search instead for 
Did you mean: 
gheorghe_ceres
Product and Topic Expert
Product and Topic Expert
With the SAP S/4HANA 2021 release, we introduced a new “EWM_MOBGUI” service in the transaction SICF via which users can display ABAP Dynpro in RF Framework as SAP GUI for HTML. To further personalize the RF screens, SAP also introduced a new feature called Screen Personas.  Screen Personas offers powerful means to adapt UIs to individual needs. More details can be found in the guide “SAP Screen Personas for Mobile RF Devices in Extended Warehouse Management in SAP S/4HANA”.

If simple screen adaptation is not sufficient, you could evaluate Screen Personas Scripting to gain even more flexibility.

You can use scripting to automate or manipulate screen actions, for example:

  • Screens can be skipped assuming mandatory fields can be filled automatically by the script

  • Fields can be prefilled

  • Additional data can be retrieved and displayed


Scripts created as part of the Adapt UI features are small pieces of JavaScript. You can attach these scripts to individual UI elements with script events or entire screens with screen events. For more details, see Script Editor.

Note that the use of scripting can have negative side effects, for example:

  • Depending on what you do in JavaScript performance can be harmed significantly. Thus, every script shall be evaluated carefully before productive usage. Keep in mind that for processing on RF devices usually every millisecond counts. If you want to do complex steps via scripting the added runtime has to be accepted by the end users. Accordingly, you should evaluate the expected costs (runtime) and compare it with the benefit for the end users.
    If you for example change the color of a button via scripting, there is a visible delay in the button changing its color at runtime.

  • Added complexity due to the usage of scripts. As a matter of fact, usage of scripts makes a flavor more complex.

  • Your script can depend on the screen definition, i.e. the objects/elements on the screen. If the screen would get changed, this might have negative impact on your script. Depending on what is done the script might need to be revised.

  • If you use object related content in your script e.g. the text/label of a button for a query, the corresponding coding might become language dependent. That is, if the script checks for the label text, you must consider different languages used in your warehouses.


The scripting examples below are added for illustration purposes only. They do not claim to be perfect JavaScript code. Additionally, they focus on a certain aspect and do not cover screen processing in a holistic way (e.g. complete error handling).

  • Example 1 – Dynamically Hide Verification Field on Destination Screen

  • Example 2 – Add ODO Number to Picking Source Screen

  • Example 3 – Query HU by Alternative Identification


Please watch this page as we plan to add more examples depending on feedback.

Example 1 – Dynamically Hide Verification Field on Destination Screen


This example describes how to use a script to dynamically hide the quantity fields on the destination screen of a product warehouse task in RF picking. Besides hiding the fields, the script also automatically verifies the quantity on the destination screen. This is based on the assumption that the quantity was already verified on the source screen.

1.Start the script editor from the flavor manager by choosing Scripts > Edit:


2. Choose Create New Script:


3. Add the following coding:


4. Save the implementation.

5. Assign the script to the screen event by editing the flavor, choosing the Insert tab, and choosing Script Events:


6. Add the created script to the onAfterRefresh screen event:


When the script runs, the quantity fields won't be visible on the destination screen for product warehouse tasks in RF picking:



Example 2 – Add ODO Number to Picking Source Screen


With this example you can see how to create a script to add the outbound delivery order number to the RF picking source data screen. This can be done although the ODO number is not available in standard on the source data screen.

Please note that a custom field and label has to be added to the screen (see txtPersonas_168726056454688 below). For your script you will have to correct the ID / use the ID of your custom field.

1.Start the script editor from the flavor manager by choosing Scripts > Edit:


2. Choose Create New Script:


3. Name the script and create the following implementation in the coding window:


4. Save the implementation.

5. Assign the script to the screen event by editing the flavor, choosing the Insert tab, and choosing Script Events:


6. Add the created script to the onAfterRefresh screen event:


The flavor containing the script in the background uses RF functionality to execute a WT query in RF to get the ODO number linked to the warehouse task and displays it on the RF picking source screen:


Please note that the flavor / script executes several steps in background. This consumes time that has to be accepted by the business users. Do not add too many steps.

If the information you need is not provided on an existing RF screen that you can reach out of the current logical transaction (e.g. picking), alternatively you could use APIs. See SAP Business Accelerator Hub for more information.

Example 3 – Query HU by Alternative Identification


The steps below describe how to create a script to select HU information by entering the alternative HU identification instead of the EWM HU number.

1. Start the script editor from the flavor manager by choosing Scripts > Edit:


2. Choose Create New Script:


3. Name the script and create the following implementation in the coding window:


4. Save the implementation.

5. Assign the script to the screen event by editing the flavor, choosing the Insert tab, and choosing Script Events:


6. Add the created script to the onEnter screen event:


7. Create a second script with the following implementation:


Please note that the Personas text element IDs (here txtPersonas_168387506699773) have to fit to your flavor.

8. Add the second script to the onAfterRefresh screen event:


The flavor containing the scripts changes the selection screen of RF transaction HU Query:


The flavor hides the original field label and input field of the HU number and instead uses the field label and input field for the alternative HU identifier. You have to add these custom fields to the screen as part of your flavor (see above).

The second script which runs for event onAfterRefresh sets the focus to the new input field.

The first script which runs for event onEnter uses an oData service to read the HU data based on the entered alternative HU identifier. See SAP Business Accelerator Hub for more information.

FIND OUT MORE!

If you are interested in more information in this area, I recommend you check out the following consulting notes:

For more information about SAP Extended Warehouse Management, please follow us on social media, our YouTube channel or our community pages:

SAP EWM Community

SAP YouTube Channel

EWM LinkedIn Community

For a complete list of Q&A from the EWM community, please access this link:
https://answers.sap.com/tags/01200615320800000705

In case you do not find your specific question there, feel free to post your question via the following form:
https://answers.sap.com/questions/ask.html?primaryTagId=01200615320800000705
9 Comments
shashankagg
Explorer
0 Kudos

Can we hide button based on certain condition ?

lets say screen 9001 has field F1 & F2 , If user provides value to Screen9001-F2 = 'value1' then screen 9002 gets trigerred and opened . Now screen 9002 has field F3 and a button B1. My ask is i need to hide button B1 for some specific users if F2 has value = 'Value1' and F3 has value = 'Value2' . 

TobiasAdler
Advisor
Advisor
0 Kudos

Hi @shashankagg,

Please try to work with custom Screen Personas Scripts for this purpose. On your first screen you could memorize the content of your field F2 using session.utils.put. On the second screen you could evaluate this value using session.utils.get.

More information can e.g. be found in the answer given here.

Best regards, Tobias

shashankagg
Explorer
0 Kudos

Thanks @TobiasAdler .

But i am a newbie to this . Could you please explain more in detail.

I did script recording from screen 1 ? i got the code ...but iam not sure how to achieve it ?

TobiasAdler
Advisor
Advisor
0 Kudos

Hello @shashankagg,

If you are a newbie, it would probably good to start with some overview information. E.g. based on the following links:

Giving a specific answer to generic question is sometimes a bit hard. Let me try to list high-level steps:

  1. Have a script for your 1st screen tied to a suitable event, so that you can consume the value of the user input.
  2. Below you can find an example to memorize the product entered for a specific RF screen in receiving of HUs
    //OnAfterRefresh
    //on screen SAPLRF_RECEIVING_HUS_PM:0401 store value of product used
    if (session.idExists("wnd[0]/usr/subX:/SCWM/SAPLRF_RECEIVING_HUS_PM:0401/txt/SCWM/S_RF_REHU_PROD-MATNR")) {
        var product = session.findById("wnd[0]/usr/subX:/SCWM/SAPLRF_RECEIVING_HUS_PM:0401/txt/SCWM/S_RF_REHU_PROD-MATNR").text;
        session.utils.put('product', product);
        session.utils.log("Product " + product + " stored in memory");
    }
  3. Create another script for your 2nd screen to consume the value memorized before and react accordingly
    //on screen SAPLRF_RECEIVING_HUS_PM:0501 retrieve stored product and e.g. hide fields dynamically
    if (session.idExists('wnd[0]/usr/subX:/SCWM/SAPLRF_RECEIVING_HUS_PM:0501/txt/SCWM/S_RF_REHU_HU-PGR')) {


        var product = session.utils.get('product');
        session.utils.log("Product " + product + " retrieved from memory");

    // do your thing, e.g. dynamically hiding some screen fields

    }

Hope this helps.

Best regards, Tobias

 

shashankagg
Explorer
0 Kudos

Hi @TobiasAdler ,

I tried following the steps you suggested but somewhere i am failing. I was again trying to explain here where i am lagging.

1.App name - 'Warehouse Monitor'

2. Executed my first script where i selected all the records for stock type = 'b'.

3.Now i got list of records whoose stock type is 'b' as given below - 

shashankagg_1-1715255465935.png

4. Now user would select records and click on below icon and select 'Change Stock Type'.

shashankagg_2-1715258877334.png

5. Below screen appears once change stock type is clicked.

shashankagg_3-1715259062175.png

6. i Have to disable above highlighted button 'Create Posting chg' once highlighted Stock type = 'F'.

Now, for this i did below scripting , here iam getting values new_value and set_value1 i debugged. Not sure why getting error. 

shashankagg_4-1715259648007.png

 

shashankagg_5-1715259743791.png

can you help?

 

 

TobiasAdler
Advisor
Advisor
0 Kudos

Hi @shashankagg,

Ahh, now I see that you are coming form a different angle. This blog focuses on Screen Personas Scripting in context of Mobile RF Devices in Warehouse Management. In that sense, we are a bit off topic 😉.

As already mentioned before, it is a bit hard to provide a solution for your very use case. Additionally, I have to admit that I did not understand all your steps. E.g. how/why you select stock via a script. My assumption is that you want to prevent users from posting to a certain stock type in some cases. For this you could try the following. Please note that this can only be seen as example. You have to adapt to your specific needs.

Important: To be able to assign scripts to events of the popup window, use these steps:

  1. Open app Warehouse Monitor and execute a query for node Stock and Bin->Physical Stock.
  2. Open profile of user in upper right corner and click on Adapt UI.
  3. Choose your flavor for editing and press on Scripts.
  4. Mark a valid stock line in the monitor node and choose method Change Stock Type. This opens the popup window.
  5. Close the scripts window at the bottom by hitting the X in the upper right corner.
  6. In Personas Flavor List choose to Edit your flavor.
  7. Assign scripts to the relevant events (see below).

Scripts

A) => tied to event onAfterRefresh of popup window

// In monitor suppress posting change to stock CAT F (=free)

// other destination CATs shall be allowed

if( session.idExists(session.activeWindow.id + "/usr/subSUBSCR_PC:/SCWM/SAPLSTOCK_OV_MON_METHODS:0220/ctxt/SCWM/S_ASP_STOCK-TO_CAT")) {

    if(session.findById(session.activeWindow.id + "/usr/subSUBSCR_PC:/SCWM/SAPLSTOCK_OV_MON_METHODS:0220/ctxt/SCWM/S_ASP_STOCK-TO_CAT").text.toUpperCase() == "F") {

        session.findById(session.activeWindow.id + "/tbar[0]/btn[8]").enabled = false;

        //session.utils.alert("Posting to Stock Type F suppressed");

    }

    else {

        session.findById(session.activeWindow.id + "/tbar[0]/btn[8]").enabled = true;

    }

}

B) => tied to Event onClick of button Create Posting Chg.

// Suppress button press triggering posting change if destination CAT = F

if (session.idExists(session.activeWindow.id + '/usr/subSUBSCR_PC:/SCWM/SAPLSTOCK_OV_MON_METHODS:0220/ctxt/SCWM/S_ASP_STOCK-TO_CAT')) {

    if (session.findById(session.activeWindow.id + '/usr/subSUBSCR_PC:/SCWM/SAPLSTOCK_OV_MON_METHODS:0220/ctxt/SCWM/S_ASP_STOCK-TO_CAT').text.toUpperCase() == 'F') {

        return true; //prevents execution of logic behind button press

    }

}

Best regards, Tobias

shashankagg
Explorer
0 Kudos

Appreciate for your help @TobiasAdler .

This really worked!

After entering value 'F' i forcefully need to press ENTER command , then only button is getting hide. Is there any event where i could assign scrips as value is entered 'F' without hitting enter.

shashankagg
Explorer
0 Kudos

Also @TobiasAdler  how do i restrict user access for my custom flavor.? do u have any URL's ?

TobiasAdler
Advisor
Advisor
0 Kudos

Hello @shashankagg,

I am not aware of way to have an immediate update upon entering "F". It might be that a Screen Personas Scripting expert has a hint.

For restrictions please check the Screen Personas help depending on your deployment option. For S/4HANA Cloud Public Edition you could check the following links:

Best regards, Tobias