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 ... 7
1
Purpose:
Using _tabrow on Liquid UI table with pushbutton option to retrieve the clicked row details.

For the below example, Liquid UI table is displayed on SAP Easy Access screen.
Click the pushbuttons on the UI to clear or populate the table with random data.
Click the pushbuttons in the Liquid UI table to retrieve the clicked row number and get that row Material details.

Liquid UI Code:
---------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs
---------------------------------------------------------------------------------

pushbutton([TOOLBAR],'Find Position',{'process':readCursorPosition});

function readCursorPosition(){
        // Put cursor in the table cell, to find out its position
        set('V[z_rowcol]','['+_tabrow+','+_tabcol+']');
        println('Value:' + z_rowcol);
}


//USER INTERFACE
clearscreen();
table([6,1], [30,48],{"name":"z_table", "title":"LUI Table", "rows":20, "rowselection":true});
   column("Material", {"size":18, "table":"z_table", "name":"z_print_mat", "readonly":true});
   column("Desc", {"size":18, "maxlength":40, "table":"z_table", "name":"z_print_matdesc", "readonly":true});
   column("Row #'s", {"size":4, "table":"z_table","label":"@AA@", "pushbutton":true,"fcode":"?","process":fnGetClickedRowData});
               
pushbutton([1,1],"Clear Table","?",{"process":fnClearTable,"size":[2,20]});               
pushbutton([1,22],"Fill Data Table","?",{"process":fnFillTable,"size":[2,20]});               
comment([4,1],"[Click on the LUI table row pushbuttons to get the Row number and Material number]");      
         



// FUNCTIONS
// Function to clear the Liquid UI table based on parameters
function clear_values(tablename, columnArray, rows){   
   for (var loop = 0; loop < rows; loop++){
      for (var col=0; col<columnArray.length; col++){   
         tablename[columnArray[col]][loop] = "";
      }
   }   
}               


function fnClearTable(){
   if(typeof z_table =='object'){
      clear_values(z_table,["z_print_mat","z_print_matdesc"],20);
      for(var idx=0;idx<20;idx++){
         z_table.selectedrows[idx] = " ";
      }
   }        
}


function fnFillTable(){
   if(typeof z_table =='object'){
      for(var idx=0;idx<20;idx++){
         z_table.z_print_mat[idx] = "12340"+idx;
         z_table.z_print_matdesc[idx] = "Test Desc_"+idx;
      }
   }        
}

function fnGetClickedRowData(){
   if(_tabrow == -1){
      message("E: No data found, please click 'Fill Data Table' first");
   } else {
      zrow = _tabrow-1;
      message("S: You clicked Row# "+_tabrow+" and Material# is "+z_table.z_print_mat[zrow]);
   }
}

2
Purpose:
Opening a URL link is different via direct connect and Liquid UI Server.
This article explains how to open links when connecting through a Liquid UI server.


Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs       // SAP Easy Access
----------------------------------------------------------------------------------------------------------------------------------------------
//================================================
// User Interface
//================================================
del("X[IMAGE_CONTAINER]");
pushbutton([4,1],"Open URL/Link via LUI Server","?",{"process":openURLviaServer});



//================================================
//Function Scripts
//================================================
// Function prototype to trim blank characters from a string
String.prototype.trim = function () {
   return this.replace(/^\s+|\s+$/g, "");
}

// Function to return trimmed string
function getString(strInput) {
   return (typeof(strInput) == 'undefined' || strInput == 'undefined') ? "" : strInput.toString().trim();
}

// Function to check for blank string
// Specifically used to determine if input exist in the edit field
function isBlank(strInput) {
   var strVal = getString(strInput);
   var blank = strVal == "";
   return blank;
}

//Function to delete toolbar buttons on popup
function delButtonsRSM0400() {
   del('P[Continue]');
   del('P[Generate]');
   del('P[End Session]');
   del('P[Cancel]');
   if(<'P[Delete Session]'>.isValid)      del("P[Delete Session]");
}

