cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Context Attributes - Download to Excel.

Former Member
0 Kudos

Hi Experts,

I have a view with a Context Node in which the context attributes are added dynamically. And further,i bind these attributes dynamically to a dynamically

created UI element Table.

I want to have a functionality to download the contents of this context node (which

are filled in the application) to an Excel file.

I have successfully implemented the Download to Excel for context nodes which were not dynamically added attributes using the following blog:

/people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities

and also using the Table Tutorial from the Web Dynpro Samples and Examples.

Using the same concepts for this application, I an getting an exception, that the

context that was dynamically created, does not exist (very specifically in

TableUtilities.java file, in the downloadtoexcel method).

I wanted to know how can I use the TableUtilities.java for Dynamically Created

Context Attributes, or any other method which can be used for this purpose.

Any ideas regarding this will be helpful.

Regards,

Alka.

Accepted Solutions (1)

Accepted Solutions (1)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Alka,

in NW04s you can download the table data as Excel File on-demand. This means my existing table and Excel export tutorials (written for NW04) are not up-to data any more regarding NW04s. Read my post on downloading an Excel resource from a table tool bar on-demand: . I intend to write an article on this specific solution. It can also be applied for your use-case where the context attributes and the Table UI element are dynamically created.

Regards, Bertram

Former Member
0 Kudos

Hello Bertram,

I have just gone through the post of yours and am trying to understand the steps.

I'll try doing that with some sample application in NW04s, but for right now I'm

using NW04 for the application I was talking of.

It will be very helpful, if you can throw some light on using Dynamic Context for

table contents download for NW04.

Thanx for the post, I'll surely try that out.

Regards,

Alka.

Answers (1)

Answers (1)

Former Member
0 Kudos

Alka,

Could you post complete stack trace?

VS

Former Member
0 Kudos

Hi Valery,

Following is the Stack Trace:

com.sap.tc.webdynpro.progmodel.context.ContextException: NodeElement(TableDataView.Table_Data.0): unknown attribute IPrivateTableDataView.ITable_DataElement.<b>LIFNR</b><u><i> :is the Context Attribute created Dynamically</i></u>

at com.sap.tc.webdynpro.progmodel.context.NodeElement.wdGetAttributeInfo(NodeElement.java:373)

at com.sap.tc.webdynpro.progmodel.context.NodeElement.getAttributeValue(NodeElement.java:867)

at com.xxx.xxxxxxxxxxxxxxxx.TableUtility.DownloadToExcel(TableUtility.java:142)

at com.xxx.xxxxxxxxxxxxxxxx.TableDataView.wdDoModifyView(TableDataView.java:476)

at com.xxx.xxxxxxxxxxxxxxxx.wdp.InternalTableDataView.wdDoModifyView(InternalTableDataView.java:671)

... 27 more

See full exception chain for details.

Detailed Error Information

Detailed Exception Chain

com.sap.tc.webdynpro.progmodel.context.ContextException: NodeElement(TableDataView.Table_Data.0): unknown attribute IPrivateTableDataView.ITable_DataElement.LIFNR

at com.sap.tc.webdynpro.progmodel.context.NodeElement.wdGetAttributeInfo(NodeElement.java:373)

at com.sap.tc.webdynpro.progmodel.context.NodeElement.getAttributeValue(NodeElement.java:867)

at com.xxx.xxxxxxxxxxxxxxxx.TableUtility.DownloadToExcel(TableUtility.java:142)

at com.xxx.xxxxxxxxxxxxxxxx.TableDataView.wdDoModifyView(TableDataView.java:476)

at com.xxx.xxxxxxxxxxxxxxxx.wdp.InternalTableDataView.wdDoModifyView(InternalTableDataView.java:671)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doModifyView(DelegatingView.java:78)

at com.sap.tc.webdynpro.progmodel.view.View.modifyView(View.java:191)

at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.doModifyView(ClientComponent.java:398)

at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.modifyView(ClientApplication.java:692)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:382)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:659)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:251)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)

at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

Regards,

Alka.

Message was edited by:

Alka Panday

Former Member
0 Kudos

Alka,

First, it's bad idea to call DownloadToExcel from wdDoModifyView. Invoke it from action handler.

Second, it seems that you have wrong sequence of adding attributes / download calls -- download happens earlier then attributes are actually added. If you can, try to add attributes in wdDoInit or any time earlier then download action is invoked.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Hi Valery,

As said I have now written the code in an Action called by the button, also

the context attributes creation is done in the wdDoModififyview() and these are

added to the Context node when the view is called for the first time .

Even after this I am getting the same error and the same stack trace. Can you

help me with this??

Regards,

Alka.

Former Member
0 Kudos

Can you please post your wdDoModifyView code ?

Regards,

Subramanian V.

Former Member
0 Kudos

Hi Subramanian,

This is the code in wdDoModifyview in FirstTime condition:

for(int a = 1; a <=l_no_cols; a++)
{
IWDTableColumn l_tab_col = (IWDTableColumn)view.createElement(IWDTableColumn.class,"COL"+a);
IWDCaption l_tab_cap = (IWDCaption)view.createElement(IWDCaption.class,"Caption"+a);
try {
		l_tab_cap.setText(ColumnName[a]);
} catch (SQLException e1) {
		e1.printStackTrace();
}
l_tab_col.setHeader(l_tab_cap);
IWDInputField l_tab_cell = (IWDInputField)view.createElement(IWDInputField.class,"CellEditor"+a);
						
try {
 <b>wdContext.nodeTable_Data().getNodeInfo().addAttribute(ColumnName[a],ColumnType[a]);</b>l_tab_cell.bindValue(wdContext.nodeTable_Data().getNodeInfo().getAttribute(ColumnName[a]));
} catch (SQLException e2) {
		e2.printStackTrace();
}
l_tab_col.setTableCellEditor(l_tab_cell);
l_tab.addColumn(l_tab_col);
						
						
}

Regards,

Alka.

Message was edited by:

Alka Panday

Message was edited by:

Alka Panday

Message was edited by:

Alka Panday

Former Member
0 Kudos

Hi Alka,

Can you also indicate which is line 476 in your wdDoModifyView and I presume you have not pasted the entire code of wdDoModifyView ?

Are you trying to add the entire table or just few columns of that table ?

Are you facing a problem to create the UI Element or the Context Attribute ?

Your code does not show where you have created a new Context Attribute.

Regards,

Subramanian V.

Former Member
0 Kudos

Q) Are you trying to add the entire table or just few columns of that table ?

I'm adding the entire table .

Q) Are you facing a problem to create the UI Element or the Context Attribute ?

I'm getting no problems in either of the two.

Q)Your code does not show where you have created a new Context Attribute.

<b>wdContext.nodeTable_Data().getNodeInfo().addAttribute(ColumnName[a],ColumnType[a]);</b>

line 476:

wdContext.currentContextElement().setLink_XL((String)wdContext.currentContextElement().getTableUtility().DownloadToExcel(al_ex).get("url"));

al_ex: Arraylist in which i'm passing all the attribute names that are created dynamically.

Exception occurs in TableUtilities.java at:

xml_file.append("<")

.append(attributeName)

.append(">")

<b>.append(elem.getAttributeValue(attributeName))</b>

.append("</")

.append(attributeName)

.append(">\n");

Regards,

Alka.

Message was edited by:

Alka Panday