Liquid UI - WS Reference Library

return()


Purpose

With return(), you can return values or messages from actions.

The return command enables users to return values or messages from actions and then display those values or messages on a SAP screen. The most common usage is to send an error message to a user when an invalid action occurs and then to end the script. The return command can be executed in WS to perform any of the following actions:

  • Convey users back to the initial screen of a SAP transaction.
  • Display a message on a SAP screen.

Note: When screen combinations are done, the return command should be used before any screen blocks.


Syntax

return("string");

Variables can also be used in return commands. To use a variable, such as a user-created variable or system variables:

return(_variable);

Variables and strings can also be combined. To combine a variable and a string:

return("string" +_variable);

Properties

  • Variable/Text


Options

The return command does not take any options.


Example

In the following example, we will demonstrate the usage of return() command:

The return() command, on execution, provides the following results:

  • based on the transaction code entered, the screen appears
  • error message appears, if no transaction code/incorrect code entered

On the SAP Easy Access screen, execute the below script. The screen appears, as shown in following Figure.


Script

del("X[IMAGE_CONTAINER]");
pushbutton([2,1],"Execute Return",{"process":z_return, "size":[1,30]});
inputfield([2,32],{"name":"fcode","size":10,"nolabel":true}); 
 function z_return()  { 
 if(fcode == "")  { 
 return("E: Please enter a transaction code - ex. va01, mm01..."); 
 } 
onscreen 'SAPLSMTR_NAVIGATION.0100'
enter("/n&V[fcode]"); 
 }


Tips and Tricks

  • Get Future Date

    To get the future date in the current user’s date format based on the number of days entered.

    return('E: Enter number of Days');

    Learn more about how to Get Future Date based on number of days.