//Function to display Liquid UI message popup
function procLUIMessageBox(param){
   var intHeight = 5 + 4 + param.l_message.length;
   var intPaintRow = 1;
   var intPaintCol = 3;
   enter("/o");
               
   onscreen 'RSM04000_ALV_NEW.2000'
      goto RESIZE_REPAINT;
      
   onscreen 'RSM04000_ALV.2000'
      RESIZE_REPAINT:;
      clearscreen();
      delButtonsRSM0400();
   
      title(param.l_title);
      
      if(isBlank(param.l_viewtext))   var viewTextContent='';
      else var viewTextContent = param.l_viewtext;
      if(isBlank(param.l_viewhtml))   var viewHTMLContent='';
      else var viewHTMLContent = param.l_viewhtml;
      if(isBlank(param.l_viewheight))   var viewHeight=0;
      else var viewHeight = param.l_viewheight;
      
      //Logic to render message
      for(var idxI=0; idxI<param.l_message.length; idxI++){
         var intWidth = (intWidth>param.l_message[idxI].length)?intWidth:param.l_message[idxI].length;
         if(param.l_message[idxI].indexOf("\t")==0)      //When message needs to be indented
            text([intPaintRow+idxI,intPaintCol+4], param.l_message[idxI]);
         else
            text([intPaintRow+idxI,intPaintCol], param.l_message[idxI]);
      }
      intWidth = intWidth+20;
      if(intWidth<51) intWidth=52;
      
      intPaintRow = 2 + param.l_message.length;
      if(!isBlank(fileURL)) {
         windowsize([5,5,90,intHeight+viewHeight]);
         view([intPaintRow-1,5],[intPaintRow+viewHeight,60],fileURL,{'name':fileURLName});
         intPaintRow = intPaintRow+1;
      } else if(viewTextContent.length>0) {
         textbox([intPaintRow,1],[intPaintRow+14,148],{'name':'viewTextContent','readonly':true});
         intPaintRow = intPaintRow+15;
         windowsize([5,5,150,intHeight+15]);
      } else if(viewHTMLContent.length>0) {
         var viewingFile = generatePrintableView(viewHTMLContent);
         var viewHNDL = getTodayDateTimeStr('HMS');
         //var viewingFile = viewHNDL+GP_Path_User+'PRINTCONTENT.htm';
         //view([intPaintRow,1],[intPaintRow+14,146],'&V[GP_Path_User]PRINTCONTENT.htm',{'name':viewHNDL});
         view([intPaintRow,1],[intPaintRow+14,146],viewingFile,{'name':viewHNDL});
         intPaintRow = intPaintRow+15;
         windowsize([5,5,150,intHeight+15]);
      } else {
         windowsize([5,5,intWidth,intHeight+1]);
      }
      fileURL = '';
      
      //Draw buttons according to type
      switch(param.l_type) {
         case "MB_YESNO":
            pushbutton([intPaintRow,intPaintCol], "@01@Yes", "/12",{"eventid":"YES", "size":[2,20]});
            pushbutton([intPaintRow,25], "@02@No", "/12",{"eventid":"NO", "size":[2,20]});
            break;
            
         case "MB_OKCANCEL":
            pushbutton([intPaintRow,intPaintCol], "@01@OK", "/12",{"eventid":"OK", "size":[2,20]});
            pushbutton([intPaintRow,25], "@02@Cancel", "/12",{"eventid":"CANCEL", "size":[2,20]});
            break;
            
         case "MB_OK":
            pushbutton([intPaintRow+viewHeight,intPaintCol], "@01@OK", "/12",{"eventid":"OK", "size":[2,20]});
            break;
            
         default:
            pushbutton([intPaintRow,intPaintCol], "OK", "/12",{"eventid":"OK", "size":[2,20]});
            break;
      }
}


function openURLviaServer(){
   //Set the path to where the html file can be created
   Z_PATH_LINK = "C:\\LiquidUI\\Scripts\\";
   
   onscreen "SAPLSMTR_NAVIGATION.0100"
      lFile = [];
      lLink = 'X';
      lName = 'LiquidUI_Web_Link_';
      set("V[tmpLink]","https://www.liquid-ui.com/");      //Set the link (URL) you want to open
      lFile.push([tmpLink,'LiquidUI_Web_Link']);
      reenter({'process':I_INITIAL_SCREEN_INFORMATION,'using':{'l_filename':lFile,'l_name':lName,'l_link':lLink}});
}


function I_INITIAL_SCREEN_INFORMATION(param){
   // SAP Easy Access
   enter('?');
   onscreen '*'
      var arrFiles = param.l_filename;
      var arrf1N = [];
      set('V[t1]',param.l_filename);
      
      set("V[t2]", 'Link');
      set("V[f1N]", '&V[Z_PATH_LINK]&V[t1]');
      for(var i=0;i<arrFiles.length;i++) {
         if(param.l_link == 'X') {
            set("V[f1N]", arrFiles[0]);
         } else {
            if(isBlank(param.l_type)) {
               set("V[f1N]", '&V[Z_PATH_LINK]'+arrFiles[0]);
            } else if(param.l_type == 'MACRO') {
               set("V[f1N]", '&V[Z_PATH_MACRO]'+arrFiles[0]);
            }
         }
         arrf1N.push([f1N,arrFiles[1]]);
      }
      fileURLName = param.l_name;
      fileURL = generateDynamicViewFileLinkV2(arrf1N,fileURLName+'VIEW.htm',param.l_link);
      
      title('Opening &V[t2] Please Wait...');
      strType = "MB_OK";
      strTitle = "View Link";
      aryMessage = [];
      aryMessage.push("Click to Open Link");
      reenter({"process":procLUIMessageBox, "using":{"l_type":strType, "l_title":strTitle, "l_message":aryMessage,'l_viewheight':arrFiles.length}});   
}


