cancel
Showing results for 
Search instead for 
Did you mean: 

Generate class boundaries (GENERATE_BREAKS) for BExMap

BMEIJS
Active Participant
0 Kudos

When displaying data as color shading on a map in a webtemplate (using BExMap), the automatic distribution of the value ranges for the color groups is not optimal.

An example: If 99% of the turnover falls between $0-$100 and 1% is > $10,000 and I have 10 color-classes, only 2 color-classes are showed in the map (0-1000 and >1000). This happns because SAP takes the upper and lower limit and divides it in 10 equal-sized categories. However, I want SAP to choose the color-class boundaries such that ALL classes are displayed. 10% of the total turnover should fall in every color class.

From the BW 3.5 API I've learned that there exist a map attribute GENERATE_BREAKS with the description "This attribute enables better automatic distribution of the color shading". As I'm on BW 3.1B, I can't check if this is what I want. Therefor, I've got 2 questions:

  • Does GENERATE_BREAKS generate the color distribution that I want?

  • Can I achieve this effect for BW 3.1B?

Kind regards.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi, Ben.

We're on BW 3.5 and use this feature to adjust range limits. So, if I understand your problem, the answer to first question is YES.

For example: we run the web template and using javascript capture the values returned by query. Then we calcule range limits and recall the template again setting the intervals. Follow a example of the url:

'&BREAK_1=' + limit1 + '&BREAK_2=' + limit2 + '&BREAK_3=' + limit3 + '&BREAK_4=' + limit4;

Other option is to define the interval on the map_layer, as follow:

<object>

<param name="OWNER" value="SAP_BW"/>

<param name="CMD" value="GET_ITEM"/>

<param name="NAME" value="MAPLAYER_1"/>

<param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_MAPLAYER"/>

<param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>

<param name="CLASSES" value="8"/>

<param name="COLOR_VALUE_1" value="RGB(0,170,0)"/>

<param name="BREAK_1" value="1.1"/>

<param name="COLOR_VALUE_2" value="RGB(0,255,0)"/>

<param name="BREAK_2" value="2.1"/>

<param name="COLOR_VALUE_3" value="RGB(204,204,204)"/>

<param name="BREAK_3" value="3.1"/>

<param name="COLOR_VALUE_4" value="RGB(255,255,0)"/>

<param name="BREAK_4" value="4.1"/>

ITEM: MAPLAYER_1

</object>

For BW 3.1B I'm not shure if this will work. Try to use the example above on url or object to adjust the range.

Good luck.

Henrique

BMEIJS
Active Participant
0 Kudos

Thank you Henrique.

I will try your approach. A major drawback is that you have to execute 2 queries. Do you have 2 separate queries, or do you execute both queries twice?

What about browser/javasript performance for large resultsets? It would be great if you could post your javascript, or give me some tips for the coding.

Former Member
0 Kudos

Ben,

That's not a good approach if query execution time may be a problem. In our cenarios isn't. We execute same query twice.

We execute the template one first time. Using the script (at the end of the post) we get the max and min values (different columns calculated in query) from a hidden table (named TABLE_1).

The position of scripts are important. Follow the general logic.

Coded right after the object TABLE_1:

<script>

/* Get the max and min values and set the limits */

var min = 0

var max = 0

range(document)

function range(o)

{

if (o.nodeName == 'TABLE' && o.name == 'TABLE_1')

{

min = o.firstChild.childNodes[1].childNodes[2].firstChild.firstChild.nodeValue

max = o.firstChild.childNodes[1].childNodes[3].firstChild.firstChild.nodeValue

}

/* Recursive call to treat layout issues */

for (var child = 0; child < o.childNodes.length; child++)

{

if (o.childNodes[child].nodeName == "HTML"

|| o.childNodes[child].nodeName == "BODY"

|| o.childNodes[child].nodeName == "SPAN"

|| o.childNodes[child].nodeName == "DIV"

|| o.childNodes[child].nodeName == "P"

|| o.childNodes[child].nodeName == "TABLE"

|| o.childNodes[child].nodeName == "TBODY"

|| o.childNodes[child].nodeName == "TR"

|| o.childNodes[child].nodeName == "TD"

|| o.childNodes[child].nodeName == "A")

{

range(o.childNodes[child])

}

}

}

max = parseFloat(max)

min = parseFloat(min)

min = Math.round(min);

incremento = Math.round( (max - min) / 7 )

faixa1_i = 0

faixa1_f = faixa2_i = menor + incremento

faixa2_f = faixa3_i = faixa2_i + incremento

faixa3_f = faixa4_i = faixa3_i + incremento

faixa4_f = faixa5_i = faixa4_i + incremento

faixa5_f = faixa6_i = faixa5_i + incremento

faixa6_f = faixa7_i = faixa6_i + incremento

</script>

Coded at the end of template

<script>

if (location.href.indexOf("MAP") == -1)

{

command = '&CMD_1=ITEM=MAPLAYER_1&CLASSES=8';

breaks = '&BREAK_1=' + faixa1_f + '&BREAK_2=' + faixa2_f + '&BREAK_3=' + faixa3_f + '&BREAK_4=' + faixa4_f + '&BREAK_5=' + faixa5_f + '&BREAK_6=' + faixa6_f + '&BREAK_7=' + faixa7_f;

colors = '&COLOR_VALUE_1=RGB(0;128;64)&COLOR_VALUE_2=RGB(0;255;0)&COLOR_VALUE_3=RGB(207;207;207)&COLOR_VALUE_4=RGB(255;255;0)&COLOR_VALUE_5=RGB(255;128;0)&COLOR_VALUE_6=RGB(255;0;0)&COLOR_VALUE_7=RGB(128;0;128)&COLOR_VALUE_8=RGB(128;0;128)';

window.location= '<sap_bw_url>' + command + breaks + colors;

}

</script>

Answers (0)