Liquid UI - Documentation - 14.02 Retrieve metadata information of a website

14.02 Retrieve metadata information of a website


Prerequisites


Purpose

You will learn how to execute a simple URL and retrieve metadata information using wsCurl. To demonstrate this, we’ll walk you through the following steps:

  • Delete unnecessary elements on the SAP screen using the del command
  • Add a pushbutton to execute the process on click
  • Add a text field
  • Add a text box to display the retrieved metadata
  • Add a function to retrieve the metadata of the given website


User Interface

Create the file SAPLSMTR_NAVIGATION.E0100.sjs inside your script folder for customizing the SAP Easy Access screen.
//Now, let's start adding the script to the above file and save it.


Customization

  1. Logon to SAP, and delete the image container on it using the del command, as shown below:
     
    // Deletes an image container on the SAP Easy Access screen.
    del("X[IMAGE_CONTAINER]");
    
     
  2. Add a pushbutton with the label WWW.GUIXT.COM to execute the process simple_http that retrieves the metadata information using wsCurl on click.
     
    pushbutton([1,0], 'WWW.GUIXT.COM', '?',{"size":[1,15], "process":simple_http});
    text([3,1], "http Details below - ");
    textbox([4,1], [24, 100],{"name":"z_text"});
     
     
  3. Add a text field with the label http Details below, as shown in the image below.
     
    // Creates a text field with the label http Details below 
    text([3,1], "http Details below - ");

     
     
  4. Add a text field with the label http Details below, as shown in the image below.
     
    // Creates a text box to display the output, as shown in the image below
    textbox([4,1], [24, 100],{"name":"z_text"});

     
     
  5. Add the wscurl file using the load command in this script to use WS services to translate the text entered in the input field.
     
    // includes a file in this script file 
    load('wscurl');
     
  6. Now, add the following Liquid UI script to the above file and save it.
     
    // Function to execute a simple URL and retrieve information
    function simple_http() {    
        var wsCurl = new Curl();
            
        /* Build the URL to make a call*/
        var completeURL = "http://www.guixt.com/";

        /* Note this use is for calls made to www.guixt.com which returns us the JSON object in string*/
        wsCurl.setopt(Curl.CURLOPT_URL, completeURL);
        
        /* You can check the return code to avoid error data string which can be found from "wsCurl.error"
         * return value 0 means success*/
        var response = wsCurl.exec();
        var error = wsCurl.error;
        
        z_tmp = response.substring(0,2000);
        copytext({"fromstring":"z_tmp", "totext":"z_text"});
        
        /* Close the http connection for the URL fetch*/
        wsCurl.close();
        
        /* Remove any reference for Garbage Collection*/
        wsCurl= NULL;
    }


    SAP Process

    1. Refresh the SAP screen and click on the WWW.GUIXT.COM pushbutton. Then, the function simple_http is executed and the metadata of the given website will be displayed in the text box created, as shown in the image below.
       
       
       

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