function generateDynamicViewFileLinkV2(arrInpFile,viewSuffix,strLink) {
   var fileName = Z_PATH_LINK+viewSuffix;
   removefile(fileName);
   var textString = "<html><head><body bgcolor='#FFFFFF'>";
   copytext({'tofile':'&V[fileName]','fromstring':'textString','appendline':true});

   for(var i=0;i<arrInpFile.length;i++) {
      if(strLink == 'X') {
         var textString1 = "<a href=\"";
      } else {
         var textString1 = "<a href=\"file:///";
      }
      var textString2 = arrInpFile[0];
      if(strLink == 'X') {
         var textString3 = "\" target=\"_blank\"><B><I><U>"+arrInpFile[1]+"</U></I></B>[/url]</BR>";
      } else {
         if(arrInpFile[0].toString().indexOf('.')>-1) {
            var textString3 = "\"><B><I><U>"+arrInpFile[1]+"</U></I></B>[/url]</BR>";
         } else {
            var textString3 = "\" target=\"_explorer.exe\"><B><I><U>"+arrInpFile[1]+"</U></I></B>[/url]</BR>";
         }
      }
      var textString = textString1+textString2+textString3;
      copytext({'tofile':'&V[fileName]','fromstring':'textString','appendline':true});
   }
   var textString = "</body></head></html>";
   copytext({'tofile':'&V[fileName]','fromstring':'textString','appendline':true});
   closefile(fileName)
   return fileName;
}


See attachments for code samples!

3
Purpose:
Required RFC authorizations for 'RFC_READ_TABLE' function module.

1. S_RFC: RFC_TYPE=FUGR, RFC_NAME=SYST, ACTVT=16
Note: Needed for sapnwrfc which is the newer RFC library from SAP


2. S_TABU_NAM: ACTVT=03, TABLE=SRGBTBREL
Note: Needed to check if attachment exists for work order or not (Table name will change as needed)




Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLCORU.E3200.sjs       // IW41 Actual Data
----------------------------------------------------------------------------------------------------------------------------------------------
// Load the generic functions
load("stringFunctions.sjs");

// User Interface
pushbutton([TOOLBAR], "@4P@Attachments", '?', {'size':[2,32], 'process':iw41_viewAttachments});


// Related functions
// Function to open attachment list if it exists

function iw41_viewAttachments(){
   println("\n ==== Entered function iw41_viewAttachments ===\n");
   
   set("V[z_iw37n_order]","&F[Order]");
   var result = attachmentListExists(z_iw37n_order,12);
   if(!result){
      return("E: No attachments exists");
   } else {
      setcursor("F[Order]");
      enter('/2');
   }
   
   onscreen 'SAPLCOIH.3000'
      enter({'control':'GOSCONTAINERCTRL.Toolbar','item':'%GOS_TOOLBOX;75;89','event':2});      //Object for services
      
   onscreen 'SAPLSWUG.0100'   
      set("cell[TABLE,0,1]","X")
      enter();
      
   onscreen 'SAPLCOIH.3000'
      enter({'control':'GOSCONTAINERCTRL.Toolbar','item':'%GOS_VIEW_ATTA','event':1});              //Attachment List
   
}


// Function uses RFC call to check if attachment list exists for order
function attachmentListExists(strDocNum, nPadding, strYear){         
   println("\n ==== Entered function attachmentListExists ===\n");
   
   var z_in_query_table = "SRGBTBREL";
   if(hasValue(strYear)){
      var z_options = ["INSTID_A = '" + (padString(strDocNum,nPadding,PADDING_LEFT,"0")) + strYear + "'"];
   } else {
      var z_options = ["INSTID_A = '" + (padString(strDocNum,nPadding,PADDING_LEFT,"0")) + "'"];
   }
   var z_fields = ["INSTID_B"];
   var z_InstanceID = [];
   var bResult = false;

   rfcResult = call("RFC_READ_TABLE", {"in.QUERY_TABLE":"z_in_query_table",
                              "table.OPTIONS":"z_options",
                              "table.FIELDS":"z_fields",
                              "table.DATA(width:3000)":"z_InstanceID"});
   println("=====>> Check RFC_READ_TABLE Exception="+rfcResult.exception+"<==");
   println("=====>> Check z_InstanceID.length="+z_InstanceID.length+"<==");
   //FOL18          4 EXT44000000000134
   
   if(z_InstanceID.length>0){
      bResult = true;
   }
   return bResult;
}


See attachments for code samples!


4
Symptoms
When you use Liquid UI to open a dialog window with certain Windows OS[19042.1083, 19042.1165] to select a file, you receive Javascript runtime error related to insufficient memory.
"CommonDialog: The common dialog function failed during initialization. This error often occurs when insufficient memory is available".

This article provides work around to the issue.


Resolution/Work around(a classic select file window shows up):
Change the flags as specified below in getFilesToUpload() function:

function getFilesToUpload(szPrompt)

    if(szPrompt==void 0) szPrompt = 'Select File';
    var dialog = new ActiveXObject('MsComDlg.CommonDialog');
    dialog.Filter='All Files(*.*)|*.*'; 
    dialog.MaxFileSize=32767; 
    dialog.DialogTitle=szPrompt;
    //dialog.Flags=0x200|0x80000|0x800|0x4|0x200000; // FAILS because of 0x80000
    dialog.Flags=0x200|0x800|0x4|0x200000;  // WORKS, but fails if there is no 0x200
    dialog.ShowOpen(); 
    //var ret = dialog.FileTitle;
    var ret = dialog.FileName;
    dialog = void 0;
    return ret;



Findings 1: dialog.Flags=0x200|0x80000|0x800|0x4|0x200000; // FAILS because of 0x80000
Findings 2: dialog.Flags=0x200|0x80000|0x800|0x4|0x200000; // WORKS if high contrast mode of windows is turned on, Search for high contrast using windows search at bottom of the screen, and 'Turn on high contrast'
Findings 3: dialog.Flags=0x200|0x800|0x4|0x200000;  // WORKS
Findings 4: dialog.Flags=0x800|0x4|0x200000;  // Fails if there is no 0x200



