Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Benjamin Dasari

Pages: 1 2 3 [4] 5 6 7
46
Purpose: To check if a SAP screen element exists and is visible or not. Both the options return true or false.

isValid - Can be used to check if a SAP screen element exists or not, i.e., if the control is sent from SAP even though it is not visible on the screen.
Syntax:
if(<"F[GR/GI Slip No.]">.isValid)      // Check if the field exists
     set("V[z_migo_grgislipnum]","X");     


isVisible - Can be used to check if a SAP screen element is visible or not on SAPgui.
Syntax:
if(<"F[GR/GI Slip No.]">.isVisible)   // Check if the field is appears on SAPgui
      set("F[GR/GI Slip No.]", " ");     // Set it to blank

Example-
SAP R/3 - ZEUS [Internal to Synactive]
Inputfield - "GR/GI Slip No."
Transactions MIGO and Z_MIGO for Goods Issue. This field is valid on both the transactions, however only visible in MIGO and not Z_MIGO.

NOTE - Below is the link of another forum article where it is used:
http://www.guixt.com/forum/index.php?topic=81.msg85#msg85

47
Purpose: We can cause a delay specified in milliseconds before executing an enter command.
This might be required in cases where the screen displays a status message specifying that it is locked by the current user or if we would like to wait for certain time before executing an action.

In the below example, Enter is performed after the specified number of milliseconds. 

Example:

via Liquid UI Desktop -
     enter(3000);           // In this case the action "Enter" is executed after waiting for 3 seconds

     [OR]

     enter("/11",3000);  // In this case the function code "/11" [Save] is executed after waiting for 3 seconds

via Liquid UI Server -
     sleep(3000);           // Waits for 3 seconds before performing the "Enter" action
     enter();

     [OR]

     sleep(3000);           // Waits for 3 seconds before the enter "/11" action
     enter("/11");


48
Purpose: Mark entry fields with a small red cross to either prompt for user input or highlight the field, etc.
A small red cross is displayed in front of the entry field. This can be achieved by calling the "cmdMark" function and passing parameters to it.

Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPMV45A.E0101.sjs
----------------------------------------------------------------------------------------------------------------------------------------------
// Function to trim blank spaces at the end of the string
String.prototype.trim = function(){return this.replace(/^\s+|\s+$/g,'');}

function getString(strInput) {
   return (typeof(strInput) == 'undefined') ? "" : strInput.toString().trim();
}

function isBlank(strInput) {
   var strVal = getString(strInput);
   var blank = strVal == "";
   return blank;
}

// Function to mark entry fields with a small red cross
function cmdMark(fldName,nOffset,strIcon) {           
   if(isBlank(nOffset) || nOffset < 2) {
      nOffset = 3;
   }
   if(isBlank(strIcon)) {
      strIcon = '02';
   }

   var nRow = <'F['+fldName+']'>.row;
   var nCol = <'F['+fldName+']'>.column;
   text([nRow,nCol-nOffset],'@'+strIcon+'@');
}

// Liquid UI Interface
cmdMark("VBAK-AUART");      // Order Type




49
Purpose: To retrieve the SAP status message if we know the message Type, ID and Number from SE91 transaction code.

Steps -
Follow the below steps in order to retrieve the message-
1.   Navigate to SE91
2.   Table Name: Enter message ID in the Message Class field
3.   In Subobjects, select Messages radio button
4.   In the Number field, enter the message Number
5.   Click Display

This will display the message.
Once we have the message, then we can use indexOf and substring javascript generic functions to perform additional checks, validations, etc.
Ex-
if(_message.substring(0,2)=='E:' &&  _message.indexOf("Invalid Service Order Value")>-1){
     set("V[z_va01_dla_save_err]", "X");
}


Sample Message:

"E: Fill in all required entry fields" - VA01 initial screen, no data filled out, hit Enter

In SE91:

the Message Class is "00"
the Number is "55"

50
Purpose:
Use cursor position [row,column] on a list screen to read data.
The system variables "_listcursorrow" and "_listcursorcol" can be used to find the cursor position on a list screen and further to read the data from that position.

For the below example, list screen is displayed on MB51 transaction.
The cursor position and data stored in "z_listvalue" can be read using the below code:

Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: RM07DOCS.E0120.sjs
----------------------------------------------------------------------------------------------------------------------------------------------
pushbutton([TOOLBAR],'Find Position',{'process':readCursorPositionAndData});

