Liquid UI - WS Reference Library

Logging Capability


Purpose

Liquid UI: Logs can be generated to debug user issues.


User Interface

1. Navigate to the MM01 transaction.


2. Enter the information and click on Create Material button to create a material.

3. Log file gets generated in the specified folder mentioned in the script.

Log file Creation after clicking create material

Successful creation


Error while creating material



Liquid UI Script

//SAPLMGMM.E0060.sjs

// Author: Synactive, Inc. [1065 E. Hillsdale Blvd, Foster City, CA, 94404, USA]
// Email: support@guixt.com; sales@guixt.com;
// Contact: 650.341.3310
// Version: 1.0.0.0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

// Purpose: Create a File to Write Logs
function initiateLogFile(strDir,strProcess) {
    if(ENABLE_FILE_LOGGING) {        // Global variable for enabling logging, set to TRUE based on URL parameter 'mode'
        var d = new Date();
        mm = d.getMonth()+1;
        if(mm<10) mm='0'+mm;    // Convert to 2 characters month for months 1-9
        dd = d.getDate();
        if(dd<10) dd='0'+dd;    // Convert to 2 characters date for dates 1-9
        
        dt = mm.toString() + dd.toString() + d.getFullYear().toString();    // Date Stamp
        thr = d.getHours();
        if(thr<10) thr='0'+thr;    // Convert to 2 characters hours for hours 1-9
        tmin = d.getMinutes();    
        if(tmin<10) tmin='0'+tmin;    // Convert to 2 characters minutes for minutes 1-9
        tsec = d.getSeconds();
        if(tsec<10) tsec='0'+tsec;    // Convert to 2 characters seconds for seconds 1-9
        
        tm = thr.toString() + tmin.toString() + tsec.toString(); // Time Stamp
        ts = dt + '_' + tm;    // Date & Time Stamp
        var z_filename = strDir + _user.toString().trim()+"_"+ts+"_"+ strProcess + ".txt";
        openfile(z_filename, {"output": true});    
        return z_filename;
    }
}

// Purpose: Write to a Log File
function logToFile(strFileName, strIdentifier, strValue) {
    if(ENABLE_FILE_LOGGING) {
        var z_system_datetime = new Date();
        logStr = z_system_datetime + ':' + strIdentifier + ':' + strValue;
        appendfile(strFileName, {logStr:true});            
    }
}

set('V[ENABLE_FILE_LOGGING]',true);
pushbutton([22,54], "@2L@Create Material", { "process":mm01_create_material});
del("F[Change Number]");
pos("F[Industry sector]", [3,51]);
pos("F[Material Type]", [4,51]);
del("G[Copy from...]");
del("F[Material]");

box([11,46], [15,90], "Basic Data");
box([6,46], [10,90], "Organizational Data");
box([16,46], [20,90], "MRP Data");
box([2,44], [23,92], "");
radiobutton([7,47], "Plant 1000", { "name":"z_mm01_plant", "value":"1000"});
radiobutton([7,63], "Plant 2000", { "name":"z_mm01_plant", "value":"2000"});
radiobutton([7,78], "Plant 3000", { "name":"z_mm01_plant", "value":"3000"});
inputfield( [8,48], "Stor.Loc", [8,58],{ "name":"z_mm01_storloc", "size":4, "required":true});
inputfield( [12,48], "Description", [12,60],{ "name":"z_mm01_desc", "size":25});
inputfield( [14,48], "Mat Grp", [14,60],{ "name":"z_mm01_matgrp", "size":3});
inputfield( [13,48], "BUOM", [13,60],{ "name":"z_mm01_buom", "size":2});
checkbox([19,49], "BulkMaterial", { "name":"z_mm01_blkmat"});
inputfield( [17,48], "Mrp Type", [17,60],{ "name":"z_mm01_mrptype", "size":3});