5

Symptoms
When you use Liquid UI to open a dialog window to select a file, you receive error related to MsComdlg or CommonDialog.
This article provides resolution to the issue.

Resolution:
Download the comdlg32 files(comdlg32.dll and comdlg32.ocx):
Comdlg32 files (click here)
OR
Paste the below link in your browser:
http://updates.guixt.com/downloads/comdlg32.zip

Steps to register the ocx file:
Step 01: After the download of comdlg32.zip
Step 02: Extract comdlg32.zip
Step 03: Place the files in "C:\Windows\SysWOW64" folder
Step 04: Open command prompt as admin and run the below commands:
            cd C:\Windows\SysWOW64
            regsvr32 comdlg32.ocx

6
Purpose:
To enable ABAP text-based editor to display the source code of a function module when using Liquid UI for iOS.

Please refer to the attachment for step-by-step instructions and screenshots!

7
Purpose:
For several functions, Liquid UI uses an RFC connection to the SAP System (Remote Function Call).
In order to logon to the system, the RFC needs a user name and password.

Liquid UI uses the logon values stored in Liquid UI profile.
As a default, the Liquid UI profile contains the user "SAPCPIC".
Since this user is often locked in productive systems, we suggest you create a special Liquid UI RFC user with appropriate rights.

For testing purposes, you can also fill in your own user name and password in Liquid UI profile.

Please refer to the attachment for step-by-step instructions on creating a role with required RFC authorizations!

8
Purpose:
For the searchhelp on Liquid UI fields to work, you need to install the ABAP program (ZGUIXTF4) in your SAP ERP system and also assign a transaction code ZXF4 to this program.

NOTE:
You can download the ABAP program ZGUIXTF4 from the below link:
http://updates.guixt.com/downloads/zguixtf4.zip


Please refer to the attachment for steps to install!

9
Purpose:
Structure to make function module calls and capture any errors if the call was not successful or capture any exceptions and display to the user.

NOTE::
To make the function module call, it is required to provide the rfc parameters in the configuration file i.e., guixt.sjs

Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs       // SAP Easy Access
----------------------------------------------------------------------------------------------------------------------------------------------
// User Interface
clearscreen();
inputfield([1,0],"User Date Format",[1,20],{"name":"z_user_dateformat","size":2,"readonly":true});
pushbutton([3,1],"Get Date Format","?",{"size":[2,20],"process":Z_FMCallGetData});

// Related functions
// Function trim, to remove blank spaces from variable values

String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}

// Function to return trimmed string
function getString(strInput) {
   return (typeof(strInput) == 'undefined' || strInput == 'undefined') ? "" : strInput.toString().trim();
}

// Function to check for blank string
// Specifically used to determine if input exist in the edit field

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

// Function to call BAPI and display results
function Z_FMCallGetData(){
   onscreen 'SAPLSMTR_NAVIGATION.0100'
      rfcresult = call('BAPI_USER_GET_DETAIL', {"IN.USERNAME":"&V[_user]","OUT.DEFAULTS":"Z_DEFAULTS"});
      if(rfcresult.rfc_rc != 0) {         
         // Cannot Call RFC for any reason
         // RFC call was *NOT* successful.
         // Display message to user, that rfc cannot be called  (you can use the content of rfcresult.rfc_key)

         message('E: Error! RFC Call Failed to Return Data');
         enter("?");
         goto SCRIPT_END;
      } else {
         if(!isBlank(rfcresult.exception)) {
            // RFC Call succeeded, but the ABAP code in the function module generated an exception
            // Display message to user, that rfc exception occured (you can use rfcresult.exception

            message('E: Error! '+rfcresult.exception);
            enter("?");
            goto SCRIPT_END;
         }
      }

      // RFC Call was successful
      if(!isBlank(Z_DEFAULTS)){
         set('V[z_user_dateformat]', Z_DEFAULTS.substring(27,28));   
      }
      message('S: RFC call was successful');
      enter('?');
      
   SCRIPT_END:;   
}


See attachments for code samples!

10
Purpose:
Using the 'view' command with relative positioning.

NOTE::
The usual 'offset' option does not work with view command, instead we use the 'getCoords' function. Make sure this function is loaded before the call.

Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLCOIH.E0101.sjs       // IW32 Initial screen
----------------------------------------------------------------------------------------------------------------------------------------------
// User Interface
box("F[Order]+[5,0]","F[Order]+[28,120]","Testing View");
pushbutton("F[Order]+[2,0]","View WITH relative positioning","?",{"size":[2,24],"process":viewTest,"using":{"PTYPE":"WITHREL"}});
pushbutton("F[Order]+[2,30]","View W/O relative positioning","?",{"size":[2,24],"process":viewTest,"using":{"PTYPE":"WITHOUTREL"}});

