Using the addstring option

The following describes how to use the addstring option with statusmessage. The basic function of 'addstring' is to add a custom message to a listbox. The syntax is as follows:

statusmessage({"addstring":"This is a sample message!"});

Messages can be added at any time during the execution of the function, either inside or outside a given screen block. It is also possible to include variables in the addstring option, such as the example shown below:

        var z_msgtitle = "Test Listbox";
        statusmessage({"addstring":z_msgtitle});
      

In the following example, we will create a function that will invoke a statusmessage listbox on the Easy Access screeen.

  1. Go to the Easy Access screen.
  2. Open the 'SAPSLMTR_NAVIGATION.E0100.sjs' script file, and enter the following code. Create the file if it does not already exist.
    var z_msgtitle = "Sample StatusMessage Listbox";
    var z_msg = "This is a sample message for the statusmessage command!";
            
  3. Now add code to create a toolbar pushbutton. We need this to initiate our process. An example is shown below:
    pushbutton([TOOLBAR], "Test StatMsg", {"process":z_statmsg});
              
  4. Add code for the function that will execute our process. An example is shown below:
    function z_statmsg() {
      statusmessage({"remove":true});
      statusmessage({"title":z_msgtitle, "size":[10,40], "position":[5,10], "addstring":z_msg});
      message("S: The message was displayed!");
                }
              
  5. Save the changes and refresh the SAP screen.

The VA01 screen will now display as shown below: