Liquid UI - Documentation - 21.02 Logging Capability

21.02 Logging Capability


Prerequisites


Purpose

To troubleshoot user issues, logs can be generated automatically. In the same way that it generates an error when the incorrect file path is mentioned, logs can be generated in the designated folder to display the status of the content, making it simpler for the user to troubleshoot problems. To demonstrate Log file generation, we have taken the MM01 screen as an instance and we will walk you through the following steps:

  1. Log into SAP and navigate to the MM01 screen
  2. Delete the elements that are not required for this scenario
  3. Add text boxes that displays the text
  4. Add radio buttons that assigns value to the required field on selection
  5. Add input fields where the user can enter the details as per requirement
  6. Add functions that generates the logs automatically when created, and it generates an error message when the incorrect file path is mentioned


User Interface

//Create this file inside your script folder for customizing the Create Material (Initial Screen): SAPLMGMM.E0060.sjs
//Now, let's add the Liquid UI script to this file and save it.

Customization

  1. Log into SAP and navigate to the MM01 transaction.
     
     
  2. Delete change number, Copy from..., and Material, as they were not required for this scenario, and change the positions of the other buttons on the screen, as shown in the image below.
     
    //Deletes change number and positions of the buttons on the screen.
    set('V[ENABLE_FILE_LOGGING]',true);
    del("F[Change Number]");
    pos("F[Industry sector]", [3,51]);
    pos("F[Material Type]", [4,51]);
    del("G[Copy from...]");
    del("F[Material]");
     
     
  3. Add four text boxes with the labels Basic Data, Organizational Data, MRP Data, and " ".
     
    //Adds four text boxes with labels as Basic Data, Organizational Data, MRP Data and “” to display text.
    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], "");
     
     
  4. Add three radio buttons with labels Plant 1000, Plant 2000, and Plant 3000 which assigns value to the required field on selection.
     
    //Adds radio buttons which assign value to the Organizational Data field on selection
    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"});
    
     
     
  5. Add five input fields with the labels Stor.Loc, Description, Mat Grp, BUOM, and Mrp Type, and a checkbox labeled BulkMaterial where the user can enter the details as per their requirement.
     
    //Adds five input fields where you can enter the details as per your requirment.
    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});
     
     
  6. Now, add the following Liquid UI script to this file and save it.
     
    //Function that generates the logs automatically when created, and it generates an error message when the incorrect file path is mentioned.
    function mm01_create_material(){
    set("V[z_mm01_error]",""); 
    var logFileName;
    logFileName = initiateLogFile('C:\\TEMP\\Liquid UI Cache\\','CreateMaterial');
    // Constructed File Name would be C:\\TEMP\\Liquid UI Cache\\<UserName>_<DateTimeStamp>_CreateMaterial.txt // Example: C:\\TEMP\\Liquid UI 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; 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});
    }
     

SAP Process

  1. Refresh the SAP screen, fill in the required fields, and click on the Create Material pushbutton to create a material. You can see a notification after successful creation along with the material number.
     
     
  2. Then, the Log file gets generated in the specified folder mentioned in the script.
     
     
  3. If the path specified is incorrect, displays an error, as shown below.
     

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