if(z_iw32_scr == "WITHREL"){
   //Below relative positioning does not work, instead use the one that is uncommented
   //view("F[Order]+[6,1]","F[Order]+[27,118]","http://www.guixt.com/");
   view(getCoords("F[Order]", [6,1]), getCoords("F[Order]", [27,118]), "http://www.guixt.com/");
} else if(z_iw32_scr == "WITHOUTREL"){   
   view([9,2],[30,118],"http://www.guixt.com/");
}


// Related Functions
function viewTest(param){
   onscreen "SAPLCOIH.0101"
      set("V[z_iw32_scr]",param.PTYPE);
      enter('?');
}

function getCoords(field, offset){
   return [<field>.pos[0] + offset[0], <field>.pos[1] + offset[1]];
}


See attachments for code samples!


11
Purpose:
Maintain a structure to easily implement new languages for existing scripts when working with language independent scripts.

NOTE::
 - Make sure the configuration file guixt.sjs has the below line:
      nolanguagekey = true;
 - Also, the screen files should not have any language key, example below:
      SAPMV45A.0101.sjs

Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SESSION.sjs       // Session file
----------------------------------------------------------------------------------------------------------------------------------------------
switch(_language) {
   case 'E':
      load('languageEN.sjs');
      logonLanguage = languageEN;
      break;
   case 'F':
      load('languageFR.sjs');
      logonLanguage = languageFR;
      break;
   case 'S':
      load('languageES.sjs');
      logonLanguage = languageES;
      break;   
   default:
      logonLanguage = languageEN;
      break;
}

----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPMV45A.4001.sjs       // VA02 transaction
----------------------------------------------------------------------------------------------------------------------------------------------
// User Interface
if(_page.exists(logonLanguage.pageexists.sales)){
   del(logonLanguage.controls.itemoverview);
   del(logonLanguage.controls.itemdetails);
   del(logonLanguage.controls.ordparty);
   del(logonLanguage.controls.procurement);
   del(logonLanguage.controls.shipping);
   del(logonLanguage.controls.reasonforrej);
   del(logonLanguage.controls.listofsalesorders);
   
   text(logonLanguage.controls.sales, logonLanguage.texts.salesdata);
   
   text([0,89], logonLanguage.texts.headertxt,{ "size":20});
   textbox([1,89], [4,125], {"name":"z_va02_hdrtxt", "textfont":"Arial", "textheight":"12", "textweight":"5"});
   
   columnheader("SAPMV45A_TCTRL_U_ERF_AUFTRAG,2", logonLanguage.texts.matlnum);         //Material column
   inputfield( [4,0], logonLanguage.inputfield.delstatus, [4,17], {"name":"z_va02_delstatus", "size":22});
   
   pushbutton([TOOLBAR], logonLanguage.pushbutton.exit, '/nVA02');
   pushbutton([TOOLBAR], logonLanguage.pushbutton.gotoeasyaccess, '/n', {"group":"A+"});
   
   message("W: "+logonLanguage.message.msgponum);
}

----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: languageEN.sjs       // English language file
----------------------------------------------------------------------------------------------------------------------------------------------
var languageEN = {
   "inputfield": {   
      "delstatus": "Delivery Status"
   },
   "pushbutton": {      
      "exit": "Exit",                                    
      "gotoeasyaccess": "Goto SAP Easy Access"
   },
   "texts": {      
      "salesdata": "Sales Data",
      "headertxt": "Header Text",
      "matlnum": "Material Number"
   },
   "message": {      
      "msgponum": "Enter PO number"
   },
   "controls": {
      "sales": "P[Sales]",                                 
      "itemoverview": "P[Item overview]",                                 
      "itemdetails": "P[Item detail]",                                    
      "ordparty": "P[Ordering party]",                                    
      "procurement": "P[Procurement]",                  
      "shipping": "P[Shipping]",
      "reasonforrej": "P[Reason for rejection]",
      "listofsalesorders": "P[list of sales orders]"
   },
   "pageexists": {
      "sales": "Sales"
   }
};

----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: languageES.sjs       // Spanish language file
----------------------------------------------------------------------------------------------------------------------------------------------
var languageES = {
   "inputfield": {   
      "delstatus": "Status entrega"
   },
   "pushbutton": {      
      "exit": "Salida",                                    
      "gotoeasyaccess": "Ir a SAP Easy Access"
   },
   "texts": {      
      "salesdata": "Los datos de ventas",
      "headertxt": "Texto de cabecera",
      "matlnum": "Número material"
   },
   "message": {      
      "msgponum": "Ingrese el número de pedido"
   },
   "controls": {
      "sales": "P[Ventas]",                                 
      "itemoverview": "P[Resumen de posiciones]",                                 
      "itemdetails": "P[Detalle posición]",                                    
      "ordparty": "P[Solicitante]",                                    
      "procurement": "P[Aprovisionamiento]",                  
      "shipping": "P[Expedición]",
      "reasonforrej": "P[Motivo de rechazo]",
      "listofsalesorders": "P[Lista de pedidos]"
   },
   "pageexists": {
      "sales": "Ventas"
   }
};

