Liquid UI: Logs can be generated to debug user issues
Step 1: User Interface [ Navigate to MM01 ]
Enter the information and click on create material button to generate log file
Variable ENABLE_FILE_LOGGING is used to turn on the logging option
set('V[ENABLE_FILE_LOGGING]',true);
pushbutton([22,54], "@2L@Create Material", { "process":mm01_create_material});
Step 2: Successful log creation in the specified path. Initiatelogfile function is used to create a file and logToFile function is used to write to a log file
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;
}
}
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});
}
}
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});
}
See attachments for code samples