Liquid UI - Documentation - 5.4 Creating a Notification with bot

5.4 Creating a Notification with bot


This example of bot in action will demonstrate how to set up a task and run bot without user interaction. In this example, we will create a new PM notification in the IW21 transaction in SAP. The steps to demonstrate this are as follows.

  1. We previously created an 'elogon.sjs' file with the user login and password for the example of the infinite logon and logoff loop. We will use this same file for this example, so the only change we need to make is to make the enter command call the requisite process. We can do this by changing the enter command as shown below.
    enter({"process":create_iw21});
  2. Open the script file for the Easy Access screen ('SAPLSMTR_NAVIGATION.E0100.sjs'). In this file, change the function in the enter command to be a different name. We will use the name 'create_notification', as shown below.
    enter({process:create_notification});
  3. Now we will open the 'functions.sjs' file and create a new function to create a notification. This function will actually perform the work of creating a new notification. First, add a line that will call the IW21 transaction. An example is shown below.
    function create_iw21() { 
     onscreen 'SAPLSMTR_NAVIGATION.0100' 
     enter('/niw21'); 
    
  4. Now enter the following code to populate the 'Notification Type' field.
    onscreen 'SAPLIQS0.0100'  
    set("F[Notification type]", "M1");  
    enter(); 
  5. Add code to populate the 'Functional Location', 'Equipment', and 'Description' fields and then save the new notification. The example code will be as follows.

    Note:The 'VIQMEL-QMTXT' field is the name of the text field that contains the description.

    onscreen 'SAPLIQS0.7200' 
    set('F[Functional loc.]', '1032-ADMI');  
    set('F[Equipment]', '10000957');  
    set('F[VIQMEL-QMTXT]', 'FTE Test');  
    enter('/11'); 
    

    In this example, we are using the WS 'onscreen' command to specify the SAP screens on which we will enter data. On the initial screen, we entered the notification type. We then proceeded to the 'Maintenance Request' screen, where we entered the functional location, the equipment and a description. We then saved the notification by passing the 'Save' code ('/11') through the WS 'enter' command.

  6. To verify that the notification was in fact created, we will capture the new notification number and output it to the Console. You can also choose to output this number to a file if you prefer. The code is as follows.
    onscreen 'SAPLIQS0.0100'
    println('\n------MESSAGE='+_message);
  7. We will now exit from the transaction by sending the exit code '/i' and entering 'Yes' on the ensuring exit confirmation screen. The script code is shown below.
    enter('/i');  
    onscreen 'SAPLSPO1.0100' 
    enter('=YES'); }  
    
  8. Save your changes to the 'functions.sjs' file and then run bot either with Task Scheduler or with the command prompt as previously explained.
  9. A new notification should now be created. To verify that it was actually created, go into the IW22 transaction and enter the number of the new notification into the search field. If you run the task with Task Scheduler, you will not have a notification number, so you must search by date or by description by clicking on the icon beside the search field. In the resulting popup, you can enter the text of your description, or you can enter a date range. In our example below, we will type 'bot Test' into the Search field and click the green checkmark as shown.
     
  10. A list of transactions matching our search criteria will display as shown below.
     
  11. Select the transaction that matches the one you just created. The notification number will be populated into the search field as shown below.
     
  12. Press 'Enter'. The transaction will display in SAP as shown below. Verify that all data has been uploaded to SAP.
     
  13. Once you have created the scripts, launch Task Scheduler as explained in earlier and create a new task to run bot.
  14. Verify that the task runs by searching for your new notifications in the IW22 transaction as described above.

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