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 ... 5 6 [7]
91
Purpose:
The same SAP screen can be used to display multiple layouts or different launch pads by passing different parameters.

Liquid UI Code:

// User Interface
// SAPLSMTR_NAVIGATION.E0100.sjs

del('X[IMAGE_CONTAINER]');      // Delete AxtiveX Container on SAP Easy Access screen

function isBlank(jvar){         // Function is called to validate if the variable holds blank or null value
   return(jvar == "" || jvar == null || jvar == void 0);
}

function next_screen(param) {   // Function to change layout based on parameter passed   
   set('V[z_view_layout]',param.l_scrn);
}

if(isBlank(z_view_layout)){
   box([2,9], [13,56], "Main Menu");
   pushbutton([4,20], "Material Management  ", { "process":next_screen, "size":[2,20], "using":{l_scrn:"MM"}});
   pushbutton([7,20], "Sales & Distribution ", { "process":next_screen, "size":[2,20], "using":{l_scrn:"SD"}});
   pushbutton([10,20], "Plant Maintenance    ", { "process":next_screen, "size":[2,20], "using":{l_scrn:"PM"}});
}

if(z_view_layout == 'MM'){
   box([2,9], [13,56], "Material Management");
   pushbutton([4,20], "Create Material      ", "/nmm01", { "size":[2,20]});
   pushbutton([7,20], "Change Material      ", "/nmm02", { "size":[2,20]});
   pushbutton([10,20], "Display Material     ", "/nmm03", { "size":[2,20]});
   pushbutton('[toolbar]', "@9S@ Back", { "process":next_screen,"size":[2,20], "using":{l_scrn:""}});
}

if(z_view_layout == 'SD'){
   box([2,9], [13,56], "Sales & Distribution");
   pushbutton([4,20], "Create Sales Order   ", "/nva01", { "size":[2,20]});
   pushbutton([7,20], "Change Sales Order   ", "/nva02", { "size":[2,20]});
   pushbutton([10,20], "Display Sales Order  ", "/nva03", { "size":[2,20]});
   pushbutton('[toolbar]', "@9S@ Back", { "process":next_screen,"size":[2,20], "using":{l_scrn:""}});
}

if(z_view_layout == 'PM'){
   box([2,9], [13,56], "Plant Maintenance ");
   pushbutton([4,20], "Create Notification  ", "/niw21", { "size":[2,20]});
   pushbutton([7,20], "Change Notification", "/niw22", { "size":[2,20]});
   pushbutton([10,20], "Display Notification ", "/niw23", { "size":[2,20]});
   pushbutton('[toolbar]', "@9S@ Back", { "process":next_screen,"size":[2,20], "using":{l_scrn:""}});
}


See attachments for code samples!

92
Purpose:
To strip numbers from a Standard SAP message and use it as required. 

Liquid UI Code:

function testFunction(){   
   myarr = [];
   mymsg = 'The order 123021213 is saved and 542321 updated';   // Sample message
   var res = mymsg.match(/[-+]?[0-9]*\.?[0-9]+/g);
   myarr = res.toString().split(',');   // Store the numbers in an array
   
   for(var idx=0;idx<myarr.length;idx++){
      set('V[z_num&V[idx]]',myarr[idx]);
   }   
}

del('X[IMAGE_CONTAINER]');         // Delete ActiveX control on SAP Easy Access
inputfield([1,1],"Order Number", [1,15], {"name":"z_num0", "size":"15", "readonly":true});
inputfield([2,1],"Deliv. Number", [2,15], {"name":"z_num1", "size":"15", "readonly":true});
pushbutton([TOOLBAR],'Execute','?',{'process':testFunction});   // Function Call


See attachments for code samples!

93
Purpose:
To use appendfile command and increment counter in a file. This could also be used as an example to use appendfile to add to a file.

Liquid UI Code:

function testFunction() {
   strFileName = 'counter.txt';
   appendToCounterFile(strFileName);
}

// Toolbar pushbutton on User interface screen
pushbutton([TOOLBAR],'Execute','?',{'process':testFunction});

// Function is called to remove blank spaces
String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}

// Function is called to validate if the variable holds blank or null value
function isBlank(jvar){
   if(typeof jvar == undefined || jvar == null || jvar == "" || jvar == void 0)
      return true;
   else
      return jvar.toString().trim() == '';
}

// Function which takes as parameter the file and appends to it
function appendToCounterFile(fileName) {
   var lastCounter = 0;
   var z_counter = '';
   var strBlank = '';
   openfile(fileName, {"delimiter":","});
   NEXT_LINE_READ:;
   readfile(fileName, {"z_counter":true});
   if(isBlank(z_counter)) {
      goto END_OF_FILE;
   }
   lastCounter = parseInt(z_counter);
   var z_counter = '';
   goto NEXT_LINE_READ;

   END_OF_FILE:;
   closefile(fileName);
   
   openfile(fileName, {"append":true, "delimiter":","});
   lastCounter++;
   appendfile(fileName, {"lastCounter":true});
   closefile(fileName);
}