function readCursorPositionAndData() {
        // Put cursor on the icon, to find out its position
        // Once you know the position of the list element, you can use below

        set('V[z_listvalue]','&#['+_listcursorrow+','+_listcursorcol+']');
        println('Value:' + z_listvalue);
}

51
Purpose: To trim the values returned from RFC call.

When we make an RFC call like below:
     rfcres = call("BAPI_USER_GET_DETAIL",{"in.USERNAME":"&V[_user]","out.DEFAULTS":"z_defaults"});

In this case, z_defaults can either be a string value (variable), or a control if defined by inputfield like this:
     inputfield([15,1], 'Test', [15,20], {name:'z_defaults', size:255});

In either one of these cases, the z_defaults value would have to be 'trim' by using the trim command of string.
Without trim, the string length will be 4096, unless the inputfield command is executed again, in which case, it will be truncated to 255.

Using the rfctrim command, you will be able to control this behavior.
By default it will right trim the string (not left trim), which means, all space characters at the end of the string will be removed.
You will now NO longer need to call .trim to trim the string after the RFC call.

To disable this default behavior, use this command-
disable('rfctrim')

And to enable it again, use this command-
enable('rfctrim')

NOTE - This feature is available from Liquid UI Server version 548 onward.

52
WS aka Web Scripts (Attended RPA for SAP) / "applyguiscript" Command
« on: June 06, 2017, 11:55:02 AM »
Purpose:
The applyguiscript command passes variables from a WS script to a Visual Basic (VB) script.
The applpyguiscript command is useful primarily when a user is dealing with special controls such as grids or ActiveX controls.

This command takes only one option which is {"template":true}
This option enables users to execute a pre-made template with the particular variables from the individual screen.
The template option used with applyguiscript enables a user to create a VBS file which is then called with the applyguiscript command.
When applyguiscript is invoked, the template is copied into a temporary file and all variables in the template are replaced with the actual values from the screen in question.
The VBS file then executes using these variables. This is very useful when a number of different values must be operated on in a similar manner.

Syntax:
applyguiscript('filename.vbs');
applyguiscript('C:\\LiquidUI\\Scripts\\filename.vbs');
applyguiscript("filename", {"template":true});

Liquid UI Code:
When user clicks the "IH06 - Select Grid Rows" button on the SAP Easy Access Screen, in this scenario, it navigates us to IH06 transaction and executes and selects the first 7 rows on the GRID screen using VB scripting (applyguiscript).

Sample script for the scenario-
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs
----------------------------------------------------------------------------------------------------------------------------------------------
// Clears the screen UI
clearscreen();
pushbutton([2,2],"IH06 - Select Grid Rows", "/nIH06", {"process":ih06_selectrows, "size":[2,24]});

// Function to execute applyguiscript which selects the first 7 rows of a GRID
function ih06_selectrows(){
   onscreen 'RIIFLO20.1000'
      enter('/8');

   onscreen 'SAPLSLVC_FULLSCREEN.0500'
      applyguiscript("Script1.vbs");
}

NOTE - If the recorded VB script navigates through multiple screens, the related "onscreen" blocks must be added after "applyguiscript" command in the Liquid UI scripts.
Also, place the recorded VBScript file in the same path where the Liquid UI scripts are located for this scenario.

See attachments for code samples!

53
For the iOS, Android and Handheld CE devices, the status messages can be displayed as a pop-up without making any script changes.
For iOS and Android devices, all messages can be displayed on the pop-up; however, for Handheld CE Devices only the error messages can be displayed on the pop-up.

This can be done in the Settings or Profile of the devices.

On iOS:
1. Goto Settings
2. Select the Liquid UI App
3. Turn ON the "Dialog Box at Message" option

Settings -> Liquid UI App -> Dialog Box at Message [ON]

On Android:
1. Open the Liquid UI App
2. Click on the top left corner (3 horizontal lines) to display options
3. Click on the "App Settings"
4. Under SAP Settings, click the "System Message Style" option
5. Turn ON the "Show as Popup" option which is displayed on a popup window
6. Touch anywhere else on the screen besides the popup window for it to be saved and disappear

Liquid UI App -> App Settings -> System Message Style -> Show as Popup [Select radiobutton]

