Skip to Content

Being new to MII has been a challenge.   There are a lot of weblogs, posts, and information on SDN, but I could not find some of the basic information that I learned through trial and error.  This weblog is an attempt at giving some basic tips and tricks for the new developer in MII.  These tips could save you time in maintenance further down the road.  I also recommend reading the Best Practices guide found here.   All of the MII classes offered by SAP are helpful to attend.

 

Queries

Basic queries can be a pain point.   If you are not careful, you could end up with hundreds of queries.   Here is a query that might have to be written several times against the same table.   The example shows a query using sort and filter in the the query, and the Javascript to reference the query.  With this example, many queries would need to be written if you want to access the table with a different filter.

image

JavaScript

function Plan_Guide_Grid_Created()
{

document.Get_Plan.getQueryObject().setParam(1,GuideId)
}

Here’s an example of how the query and Java script should have been written.  This query allows for flexibility when called via Javascript.   Even if your sort or filter criteria change, the query would stay the same.

image

JavaScript

function Plan_Guide_Grid_Created(planid)
{

var filter = (“plan_guides.plan_guide_id = ‘”+planid+”‘”)

var sortorder = “name ASC”;
document.Get_Plan.getQueryObject().setFilterExpr(filter);
document.AGet_Plan.getQueryObject().setSortExpr(sortorder);
}

Templates

Templates are reusable.   Which means the query is not saved with the template.   The only way to find the query used is to refer back to your HTML.  Of course, this is a great practice for re-usable code.   However, if you are in the development process you might want to keep track of how the templates map the queries.   By doing so you can avoid having to keep your HTML page open in an HTML editor – you can test without needing to review your HTML to find the template and/or query name.

Templates also have many different settings.  Most (if not all) of your settings can be set dynamically in your HTML.   Because the MII documentation is less than verbose, often the best way to determine what a setting will do is to try it.

Note: When you are using a template to display dates retrieved from an xacute query, make sure that the dates are in the datetime format coming from the transaction.  If they are not then there will be problems with your display.

Folder Organization

When starting with MII.  It seemed like a good idea to keep all the information in one generic folder.   This caused problems when updating our system to version 12.0.   With 12.0, a different way of moving files was introduced with Netweaver.   Folders become “projects”.  Those projects can be imported/exported between systems.

It made more sense to have one folder per grouping of projects.   Our original folder structure did not allow for separation of projects.   There was one large project called Dashboard.  Really that folder had several different components. 

With the upgrade of 12.0, the Dashboard folder was broken into the following folders:

  • Production Dashboard

  • Manufacturing Dashboard

  • Plant Maintenance

  • Safety

All of the javascripts are still in one generic location if they are used in multiple different HTML pages.   If they are specific to the project, then they are in the project folder.

Generic Advice – Static Values

When possible create a master table for any static values that might change in the future.   That will allow you to change the value without changing the code.   When writing the code select the data from the master data table as if you will get one or many records.   In the future your one static value could change to many values.  These tables can work like configuration or master data table in SAP.

HTML/Javascript

There are helpful links all over the web many including code snippets, etc.   My only recommendation would be to understand the code prior to including it in your webpage as there are some malicious scripts out there.  My favorite place remains  www.w3schools.com.

 

I am new to writing weblogs and fairly new to MII, HTML, and JavaScript.   I welcome any comments and suggestions.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Sascha Wenninger
    Hi Michelle,

    well done on the blog!

    I would like to add one word of caution around passing large chunks of SQL as paramters directly from HTML. This can be very dangerous as it creates huge opportunities for SQL injection! A better way would be to abstract the SQL commands via parameterised stored procedures and/or via the use of Business Logic Services. Stored procedures also enable fine-grained access control on the database level to minimise exposure of your database via MII.

    Sascha

    (0) 

Leave a Reply