See attachments for code samples!

94
WS aka Web Scripts (Attended RPA for SAP) / Domains Localvaluehelp
« on: February 12, 2016, 05:29:34 PM »
Purpose:
The localvaluehelp command enables users to access help for possible input sets for SAP inputfields when you perform a right-click on the field in question. This command will function both on GuiXT and native SAP fields. The localvalue help command can be used only on inputfields.

Liquid UI Code:

Step 1:
// In GuiXT WS configuration file, 'guixt.sjs' make sure the domains path and the option below are set-
historyonrightbutton    = true;
domains = "C:\\guixt\\scripts";

Step 2:
// In the path specified in the configuration file place the file with the list of options-
// dom.E.CURRENCY.txt
ADP //Andoran peseta
AED //United Arab Emirates Dirham
AFA //Afghani
ALL //Albanian Lek
AMD //Armenian Dram
ANG //West Indian Guilder
AOK //Angolan Kwanza
BBD //Barbados Dollar

// dom.E.SHIPVIA.txt
A1 //Truck - Van
A2 //Truck - Flat Bed
A3 //Truck - Rail Deck
A4 //Truck - B-Train
A5 //Truck - Maxi
A6 //Truck - LTL
A7 //Cust PickUp Van
A8 //Cust PickUp Flat B
R1 //Rail - 50' Box car d
R3 //Rail - 52' High Cube
R4 //Rail - 60' High Cube
R5 //Rail - 60' Flat car
R6 //Rail - 66' Flat car

Step 3:
// User Interface
// SAPLSMTR_NAVIGATION.E0100.sjs

del("X[IMAGE_CONTAINER]");   // Delete ActiveX Container on SAP Easy Access
inputfield([1,1], "Currency", [1,15], {"name":"z_va0x_currency", "size":3});
localvaluehelp("F[Currency]", {"domain":"CURRENCY"});

inputfield([2,1], "Ship Via", [2,15],{ "name":"z_va0x_shipvia", "size":2});            
localvaluehelp("F[Ship Via]", {"domain":"SHIPVIA"});


See attachments for code samples!

95
Purpose:
Utilizing the below scripts where we call the Function Module 'BAPI_USER_GET_DETAIL', we can determine user authorizations based on their roles.

Liquid UI Code:
/*
Function         : getAuthorizations
Parameters     :
Purpose          : Calls function to read user SAP role and profile
*/
function getAuthorizations(){
   call('BAPI_USER_GET_DETAIL', {"in.USERNAME":"&V[_user]","table.ACTIVITYGROUPS":"Z_ROLES",'table.PARAMETER':'arParam'});
}


/*
Function         : roleExists
Parameters     : roleName
Purpose          : Checks to see if current user has the roleName match
*/
function roleExists(roleName){
   for (i = 0; i < Z_ROLES.length; i++)   {
      var z_userrole = Z_ROLES.toString().substring(0,25).trim();
      if(z_userrole == roleName) {
         return true;
      }
   }
   return false;
}


/*
Function         : tableLayout
Parameters     : tableLayoutRegion
Purpose          : Checks to see if current user has the tableLayoutRegion match
*/
function tableLayout(tableLayoutRegion) {
   for (i = 0; i < arParam.length; i++)   {
      var z_layout = arParam.toString().substring(0,16).trim();
      if(z_layout == tableLayoutRegion) {
         layout_check_value=arParam.substring(17,30);
         layout_check_value=layout_check_value.trim();
         return layout_check_value;
      }
   }
   return 'DEFAULT';
}

/*
Function         : CheckAuthorizations
Parameters     :
Purpose          : Capture authorization details into variables which can be used as necessary
*/
function CheckAuthorizations(){    // Test for role
       getAuthorizations();
       var checkAccess=roleExists("Z:SDSAREPINSIDE_ALLNONCRU");
       var tableLayoutStyle=tableLayout("ZGUIXT_VA01_VIEW");
// Below println's to print the values of the variables on the console output
       println('\n------checkAccess:'+checkAccess);         
       println('\n------tableLayoutStyle:'+tableLayoutStyle);   
}


//*******************************************************************************************************************
//Purpose: Main Function to test and print the output on the console
//*******************************************************************************************************************
function CheckAuthorizations(){    // Test for role
       getAuthorizations();
       checkAccess = roleExists("SAP_BC_DWB_ABAPDEVELOPER");
       tableLayoutStyle = tableLayout("WLC");
   // Below println's to print the values of the variables on the console output
       println('\n------checkAccess:'+checkAccess);         
       println('\n------tableLayoutStyle:'+tableLayoutStyle);   

}


pushbutton([TOOLBAR], "@F8@Get Roles", {"process":CheckAuthorizations});


See attachments for code samples!

Pages: 1 ... 5 6 [7]