Author Topic: _clipboard - Copy contents from/to windows clipboard using Liquid UI Server  (Read 11413 times)

Benjamin Dasari

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 96
    • View Profile
Purpose:
To be able to either copy data from SAPgui or user input data onto the Windows clipboard and/or retrieve data stored on the clipboard using Liquid UI scripts.
'_clipboard' is the system variable which will hold the data copied to/from clipboard.
Data could be string, multi-line text or array.

Copy TO clipboard:
If data to be saved on clipboard is from SAPgui, then the below syntax should be used:
onscreen "SAPLSPO5.0110"   
      set("R[In the clipboard]", "X");
      enter({"toclipboard":true});   // Copy contents to clipboard

If data from variable, text or array needs to be copied to clipboard, then use the below syntax:
    _clipboard = strVar;   // Copy data from string variable to clipboard
    _clipboard = txt1;     // Copy data from textbox to clipboard
   _clipboard = arrNotif;   // Copy data from array to clipboard


Retrieve FROM clipboard:
If the data that is stored in clipboard has to be retrieved, then use the below syntax:
   var strVar = _clipboard;    // Copy data from clipboard to string variable


NOTE: 
The '_clipboard' system variable is available only through the Liquid UI Server.
Feature available from Liquid UI Server version 3.5.572.0 onwards.
Feature recently added to Desktop from version 1.2.339.0 onwards, so no need to use the shell execute as specified below:
/*************************************************************************
IGNORE THIS - For Desktop, shell execute is used to copy to clipboard. Below is the link to refer to that article:
http://www.guixt.com/forum/index.php?topic=97.msg101#msg101
/*************************************************************************

See attachments for code samples and screenshots!

Liquid UI Code:

// SAPLSMTR_NAVIGATION.E0100.sjs
// SAP Easy Access Screen
clearscreen();
pushbutton([1,2], "Clipboard TO (Copy from IW28 Notification details and displayed in below textbox)", "?", {"size":[2,70], "process":procClipboardTo});
pushbutton([4,2], "Clear Textbox", "?", {"size":[2,20],"process":procClearTextbox});
textbox([8,2],[24,80],{"name":"mytext1"});
pushbutton([26,2], "Clipboard FROM (Copy data from string, array or text and pasted in IW28)", "?", {"size":[2,70], "process":procClipboardFrom});

// Function to clear textbox
function procClearTextbox(){
   var strBlank = "";   
   copytext({"fromstring":"strBlank","totext":"mytext1"});
}

// Function to copy to clipboard
// The copied value will be available in _clipboard variable

function procClipboardTo(){
   onscreen "SAPLSMTR_NAVIGATION.0100"
      enter("/nIW28");
      
   onscreen "RIQMEL20.1000"   
      set("F[Notification type]", "M1");
      enter("/8");
      
   onscreen "SAPLSLVC_FULLSCREEN.0500"
      enter("/Menu=1,12,3");
      
   onscreen "SAPLSPO5.0110"   /*ZEUS*/
   //onscreen "SAPLSPO5.0101" /*JUNEAU*/
      set("R[In the clipboard]", "X");
      enter({"toclipboard":true});      // Copy contents to clipboard

   onscreen "SAPLSLVC_FULLSCREEN.0500"
       // _clipboard system variable will have the data which can be copied to variable or text
      var str = _clipboard;
      enter("/n");
      
   onscreen "SAPLSMTR_NAVIGATION.0100"   
      copytext({"fromstring":"str","totext":"mytext1"});
      enter('?');
}

// Function to set value to be copied to clipboard
// Can be copied from string, text and arrays
// Will paste the data from _clipboard to IW28 Notification multi selection pop-up

function procClipboardFrom(){
   onscreen "SAPLSMTR_NAVIGATION.0100"
      enter("/niw28");
      
   onscreen "RIQMEL20.1000"   
      set("F[Notification type]", "M1");
      // _clipboard will hold the text in variable 'txt1'
      set('V[abc]',"");
      set('V[abc1]',"123456");
      set('V[abc2]',"123457");
      set('V[abc3]',"123458");
      copytext({'totext':'txt1','fromstring':'abc'});
      copytext({'totext':'txt1','fromstring':'abc1','appendline':true});
      copytext({'totext':'txt1','fromstring':'abc2','appendline':true});
      copytext({'totext':'txt1','fromstring':'abc3','appendline':true});
      
      // _clipboard will hold the data in array 'arrNotif'
      arrNotif = [];
      for(var i=0;i<50;i++){
         var strqq = ""+i;
         set('V[str]',strqq);
         arrNotif.push(str);
      }
      arrNotif.push("12345");
      arrNotif.push("12346");
      arrNotif.push("12347");
      // _clipboard = txt1;      // Uncomment this line and comment below line, to paste value of txt1
      _clipboard = arrNotif;      // Uncomment this line and comment above line, to paste value of array arrNotif
      enter("=%018");
      
   onscreen "SAPLALDB.3000"      
      enter('/24');   // Paste content of clipboard
}

« Last Edit: August 31, 2018, 11:32:28 AM by Benjamin Dasari »