cancel
Showing results for 
Search instead for 
Did you mean: 

Java Script appears outside of a container/table in WAD

Former Member
0 Kudos

Hi,

I am trying to create a header section at the top of a Web Template, that comprises the following:

  • A table with one row and three cells

  • In the first (left-side) cell, our company logo

  • In the second (middle-cell) - the report name with last month shown (e.g. Profit & Loss - December 2006). The last month will be derived using embedded javascript.

  • In the third (right-side) cell - a print button

All looks okay - except the Java-script that derives month is appearing outside and before the table.

i.e instead of looking like this:

[Logo] | Profit & Loss - December 2006 | [Print]

it is appearing like this:

December 2006

[Logo] | Profit & Loss - | [Print]

I have placed this table in a container item and "December 2006" still appears outside of the table (and seemingly outside of the container).

The code is like so:


            <bi:CONTAINER_ITEM name="CONTAINER_ITEM_1" designwidth="600" designheight="600" >
                <bi:FULL_WIDTH value="X" />
                <table cellspacing="0" cellpadding="0" width="100%" bgcolor="#dfddd6" border="0" >
                    <tbody >
                        <tr >
                            <td >
                                <img height="60" alt="Logo" src="bwmimerep:///sap/bw/mime/Customer/Images/top_logo.gif" width="270" border="0" />
                            </td>
                            <td width="450" >
                                <b >
                                    Profit & Loss Statement -
                                    <bi:SCRIPT_ITEM name="SCRIPT_ITEM_1" designheight="300" designwidth="600" >
                                        <bi:SCRIPT value="biLargeData:GSZMYGU8U9DFN5LA6Q3BNCD5Z" />
                                    </bi:SCRIPT_ITEM>
                                </b>
                            </td>
                            <td width="150" >
                                <div align="right" >
                                    <bi:BUTTON_GROUP_ITEM name="BUTTON_GROUP_ITEM_1" designheight="70" designwidth="300" >
                                        <bi:BUTTON_LIST type="ORDEREDLIST" >
                                            <bi:BUTTON type="COMPOSITE" index="1" >
                                                <bi:CAPTION value="Print" />
                                                <bi:ACTION type="CHOICE" value="INSTRUCTION" >
                                                    <bi:INSTRUCTION >
                                                        <bi:EXPORT >
                                                            <bi:HEADER_LEFT value="DATETIME" />
                                                            <bi:FOOTER_RIGHT value="PAGEOFPAGES" />
                                                            <bi:ITEM_REF_LIST type="UNORDEREDLIST" >
                                                                <bi:ITEM_REF index="1" value="ANALYSIS_ITEM_1" />
                                                                <bi:ITEM_REF index="2" value="ANALYSIS_ITEM_2" />
                                                            </bi:ITEM_REF_LIST>
                                                        </bi:EXPORT>
                                                    </bi:INSTRUCTION>
                                                </bi:ACTION>
                                                <bi:BUTTON_DESIGN value="EMPHASIZED" />
                                            </bi:BUTTON>
                                        </bi:BUTTON_LIST>
                                    </bi:BUTTON_GROUP_ITEM>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </bi:CONTAINER_ITEM>

and the javacript (which should appear in the middle cell) is like this:


<!-- 
now = new Date(); 
year_str = now.getYear(); 
switch (now.getMonth()-1){
case -1: month_str = "December"; 
year_str = year_str-1; 
break;
case 0: month_str = "January"; break;
case 1: month_str = "February"; break; 
case 2: month_str = "March"; break;
case 3: month_str = "April"; break; 
case 4: month_str = "May"; break;
case 5: month_str = "June"; break; 
case 6: month_str = "July"; break;
case 7: month_str = "August"; break; 
case 8: month_str = "September"; break;
case 9: month_str = "October"; break; 
case 10: month_str = "November"; break;
}
document.write(month_str + ' ' + year_str); 
//--> 

Many thanks for any assistance.

Regards

Adrian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi mate,

Sorry, but I have no further suggestions......but If it worked once and then not again, you may have been on the right track and then something else went wrong....best way forward is creat a copy of your web template and start stripping code in and out to see at which point if works or fails....

Good luck,

Rael

Former Member
0 Kudos

Thanks Rael,

I've tried all manner of things but it seems that the WAD will mess up the syntax after a Save.

I'd like to get the script working within a Script Web Item, as I think this is what it is designed to do.

However, I have discovered that

1. A Javascript web item (that is generating text) will always appear at the beginning of a generated web page - regardless of whether it is contained in a Container or Table Cell.

2. A Javascript web item (that it generating text) will be ignored by an EXPORT to PDF command (not even appearing at the top of the page).

It seems like a bug to me and have raised an OSS note to that effect.

Many thanks for all your help.

Regards

Adrian

Answers (2)

Answers (2)

Former Member
0 Kudos

This has been an issue with WAD since 3.x in that the validation the application performs when you save a template often "scrambles" JavaScript code.

We never found a perfect solution for the problem, but two strategies that did help:

1) Put as much of your JavaScript in the header of the page as possible - code all of your functions here when possible then reference them in the body.

2) Copy the template code to WordPad or a HTML editor and make changes, then paste back into WAD to overwrite existing code. Usually you can save ONCE without it splitting the code on to multiple lines.

Hope this helps - I understand your frustration as it has been a major pain point on past projects.

Former Member
0 Kudos

Hi,

Try putting your javascript code inside some script tags:


<script type="text/javascript">
</script>

Regards,

Rael

Former Member
0 Kudos

Thanks Rael,

It must be a present limitation of WAD script web items that they won't appear within a cell of a table,

Your suggestion worked initially and then strangely stopped working.

i.e I added the following code:


<script type="text/javascript" >
now = new Date(); 
year_str = now.getYear(); 
switch (now.getMonth()-1){
case -1: month_str = "December"; 
year_str = year_str-1; 
break;
case 0: month_str = "January"; break;
case 1: month_str = "February"; break; 
case 2: month_str = "March"; break;
case 3: month_str = "April"; break; 
case 4: month_str = "May"; break;
case 5: month_str = "June"; break; 
case 6: month_str = "July"; break;
case 7: month_str = "August"; break; 
case 8: month_str = "September"; break;
case 9: month_str = "October"; break; 
case 10: month_str = "November"; break;
}
document.write(month_str + ' ' + year_str); 

I executed the template and it worked fine. The next time I opened the Template and executed (it asked to save before executing) - The "December 2006" disappeared.

I've tried this a couple of times and the same thing. I notice that it squashes and modifies the code like this:

<script type="text/javascript" >now = new Date(); year_str = now.getYear(); switch (now.getMonth()-1){ case -1: month_str = "December"; year_str = year_str-1; break; case 0: month_str = "January"; break; case 1: month_str = "February"; break; case 2: month_str = "March"; break; case 3: month_str = "April"; break; case 4: month_str = "May"; break; case 5: month_str = "June"; break; case 6: month_str = "July"; break; case 7: month_str = "August"; break; case 8: month_str = "September"; break; case 9: month_str = "October"; break; case 10: month_str = "November"; break; } document.write(month_str + ' ' + year_str);</script>

- So unfortunately, the WAD is messing up the syntax of the javascript.

So I'm wondering if there is another solution to my problem. Do I perhaps need to remove the table from my container and use the script web item? I know that container layouts are mean't be able to create a "table-like" structure but am not sure of the way it is done.

Regards

Adrian