On Handheld CE devices:
1. Create a new connection
2. Under Profile, click on "Profile Management..."
3. Click on "New..."
4. Provide a "Profile Name"
5. Click on "Misc." Tab at the bottom
6. Select the "Dialog Box at Error Message" option
7. Click OK
8. Select the newly created Profile and save the connection settings

Profile Management... -> New... -> Misc. -> Dialog Box at Error Message [check] -> OK


54
WS aka Web Scripts (Attended RPA for SAP) / Set List Screen Checkbox
« on: October 13, 2016, 12:09:01 PM »
Purpose:
Select the checkbox on a list screen.

NOTE - Available from WS Version 1.2.296.0 and Liquid UI Server Version 3.5.524.0 onwards!

Liquid UI Code:

// SAPLSMTR_NAVIGATION.E0100.sjs
pushbutton([TOOLBAR], "NAVIGATE TO LIST SCREEN", "/nLB13", {"process":lb13navigate});      

function lb13navigate(){
   onscreen 'SAPML02B.0204'
      set('F[Warehouse Number]','001');
      set('F[Requirement Number]','F');
      set('C[Completed]','X');
      enter();
}   

// RLLB1300.E0120.sjs
pushbutton([TOOLBAR], "SelectListCheckBox", '?', {"process":selectListCheckBox});      
pushbutton([TOOLBAR], "DeSelectListCheckBox", '?', {"process":deselectListCheckBox});      

// Function to check the list screen checkbox
function selectListCheckBox(){
   onscreen 'RLLB1300.0120'
      set('#[5,1]','X');         
      enter('?');
}

// Function to uncheck the list screen checkbox
function deselectListCheckBox(){
   onscreen 'RLLB1300.0120'
      set('#[5,1]',' ');         
      enter('?');
}


See attachments for code samples!

55
WS aka Web Scripts (Attended RPA for SAP) / WSCurl Send Mail
« on: October 13, 2016, 11:49:14 AM »
Purpose:
Send email using WSCurl from SAP.

Liquid UI Code:

// SAPLSMTR_NAVIGATION.E0100.sjs
load('wscurl');

// Function to check if the string value is blank
function isBlank(jvar) {
    if (jvar==void 0 || jvar=="" || jvar==null) {
        return true;
    } else {
        return false;
    }
}