function mm01_create_material(){
    set("V[z_mm01_error]","");
    var logFileName;
    logFileName = initiateLogFile('C:\\TEMP\\GuiXT Cache\\','CreateMaterial');
    // Constructed File Name would be C:\\TEMP\\GuiXT Cache\\<UserName>_<DateTimeStamp>_CreateMaterial.txt
    // Example: C:\\TEMP\\GuiXT Cache\\test1_10102014_121234_CreateMaterial.txt
    
// Create Material (Initial Screen)
onscreen 'SAPLMGMM.0060'
logToFile(logFileName, 'Navigating to', 'Selecting Views');
enter('/5');

// Create Material (Initial Screen)
onscreen 'SAPLMGMM.0070'
logToFile(logFileName, 'Inside Screen', 'Selecting Views');
set('Cell[Table,0,1]', 'X');
set('Cell[Table,0,4]', 'X');
set('Cell[Table,0,6]', 'X');
set('Cell[Table,0,12]', 'X');
set('Cell[Table,0,13]', 'X');
set('Cell[Table,0,14]', 'X');
enter('/6');

// Create Material (Initial Screen)
onscreen 'SAPLMGMM.0080'
logToFile(logFileName, 'Inside Screen', 'Organizational levels');
set('F[Plant]', '&V[z_mm01_plant]');
set('F[Stor. Location]', '&V[z_mm01_storloc]');
set('F[Sales Org.]', '1000');
set('F[Distr. Channel]', '10');
enter();

// Create Material 68999 (Finished product)
onscreen 'SAPLMGMM.4004'
logToFile(logFileName, 'Inside Tab',  'Basic Data 1');
set('V[z_mm01_material]', "&F[Material]")
set('F[MAKT-MAKTX]', '&V[z_mm01_desc]');
set('F[Base Unit of Measure]', '&V[z_mm01_buom]');
set('F[Material Group]', '&V[z_mm01_matgrp]');
enter('=SP04');
onmessage
        if(_message.substring(0,2) == "E:"){
            set("V[z_mm01_error]",_message);
            message(z_mm01_error);
            logToFile(logFileName, 'Basic Data 1', 'Error:' + _message);
            enter("/nmm01")
            goto end_function;
        } else {
            logToFile(logFileName,'Basic Data 1', 'Warning:' + _message);        
            enter();
        }

// Create Material 68999 (Finished product)
onscreen 'SAPLMGMM.4000'
logToFile(logFileName, 'Inside Tab', 'Sales Org. 1');
set('cell[TABLE,5,1]', '1');
set('cell[TABLE,5,2]', '1');
enter('=SP06');
// Create Material 68999 (Finished product)
onscreen 'SAPLMGMM.4000'
logToFile(logFileName, 'Inside Tab', 'Sales General/Plant');
set('F[Trans. Grp]', '0001');
set('F[LoadingGrp]', '0001');
enter('=SP12');
onmessage
        if(_message.substring(0,2) == "E:"){
            set("V[z_mm01_error]",_message);
            message(z_mm01_error);
            logToFile(logFileName, 'Sales General/Plant', 'Error:' + _message);
            enter("/nmm01")
            goto end_function;
        } else {
            logToFile(logFileName,'Sales General/Plant', 'Warning:' + _message);        
            enter();
        }

// Create Material 68999 (Finished product)
onscreen 'SAPLMGMM.4000'
logToFile(logFileName, 'Inside Tab', 'MRP Type 1');
set('F[MRP Type]', '&V[z_mm01_mrptype]');
enter('=SP13');

// Create Material 68999 (Finished product)
onscreen 'SAPLMGMM.4000'
logToFile(logFileName, 'Inside Tab', 'MRP Type 2');
if (z_mm01_blkmat=='X')
set('C[Bulk Material]', 'X');
set('F[SchedMargin key]', '000');
enter('=SP14');

// Create Material 68999 (Finished product)
onscreen 'SAPLMGMM.4000'
logToFile(logFileName, 'Inside Tab', 'MRP Type 3');
set('F[Availability check]', '01');
z_mm01_material = z_mm01_material.trim();
logToFile(logFileName, 'Material',z_mm01_material+'Successfully Created');
closefile(logFileName, {"output": true});
set ("V[z_mm01*]", '');
enter('/11');

end_function:;
closefile(logFileName, {"output": true});
}