----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: languageFR.sjs       // French language file
----------------------------------------------------------------------------------------------------------------------------------------------
var languageFR = {
   "inputfield": {   
      "delstatus": "Statut livr."
   },
   "pushbutton": {      
      "exit": "Sortie",                                    
      "gotoeasyaccess": "Aller à SAP Easy Access"
   },
   "texts": {      
      "salesdata": "Données de vente",
      "headertxt": "En-tête",
      "matlnum": "Numéro d'article"
   },
   "message": {      
      "msgponum": "Entrez le numéro de bon de commande"
   },
   "controls": {
      "sales": "P[Vente]",                                 
      "itemoverview": "P[Synthèse des postes]",                                 
      "itemdetails": "P[Détail du poste]",                                    
      "ordparty": "P[Acheteur]",                                    
      "procurement": "P[Approvisionnement]",                  
      "shipping": "P[Expédition]",
      "reasonforrej": "P[Motif d'annulation]",
      "listofsalesorders": "P[Liste des commandes client]"
   },
   "pageexists": {
      "sales": "Vente"
   }
};


See attachments for code samples!
[/list]

12
Purpose:
Using copytext command to copy data from/to files.
Attached sample scripts uses external data to copy from file to textbox and vice-versa.

NOTE::
Available from LUI Desktop Version 1.2.333.0 and LUI Server Version 3.5.571.0

SYNTAX::
copytext({"fromfile":filename,"totext":textboxname});
copytext({'fromstring':stringname,'tofile':filename});


Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs       // Easy Access
----------------------------------------------------------------------------------------------------------------------------------------------
// User Interface
clearscreen();
pushbutton([1,2], "Copy from File to Text", "?", {"size":[2,20], "process":procCopyTextFromFile});
pushbutton([1,25], "Clear Textbox", "?", {"size":[2,20],"process":procClearTextbox});
textbox([4,2],[15,80],{"name":"mytext1"});
pushbutton([17,2], "Copy from Text to File", "?", {"size":[2,20], "process":procCopyTextFromTextToFile});


// Function to convert text(single or multi-line) to array
function convertTextToArray(inpText) {
   var outArr = [];
   outArr = inpText.split('\n');
   return outArr;
}

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

// Function to copy data from file to Liquid UI textbox
function procCopyTextFromFile(){
   set("V[NotifData]","Notifications.txt");
   
   onscreen "SAPLSMTR_NAVIGATION.0100"
      copytext({"fromfile":"&V[NotifData]","totext":"mytext1"});
      enter('?');
}

// Function to copy data from textbox to file
function procCopyTextFromTextToFile(){
   set("V[mystr]","Testing copytext fromstring tofile options");
   set("V[myfile1]","C:\\LiquidUI\\Scripts\\TestFile.txt");
   //Below line opens and clears the file or creates a new file if it does not exist
   openfile("&V[myfile1]",{"output":true});
   closefile("&V[myfile1]");
      
   onscreen "SAPLSMTR_NAVIGATION.0100"
      // Below line to copy string to file
      // copytext({'fromstring':'mystr','tofile':'&V[myfile1]'});

      
      // Below lines to convert user entered text in
      // textbox to array and then use copytext to copy to file

      arrInp = [];
      arrInp = convertTextToArray(mytext1);
      for(var i=0;i<arrInp.length;i++) {
         var textString = arrInp;
         textString = textString.replace('\r','');
         copytext({'fromstring':'textString','tofile':'&V[myfile1]','appendline':true});
      }   
      enter("?");
}


See attachments for code samples!

13
Purpose:
'#include' pre-processor is used to make the file contents load inline.
This is used for code readability if smaller functions have to be grouped into separate files and called inline.

SYNTAX::
// The 'filename.sjs' just has the script without any function header or closing brace
// No need to load the include files, however they need to be placed in the scripts root directory (Cannot be in subfolders)
#include 'filename.sjs'[Make sure there are no spaces after the closing quote]

NOTE::
 - Available from LUI Desktop Version 1.2.331 and LUI Server Version 3.5.575
 - Make sure there are no blank spaces after the include declaration or else include will not get executed

Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs       // Easy Access
----------------------------------------------------------------------------------------------------------------------------------------------
load("IW32_functions.sjs");

// User Interface
clearscreen();
inputfield( [1,1], "Order", [1,18],{ "name":"z_iw32_ordernum", "size":18, "required":true});
pushbutton([5,40],"Clear fields","?",{"process":clearData});
pushbutton([2,1],"Get Order Info [Syntax 1]","?",{"process":getOrderInfo_1});
comment([2,30],"This function does error handling, calls include function and returns to main function [Check Script Syntax]");
pushbutton([3,1],"Get Order Info [Syntax 2]","?",{"process":getOrderInfo_2});
comment([3,30],"The include function is being called entirely from the main function [Check Script Syntax]");
inputfield( [5,1], "Notification", [5,18],{ "name":"z_iw32_notifnum", "size":18});
inputfield( [6,1], "Func. Loc.", [6,18],{ "name":"z_iw32_funcloc", "size":18});
text([6,38], "&V[z_iw32_funclocdesc]");
inputfield( [7,1], "Sales Org.", [7,18],{ "name":"z_iw32_salesorg", "size":4});
inputfield( [8,1], "Distr. Channel", [8,18],{ "name":"z_iw32_distchannel", "size":2});
inputfield( [9,1], "Division", [9,18],{ "name":"z_iw32_division", "size":2});