function sendmail(){   
   /* Initialize the Curl object for making the call*/
   var wsCurl = new Curl();
   
   /* This is the URL for your mailserver. Note the use of port 587 here,
     * instead of the normal SMTP port (25). Port 587 is commonly used for
     * secure mail submission (see RFC4403), but you should use whatever
     * matches your server configuration. */
    // wsCurl.setopt(Curl.CURLOPT_URL, "smtp://smtp.google.com:587");

    wsCurl.setopt(Curl.CURLOPT_URL, "smtp://mail.guixt.com:25");
   
    /* In this example, we'll start with a plain text connection, and upgrade
     * to Transport Layer Security (TLS) using the STARTTLS command. Be careful
     * of using Curl.USESSL_TRY here, because if TLS upgrade fails, the transfer
     * will continue anyway - see the security discussion in the libcurl
     * tutorial for more details. Available 2nd Parameters are Curl.USESSL_NONE(0),
    * Curl.USESSL_TRY(1), Curl.USESSL_CONTROL(2) or Curl.USESSL_ALL(3)*/

    wsCurl.setopt(Curl.CURLOPT_USE_SSL, Curl.USESSL_ALL);

    /* If your server doesn't have a valid certificate, then you can disable
     * part of the Transport Layer Security protection by setting the
     * CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST options to 0 (false).
     *   wsCurl.setopt(Curl.CURLOPT_SSL_VERIFYPEER, 0);
     *   wsCurl.setopt(Curl.CURLOPT_SSL_VERIFYHOST, 0);
     * That is, in general, a bad idea. It is still better than sending your
     * authentication details in plain text though.
     * Instead, you should get the issuer certificate (or the host certificate
     * if the certificate is self-signed) and add it to the set of certificates
     * that are known to libcurl using CURLOPT_CAINFO.
    *    wsCurl.setopt(Curl.CURLOPT_CAINFO, "/path/to/certificate.pem");
     */

    /* A common reason for requiring transport security is to protect
     * authentication details (user names and passwords) from being "snooped"
     * on the network. Here is how the user name and password are provided: */
    // wsCurl.setopt(Curl.CURLOPT_USERNAME, "user@example.net");
    // wsCurl.setopt(Curl.CURLOPT_PASSWORD, "P@ssw0rd");

    wsCurl.setopt(Curl.CURLOPT_USERNAME, "benjamin.dasari@guixt.com");
    wsCurl.setopt(Curl.CURLOPT_PASSWORD, " ");      // Enter the Password

    /* value for envelope reverse-path. '<' '>' are REQUIRED around the email addr*/
    // wsCurl.setopt(Curl.CURLOPT_MAIL_FROM, "<email_of_sender@example.net>");

    wsCurl.setopt(Curl.CURLOPT_MAIL_FROM, "<benjamin.dasari@guixt.com>");
    /* Add two recipients, in this particular case they correspond to the
     * To: and Cc: addressees in the header, but they could be any kind of
     * recipient. */

     wsCurl.slist_append("<benjamin.dasari@guixt.com>");
    // wsCurl.slist_append("<email_of_cc_receipent@example.net>");
   
   /* Set the curl object to attach the recepients added above
    * The second parameter is a REQUIRED string to maintain the syntax,
    *  however it has no effect on the execution*/   

      wsCurl.setopt(Curl.CURLOPT_MAIL_RCPT, "recipients");
     
    /* Since the traffic will be encrypted, it is very useful to turn on debug
     * information within libcurl to see what is happening during the transfer.
     */

    wsCurl.setopt(Curl.CURLOPT_VERBOSE, 1);
   
   /* Set the buffer header and the data for the e-mail that is being sent*/
   var email = ["Date: Mon, 29 Nov 2010 21:54:29 +1100\n",
               "To: <umang.desai@guixt.com>\n",
               "From: <benjamin.dasari@guixt.com>\n",
               "Message-ID: ddmmyyyy.hhmm@domain.com\n",
               "Subject: WS embedded SMTP TLS MESSAGE\n",
               "\n", /* empty line to divide headers from body, see RFC5322 */
               "The body of the message starts here.\n",
               "\n",
               "It could be a lot of lines, could be MIME encoded, whatever.\n",
               "Check RFC5322.\n", NULL ];
            
   /* In this case, we're using a callback function to specify the data. You
     * could just use the CURLOPT_READDATA option to specify a var to read from*/

    wsCurl.setopt(Curl.CURLOPT_READDATA, email);
   
   /* Final step is to call execute to dispatch email*/
   wsCurl.exec();
   
   /* Clean up the recepient list*/
   wsCurl.slist_free_all();
   
   /* Close the smtp connection for the mail server*/
   wsCurl.close();
   
   /* Remove any reference for Garbage Collection*/
   wsCurl= NULL;
}

// User Interface
pushbutton([TOOLBAR], 'Send Mail', '?', {"process":sendmail});


See attachments for code samples!

56
WS aka Web Scripts (Attended RPA for SAP) / _last_fcode Command
« on: October 13, 2016, 11:10:50 AM »
Purpose:
This command is used to capture the last executed function code in the '_last_fcode' system variable.
In the below example, the value of the '_last_fcode' is printed on the Cornelius Output window.

NOTE - Available from WS Version 1.2.295.0 and Liquid UI Server Version 3.5.522.0 onwards!

Liquid UI Code:

// SAPLSMTR_NAVIGATION.E0100.sjs
pushbutton([TOOLBAR], "'_last_fcode' - Test", '/nVA02', {"process":lastFcode});      

