Liquid UI - Documentation - 19.23 Copy contents from/to windows clipboard using _clipboard system variable

19.23 Copy contents from/to windows clipboard using _clipboard system variable


Prerequisites


Purpose

Using the _clipboard system variable, you can copy data to/from the clipboard, which can be a string, multi-line text, or an array. In this article, we’ll demonstrate how to copy notification details from the IW28 transaction to the Windows clipboard and retrieve data stored on the clipboard.

Note: The ‘_clipboard’ system variable is available through the Liquid UI Server and desktop. This feature is available from Liquid UI Server version 3.5.572.0 onward. For desktops, shell execute is used to copy to the clipboard.


User Interface

Follow the steps below to copy the notification details from the Change Notification screen to the textbox on the SAP Easy Access screen.

  1. Delete the image container on the SAP Easy Access screen
  2. Add push buttons to copy and clear the text
  3. Add a textbox to display the copied text
  4. Add a function to copy the text from the clipboard.


User Interface

//Create this file inside your script folder for customizing the SAP Easy Access screen, SAPLSMTR_NAVIGATION.E0100.sjs

//Now, let's add the Liquid UI script to the above file and save it.

 

Customization

  1. Delete the image container on the SAP Easy Access screen using del().
     
    // Deletes the image container
    del("X[IMAGE_CONTAINER]");
    
     
     
  2. Add a textbox to display the copied text.
     
    //Creates a textbox to display the copied text
    textbox([8,2],[24,80],{"name":"mytext1"});
     
     
  3. Add three push buttons labeled Clipboard To (Copy from IW28 Notification details and display in below textbox), Clipboard FROM (Copy data from string, array, or text and past in IW28), and Clear Textbox.
     
    //Creates three push buttons to copy and clear the text from file
    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});
    
     
     
  4. Add a function to copy the text to the clipboard
     
    // 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('?');
    }
    
     
  5. Add a function to copy text to the IW28 screen
     
    // 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
    }
    
     
  6. Add a function to clear the text
     
    //Function to clear textbox
    // Function to clear textbox
    function procClearTextbox(){
       var strBlank = "";   
       copytext({"fromstring":"strBlank","totext":"mytext1"});
    }
    
     

SAP Process

  1. Refresh the SAP Easy Access screen. Now, you can see the customized screen with the Copy to Clipboard functionality. Click Clipboard To pushbutton to copy notification details from the IW28 transaction and paste them into the textbox.
     
     
  2. Select the format In the clipboard from the list, click Continue. Then the notification details are pasted in the textbox from the clipboard, as shown below.
     
     
    Note: Data is copied to the clipboard and stored in the ‘_clipboard’ system variable.
     
  3. Click the Clear Textbox push button to delete the content in the textbox.
     
     
  4. Click the Clipboard FROM (Copy data from string, array, or text and paste it into IW28) push button. You will be navigated to the Change Notification screen with the Multiple Selection for Notification popup window. Click the upload from the clipboard (Paste) button to paste the clipboard content in the popup fields.
     
     

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