----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: IW32_functions.sjs       // Functions file
----------------------------------------------------------------------------------------------------------------------------------------------
// Function prototype to trim blank characters from a string
String.prototype.trim = function () {
   return this.replace(/^\s+|\s+$/g, "");
}

// Function to return trimmed string
function getString(strInput) {
   return (typeof(strInput) == 'undefined' || strInput == 'undefined') ? "" : strInput.toString().trim();
}

// Function to check for blank string
// Specifically used to determine if input exist in the edit field

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

// Clear Data
function clearData(){
   set("V[z*]","");
}

// Get Order Information
function getOrderInfo_1(){
   if(isBlank(z_iw32_ordernum)){
      return("E: Enter Order number");
   }
   
   onscreen 'SAPLSMTR_NAVIGATION.0100'
      enter("/nIW32");
      
   // Include Pre-processor makes the function inline   
   #include "INC_GET_ORDER_DATA_1.sjs"

        onscreen 'SAPLCOIH.3000'
      set("V[z_iw32_salesorg]","&F[Sales Org.]");
      set("V[z_iw32_distchannel]","&F[Distr. Channel]");
      set("V[z_iw32_division]","&F[Division]");
      enter("/n");
}

// Get Order Information
function getOrderInfo_2(){
#include "INC_GET_ORDER_DATA_2.sjs"
}

----------------------------------------------------------------------------------------------------------------------------------------------
// This function does error handling, calls include function and returns to main function
Script File Name: INC_GET_ORDER_DATA_1.sjs       // Include file with Syntax 1
----------------------------------------------------------------------------------------------------------------------------------------------
onscreen 'SAPLCOIH.0101'
   set('F[Order]','&V[z_iw32_ordernum]');   
   enter();
   onerror
      message(_message);
      enter("/n");
      goto SCRIPT_END;
      
onscreen 'SAPLCOIH.0101'
   if(_message.substring(0,2) == 'E:'){
      message(_message);
      enter("/n");
      goto SCRIPT_END;
   } else {
      enter("?");
   }         
      
onscreen 'SAPLCOIH.3000'
   set("V[z_iw32_notifnum]","&F[Notifctn]");
   set("V[z_iw32_funcloc]","&F[CAUFVD-TPLNR]");   //Func.Loc.
   set("V[z_iw32_funclocdesc]","&F[RIOT-PLTXT]");   //Func.Loc. Description
   enter("=ILOA");
   
SCRIPT_END:;   

----------------------------------------------------------------------------------------------------------------------------------------------
// The include function is being called entirely from the main function
Script File Name: INC_GET_ORDER_DATA_2.sjs       // Include file with Syntax 2
----------------------------------------------------------------------------------------------------------------------------------------------
if(isBlank(z_iw32_ordernum)){
   return("E: Enter Order number");
}

onscreen 'SAPLSMTR_NAVIGATION.0100'
   enter("/nIW32");
   
onscreen 'SAPLCOIH.0101'
   set('F[Order]','&V[z_iw32_ordernum]');   
   enter();
   onerror
      message(_message);
      enter("/n");
      goto SCRIPT_END;
      
onscreen 'SAPLCOIH.0101'
   if(_message.substring(0,2) == 'E:'){
      message(_message);
      enter("/n");
      goto SCRIPT_END;
   } else {
      enter("?");
   }         
      
onscreen 'SAPLCOIH.3000'
   set("V[z_iw32_notifnum]","&F[Notifctn]");
   set("V[z_iw32_funcloc]","&F[CAUFVD-TPLNR]");   //Func.Loc.
   set("V[z_iw32_funclocdesc]","&F[RIOT-PLTXT]");   //Func.Loc. Description
   enter("=ILOA");

onscreen 'SAPLCOIH.3000'
   set("V[z_iw32_salesorg]","&F[Sales Org.]");
   set("V[z_iw32_distchannel]","&F[Distr. Channel]");
   set("V[z_iw32_division]","&F[Division]");
   enter("/n");
   
SCRIPT_END:;   


See attachments for code samples!

14
Purpose:
Display custom popups('Yes/No' or 'OK') to user and act based on user selections.
'_eventid' is used to capture the user selection.
'reenter' command is used to called the function to display popup.

NOTE::
Available from LUI Desktop Version 1.2.332 and LUI Server Version 3.5.571

Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs       // Easy Access
----------------------------------------------------------------------------------------------------------------------------------------------
// Screen Script - UI
clearscreen();
inputfield([2,2],"Sales Order",[2,20],{"name":"z_va02_order","size":18});
pushbutton([4,2], "@01@Change Order", "?", {"size":[2,70], "process":changeOrder});

// Function prototype to trim blank characters from a string
String.prototype.trim = function () {
   return this.replace(/^\s+|\s+$/g, "");
}

// Function to return trimmed string
function getString(strInput) {
   return (typeof(strInput) == 'undefined' || strInput == 'undefined') ? "" : strInput.toString().trim();
}

// Function to check for blank string
// Specifically used to determine if input exist in the edit field

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

// Function to delete toolbar buttons on popup
function delButtonsRSM0400() {
   del('P[Continue]');
   del('P[Generate]');
   del('P[End Session]');
   del('P[Cancel]');
   if(<'P[Delete Session]'>.isValid)      del("P[Delete Session]");
}

// Function to display the message on '/o' popup with necessary formatting
function procLUIMessageBox(param){
   var intHeight = 5 + 4 + param.l_message.length;
   var intPaintRow = 1;
   var intPaintCol = 3;
   enter("/o");
               
   onscreen 'RSM04000_ALV_NEW.2000'
      goto RESIZE_REPAINT;
      
   onscreen 'RSM04000_ALV.2000'
      RESIZE_REPAINT:;
      clearscreen();
      delButtonsRSM0400();
   
      title(param.l_title);
      
      if(isBlank(param.l_viewtext))   var viewTextContent='';
      else var viewTextContent = param.l_viewtext;
      if(isBlank(param.l_viewhtml))   var viewHTMLContent='';
      else var viewHTMLContent = param.l_viewhtml;
      if(isBlank(param.l_viewheight))   var viewHeight=0;
      else var viewHeight = param.l_viewheight;
      
      //Logic to render message
      for(var idxI=0; idxI<param.l_message.length; idxI++){
         var intWidth = (intWidth>param.l_message[idxI].length)?intWidth:param.l_message[idxI].length;
         if(param.l_message[idxI].indexOf("\t")==0)      //When message needs to be indented
            text([intPaintRow+idxI,intPaintCol+4], param.l_message[idxI]);
         else
            text([intPaintRow+idxI,intPaintCol], param.l_message[idxI]);
      }
      intWidth = intWidth+20;
      if(intWidth<51) intWidth=52;
      
      intPaintRow = 2 + param.l_message.length;
      if(!isBlank(fileURL)) {
         windowsize([5,5,90,intHeight+viewHeight]);
         view([intPaintRow-1,5],[intPaintRow+viewHeight,60],fileURL,{'name':fileURLName});
         intPaintRow = intPaintRow+1;
      } else if(viewTextContent.length>0) {
         textbox([intPaintRow,1],[intPaintRow+14,148],{'name':'viewTextContent','readonly':true});
         intPaintRow = intPaintRow+15;
         windowsize([5,5,150,intHeight+15]);
      } else if(viewHTMLContent.length>0) {
         var viewingFile = generatePrintableView(viewHTMLContent);
         var viewHNDL = getTodayDateTimeStr('HMS');
         view([intPaintRow,1],[intPaintRow+14,146],viewingFile,{'name':viewHNDL});
         intPaintRow = intPaintRow+15;
         windowsize([5,5,150,intHeight+15]);
         //removefile(viewingFile);
      } else {
         windowsize([5,5,intWidth,intHeight+1]);
      }
      fileURL = '';
      
      //Draw buttons according to type
      switch(param.l_type) {
         case "MB_YESNO":
            pushbutton([intPaintRow,intPaintCol], "@01@Yes", "/12",{"eventid":"YES", "size":[2,20]});
            pushbutton([intPaintRow,25], "@02@No", "/12",{"eventid":"NO", "size":[2,20]});
            break;
            
         case "MB_OKCANCEL":
            pushbutton([intPaintRow,intPaintCol], "@01@OK", "/12",{"eventid":"OK", "size":[2,20]});
            pushbutton([intPaintRow,25], "@02@Cancel", "/12",{"eventid":"CANCEL", "size":[2,20]});
            break;
            
         case "MB_OK":
            pushbutton([intPaintRow+viewHeight,intPaintCol], "@01@OK", "/12",{"eventid":"OK", "size":[2,20]});
            break;
            
         default:
            pushbutton([intPaintRow,intPaintCol], "OK", "/12",{"eventid":"OK", "size":[2,20]});
            break;
      }
}

// Function to show how to call either 'MB_YESNO' or 'MB_OK' popup
function changeOrder(){
   if(isBlank(z_va02_order)){
      message("E: Enter Order number");
      enter('?');
      goto SCRIPT_END;
   }

   onscreen "SAPLSMTR_NAVIGATION.0100"
      clearscreen();
      tmp_msg = "Would you like to proceed \n to VA02 Change Order?";
      strType = "MB_YESNO";
      strTitle = "Information";
      aryMessage = tmp_msg.split("\n");
      tmp_msg = "";      
      reenter({"process":procLUIMessageBox, "using":{"l_type":strType, "l_title":strTitle, "l_message":aryMessage}});
   
   onscreen "SAPLSMTR_NAVIGATION.0100"
      if(_eventid == 'YES'){
         enter("/nVA02",{"process":navigateVA02});
      } else {
         clearscreen();
         tmp_msg = "Cancelled Process";
         strType = "MB_OK";
         strTitle = "Information";
         aryMessage = tmp_msg.split("\n");
         tmp_msg = "";      
         reenter({"process":procLUIMessageBox, "using":{"l_type":strType, "l_title":strTitle, "l_message":aryMessage}});
      }         
         
   onscreen "SAPLSMTR_NAVIGATION.0100"
      enter('?');
   
   SCRIPT_END:;   
}

// Function lands on VA02 and sets the Order number
function navigateVA02(){
   onscreen "SAPLSMTR_NAVIGATION.0100"
      enter("/nVA02");
      
   onscreen "SAPMV45A.0102"
      set("F[Order]","&V[z_va02_order]");
      enter('?');
}


See attachments for code samples!

15
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
}


Pages: [1] 2 3 ... 7