function lastFcode(){
   onscreen 'SAPMV45A.0102'
      set('F[Order]','5004');
      println('\nThe last fcode is:'+_last_fcode+':\n');
      enter();
   
   onscreen 'SAPMSDYP.0010'
      println('\nThe last fcode is:'+_last_fcode+':\n');
      enter();
      
   onscreen 'SAPMV45A.4001'
      set('V[z_va02_ponum]','&F[PO Number]');
      println('\nThe last fcode is:'+_last_fcode+':\n');
      enter('=T\\03');

   onscreen 'SAPMV45A.4001'
      println('\nThe last fcode is:'+_last_fcode+':\n');
      enter('/6');

   onscreen 'SAPMF02D.7000'
      println('\nThe last fcode is:'+_last_fcode+':\n');
      enter('=TAB04');

   onscreen 'SAPMF02D.7000'
      println('\nThe last fcode is:'+_last_fcode+':\n');
      enter('/3');

   onscreen 'SAPMV45A.4001'
      println('\nThe last fcode is:'+_last_fcode+':\n');
      enter('/3');

   onscreen 'SAPMV45A.0102'
      println('\nThe last fcode is:'+_last_fcode+':\n');
      enter('/n');
      
   onscreen 'SAPLSMTR_NAVIGATION.0100'
      println('\nThe last fcode is:'+_last_fcode+':\n');
      enter('?');   
}


See attachments for code samples!

57
WS aka Web Scripts (Attended RPA for SAP) / returnvalues Command
« on: October 13, 2016, 10:20:16 AM »
Purpose:
To read data by opening a new session and continue processing in the old session using the data read from the new session.
In the below example, when the 'Test - returnvalues' toolbar pushbutton is clicked, transaction code VA02 is opened in a new session and the PO Number is read and the new session is exited and the PO Number is displayed in the old session.
This is extremely useful when data has to be passed or returned from a new session while processing data in the old session.

NOTE - Available from WS Version 1.2.295.0 and Liquid UI Server Version 3.5.522.0 onwards!

Liquid UI Code:

//ESESSION.SJS
load('functions.sjs');

// SAPLSMTR_NAVIGATION.E0100.sjs
clearscreen();
inputfield([1,0], "PO Number", [1,16], {"size":18, "name":"z_ponum", "readonly":true});   
pushbutton([TOOLBAR], "Test - returnvalues", "/oVA02", {"process":readPONum, 'using':{'l_order':'5004'}});      

//functions.sjs
function readPONum(param){
   onscreen 'SAPMV45A.0102'
      set('F[Order]',param.l_order);
      enter();
   
   onscreen 'SAPMSDYP.0010'
      enter();
      
   onscreen 'SAPMV45A.4001'
      set('V[z_va02_ponum]','&F[PO Number]');
      returnvalues({'fcode':'?','process':processOldSession,'using':{'l_ponum':z_va02_ponum}});
                enter('/i');   
}
 
function processOldSession(param){
   onscreen 'SAPLSMTR_NAVIGATION.0100'
      set('V[z_ponum]',param.l_ponum);
      message('S: Read PO Number successful!');
      enter('?');
}   


See attachments for code samples!

58
WS aka Web Scripts (Attended RPA for SAP) / WSCurl Translate Language
« on: September 22, 2016, 01:40:34 PM »
Purpose:
Using WSCurl, input text in a non-Western language and then use a service such as Google Translate to change the text into English or some other language.

Liquid UI Code:

// SAPLSMTR_NAVIGATION.E0100.sjs
load('wscurl');

// Function to check if the string value is blank
function isBlank(jvar){
    if (jvar==void 0 || jvar=="" || jvar==null) {
        return true;
    }
    else {
        return false;
    }
}

/* Function is used to input text in a non-Western language and then use a service
   such as Google Translate to change the text into English or some other language */

