The onmessage command triggers actions if messages are received from SAP.
The onmessage command is used to trigger an action if a message is returned from SAP. This command behaves as an independent screen block, similar to the onscreen command. The syntax is as follows:
onmessage
The onmessage command does not take any options.
To demonstrate the onmessage command, please do the following:
Go to the VA01 script file and create a new inputfield with the following code:
inputfield([3,1] , "Sold-to" , [3,22],{"name":"z_va01_soldto","size":10});
Create a function that will execute when the user presses enter. We will use the onUIEvents command to trigger the function and we will use the message command to display it. If an incorrect code is entered, the onmessage command will capture that and display the message on the screen. The code is as follows:
onUIEvents['Enter'] = va01_entersoldto;
function va01_entersoldto(){
onscreen 'SAPMV45A.4001'
set("F[Sold-to party]" , "&V[z_va01_soldto]");
enter();
onmessage
message("E:" + _message);
enter("/nva01");
}
Enter an incorrect value in the Sold-to field and press Enter.
The specified error message will display as shown below:
