Liquid UI - Documentation - 7.13 return()

7.13 return()


Purpose

With return(), you can return values or messages before terminating the process. Generally, these messages are used to indicate the status of the process on the 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 executed in WS performs any of the following actions:

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

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

 


Syntax

Format 1: Returns from the defined process.

return();

Format 2: Returns the string value.

return("string");

Format 3: Returns values in the variables. To use a variable, such as a user-created variable or system variables:

return(_variable);

Format 4: Also, returns the values in both the variables and strings. 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 the return() command:

The return() on the execution of the below script, provides the following results on the SAP Easy Access screen, as shown below:

  • Based on the transaction code entered, the screen appears. Here, we have entered the VA01 tcode in the input field and clicked the ExecuteReturn button. Then, we will be navigated to the Create Sales Order transaction screen, as shown below:
     
  • Error message appears, if no transaction code/incorrect code is entered, as shown in the image below.
     


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]"); 
 }


Usage Details


Tips and Tricks

  • You can use variables in the message text that appears on the status bar.
  • By adding \n in your message you can create a carriage return, and adding \t implements tab

Can't find the answers you're looking for?