function translate(param){   
   var z_text = param.toTranslate;
   var z_language = param.targetLang;
   
   /* Initialize the Curl object for making the call*/
   var wsCurl = new Curl();
   
   /* Fixed string to fetch data after translation from googleapis.com*/
   var baseURL = "https://www.googleapis.com/language/translate/v2?key=AIzaSyChzKkNGfmuBAhZXPD7Pw-1nl4e0c6shNw&q=";
   
   /* Say the text you want to convert is stored in variable "z_text", lets covert it to URI for web*/
   var textToConvert = encodeURI(z_text);
   
   /* Set source language identifier*/
   var sourceLangIdentifier = "&source=";
   
   /* Set source language (see language format below)*/
   var sourceLang = "en";
   
   /* Set translation language identifier*/
   var translateLangIdentifier = "&target=";
   
   /* Set translation language (see language format below)*/
   var translateLang = z_language;
      
   /* LANGUAGE FORMAT:
    * google.language.Languages:
    *
    * 'AFRIKAANS' : 'af',
    * 'ALBANIAN' : 'sq',
    * 'AMHARIC' : 'am',
    * 'ARABIC' : 'ar',
    * 'ARMENIAN' : 'hy',
    * 'AZERBAIJANI' : 'az',
    * 'BASQUE' : 'eu',
    * 'BELARUSIAN' : 'be',
    * 'BENGALI' : 'bn',
    * 'BIHARI' : 'bh',
    * 'BULGARIAN' : 'bg',
    * 'BURMESE' : 'my',
    * 'CATALAN' : 'ca',
    * 'CHEROKEE' : 'chr',
    * 'CHINESE' : 'zh',
    * 'CHINESE_SIMPLIFIED' : 'zh-CN',
    * 'CHINESE_TRADITIONAL' : 'zh-TW',
    * 'CROATIAN' : 'hr',
    * 'CZECH' : 'cs',
    * 'DANISH' : 'da',
    * 'DHIVEHI' : 'dv',
    * 'DUTCH': 'nl',
    * 'ENGLISH' : 'en',
    * 'ESPERANTO' : 'eo',
    * 'ESTONIAN' : 'et',
    * 'FILIPINO' : 'tl',
    * 'FINNISH' : 'fi',
    * 'FRENCH' : 'fr',
    * 'GALICIAN' : 'gl',
    * 'GEORGIAN' : 'ka',
    * 'GERMAN' : 'de',
    * 'GREEK' : 'el',
    * 'GUARANI' : 'gn',
    * 'GUJARATI' : 'gu',
    * 'HEBREW' : 'iw',
    * 'HINDI' : 'hi',
    * 'HUNGARIAN' : 'hu',
    * 'ICELANDIC' : 'is',
    * 'INDONESIAN' : 'id',
    * 'INUKTITUT' : 'iu',
    * 'ITALIAN' : 'it',
    * 'JAPANESE' : 'ja',
    * 'KANNADA' : 'kn',
    * 'KAZAKH' : 'kk',
    * 'KHMER' : 'km',
    * 'KOREAN' : 'ko',
    * 'KURDISH': 'ku',
    * 'KYRGYZ': 'ky',
    * 'LAOTHIAN': 'lo',
    * 'LATVIAN' : 'lv',
    * 'LITHUANIAN' : 'lt',
    * 'MACEDONIAN' : 'mk',
    * 'MALAY' : 'ms',
    * 'MALAYALAM' : 'ml',
    * 'MALTESE' : 'mt',
    * 'MARATHI' : 'mr',
    * 'MONGOLIAN' : 'mn',
    * 'NEPALI' : 'ne',
    * 'NORWEGIAN' : 'no',
    * 'ORIYA' : 'or',
    * 'PASHTO' : 'ps',
    * 'PERSIAN' : 'fa',
    * 'POLISH' : 'pl',
    * 'PORTUGUESE' : 'pt-PT',
    * 'PUNJABI' : 'pa',
    * 'ROMANIAN' : 'ro',
    * 'RUSSIAN' : 'ru',
    * 'SANSKRIT' : 'sa',
    * 'SERBIAN' : 'sr',
    * 'SINDHI' : 'sd',
    * 'SINHALESE' : 'si',
    * 'SLOVAK' : 'sk',
    * 'SLOVENIAN' : 'sl',
    * 'SPANISH' : 'es',
    * 'SWAHILI' : 'sw',
    * 'SWEDISH' : 'sv',
    * 'TAJIK' : 'tg',
    * 'TAMIL' : 'ta',
    * 'TAGALOG' : 'tl',
    * 'TELUGU' : 'te',
    * 'THAI' : 'th',
    * 'TIBETAN' : 'bo',
    * 'TURKISH' : 'tr',
    * 'UKRAINIAN' : 'uk',
    * 'URDU' : 'ur',
    * 'UZBEK' : 'uz',
    * 'UIGHUR' : 'ug',
    * 'VIETNAMESE' : 'vi',
    * 'UNKNOWN' : ''
    */
   
   
   /* Build the URL to make a call*/
   var completeURL = baseURL + textToConvert + sourceLangIdentifier + sourceLang + translateLangIdentifier + translateLang;
   set("V[g_URL]",completeURL);
   /* This is the URL for your translation request. Note this use is for
    * calls made to Google Translate which returns us the JSON object in string */

    wsCurl.setopt(Curl.CURLOPT_URL, completeURL);
   
   /* Final step is to call execute to dispatch email. You can check the return
    * code to avoid errata string which can be found from "wsCurl.error"
    * return value 0 means success */

   var response = wsCurl.exec();
   var error = wsCurl.error;
   posStart = response.lastIndexOf(":") + 2;
   posEnd = response.lastIndexOf("\"") + 1;
   strTranslated = response.substring(posStart,posEnd);
   
   set("V[g_translated]", strTranslated);

   /* Response of THIS particular query is JSON. You can get HTML for other URLs
    * Parse to suite your requirements
    * e.g. response from the ABOVE URL is JSON string which looks like
    * {
    *   "data": {
    *      "translations": [
    *         {
    *            "translatedText": "Bonjour tout le monde"
    *            }
    *         ]
    *      }
    *  }
    */

   
   /* Close the http connection for the URL fetch*/
   wsCurl.close();
   
   /* Remove any reference for Garbage Collection*/
   wsCurl= NULL;
}

// User Interface
clearscreen();
inputfield([1,1], "Orignal String", [1,15], {"name":"g_source1", "size":50});
inputfield([3,1], "Target Language", [3,15], {"name":"g_langugage1", "size":5});
if(isBlank(g_URL)){
   g_URL = "";
}
text([7,1], "URL:  " + "&V[g_URL]" );
if(isBlank(g_translated)){
   g_translated = "";
}
inputfield([9,1], "Target String", [9,15], {"name":"g_translated", "size":200});
pushbutton([TOOLBAR], 'toTranslate', '?',{"process":translate, "using":{"toTranslate":g_source1,"targetLang":g_langugage1}});


See attachments for code samples!

59
WS aka Web Scripts (Attended RPA for SAP) / WSCurl SimpleHTTP
« on: September 22, 2016, 12:34:11 PM »
Purpose:
Execute a simple URL and retrieve metadata information using WSCurl.

Liquid UI Code:

// SAPLSMTR_NAVIGATION.E0100.sjs
load('wscurl');

// 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;
}

// User Interface
clearscreen();
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"});


See attachments for code samples!

60
WS aka Web Scripts (Attended RPA for SAP) / WSCurl Get IP Address
« on: September 21, 2016, 03:46:14 PM »
Purpose:
Retrieve the public IP Address using WSCurl.

Liquid UI Code:

// SAPLSMTR_NAVIGATION.E0100.sjs
load('wscurl');

// Function to check if the string value is blank
function isBlank(jvar) {
    if (jvar==void 0 || jvar=="" || jvar==null) {
        return true;
    } else {
        return false;
    }
}

// Function to retrieve IP address using WSCURL
function getIPAddress(){
   var wsCurl = new Curl();
      
   /* Build the URL to make a call*/
   var completeURL = "http://www.howtofindmyipaddress.com/";
   
   /* This is the URL for your translation request. Note this use is for
    * calls made to Google Translate which returns us the JSON object in string*/

    wsCurl.setopt(Curl.CURLOPT_URL, completeURL);
   
   /* Final step is to call execute to dispatch email. You can check the return
    * code to avoid errata string which can be found from "wsCurl.error"
    * return value 0 means success*/

   var response = wsCurl.exec();
   var error = wsCurl.error;
   ipaddrline = response.substring(1670,1700);
   
   if(!isBlank(ipaddrline)){
      if(error == 0){
         posStart = ipaddrline.lastIndexOf(">") + 1;
         posEnd = ipaddrline.lastIndexOf("\/") - 1;
         ipaddress = ipaddrline.substring(posStart,posEnd);
         if(isBlank(ipaddress)){
            message('E: Could not find IP address, change URL');
         } else{
            set('V[z_ipaddress]','&V[ipaddress]');
         }   
      }   
   } else{
      message('E: Could not find IP address, change URL');
   }
   
   /* Close the http connection for the URL fetch*/
   wsCurl.close();
   
   /* Remove any reference for Garbage Collection*/
   wsCurl= NULL;
}

// User Interface
clearscreen();
pushbutton([TOOLBAR], 'Get IP Address', '?',{"process":getIPAddress});
inputfield([1,0], "IP Address", [1,16], {"size":15, "name":"z_ipaddress", "readonly":true});   


See attachments for code samples!

Pages: 1 2 3 [4] 5 6 7