on 08-31-2007 10:15 AM
Hello Friends,
I have a question as follows:
I am calling a bapi from R3 system which will return me two tables, lets say one table "zvbap" contains str vbap and second table "zsel" contains info, which fields should be displayed from the table"zvbap".
Now in my context where I am displaying table zvbap in view, is it possible to just only display those fileds which are provide in str zsel ?
I hope I am clear enough in my query , ....
Regards,
Hi,
You can bind the visibility property of the UI elements bound to the zvbap table to context. Then based on the fields in zsel, you can set the visibilities accordingly.
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Satyajit,
can you pls provide me any example or is there any docu where I can read this etc.... or can you pls be more discrptive....
I have following code, which shows the table contains, ( note the backend bapi has to be extended to provide with zsel str )...
public static void wdDoModifyView(IPrivateResultView wdThis, IPrivateResultView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
IWDMessageManager mm = wdThis.wdGetAPI().getComponent().getMessageManager();
IWDTable tv = (IWDTable)view.getElement("resultTable");
tv.bindDataSource(wdContext.currentContextElement().getApplication());
int size = wdThis.wdGetFieldControllerController().wdGetContext().nodeZfld_Name().size();
if (firstTime)
{
for (int i = 0; i < size; i++)
{
String fieldName =
wdThis
.wdGetFieldControllerController()
.wdGetContext()
.nodeZfld_Name()
.getZfld_NameElementAt(i)
.getFieldname()
.toLowerCase();
String rangeType =
wdThis.wdGetFieldControllerController().wdGetContext().nodeZfld_Name().getZfld_NameElementAt(i).getDdtext();
if (rangeType.compareToIgnoreCase("to") != 0)
{
String fieldText =
wdThis.wdGetFieldControllerController().wdGetContext().nodeZfld_Name().getZfld_NameElementAt(i).getDdtext();
fieldName = WDUtil.getJavaNameForAbapFieldName(fieldName);
String attrName = wdContext.currentContextElement().getApplication() + "." + fieldName;
IWDTableColumn column = (IWDTableColumn)view.createElement(IWDTableColumn.class, fieldName);
IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class, null);
IWDCaption caption = (IWDCaption)view.createElement(IWDCaption.class, null);
column.setTableCellEditor(textView);
column.setHeader(caption);
textView.bindText(attrName);
caption.setText(fieldText);
tv.addColumn(column);
}
}
saveColumns = tv.getColumns();
}
if (rebuildScreen)
{
IWDTableColumn[] tcArray = saveColumns;
tv.removeAllColumns();
Map hMap = new HashMap();
for (int x = 0; x < tcArray.length; x++)
{
IWDTableColumn tc = (IWDTableColumn)tcArray[x];
String tcID = tc.getId();
for (int i = 0; i < size; i++)
{
boolean omit =
wdThis.wdGetFieldControllerController().wdGetContext().nodeZfld_Name().getZfld_NameElementAt(i).getOmit();
String dispSeq =
wdThis
.wdGetFieldControllerController()
.wdGetContext()
.nodeZfld_Name()
.getZfld_NameElementAt(i)
.getDispseq();
String fieldName =
wdThis
.wdGetFieldControllerController()
.wdGetContext()
.nodeZfld_Name()
.getZfld_NameElementAt(i)
.getFieldname();
String rangeType =
wdThis.wdGetFieldControllerController().wdGetContext().nodeZfld_Name().getZfld_NameElementAt(i).getDdtext();
if (rangeType.compareToIgnoreCase("to") != 0)
{
fieldName = WDUtil.getJavaNameForAbapFieldName(fieldName);
if (tcID.equals(fieldName) && dispSeq.trim().length() > 0 && omit == false)
{
hMap.put(dispSeq, tcArray[x]);
}
}
}
}
Map sortedMap = new TreeMap(hMap);
Iterator iter = sortedMap.entrySet().iterator();
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
IWDTableColumn tc = (IWDTableColumn)entry.getValue();
tv.addColumn(tc);
}
tv.setFirstVisibleRow(0);
wdContext.currentContextElement().setTableSorter(new TableSorter(tv, wdThis.wdGetSortAction(), null));
}
rebuildScreen = false;
//@@end
}
So where in coading its setting the colum, there I can ask for "visibility" ? how I do not understand your point actually...
Regards,
Hi,
So you are creating the columns dynamically. Ok, in this part of your code where you are creating the table columsn, you can check the zsel string. Only if the condition is satisfied, you create the column otherwise you don't.
//Something like this...
if(<zSel contains this field>){
IWDTableColumn column = (IWDTableColumn)view.createElement(IWDTableColumn.class, fieldName);
IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class, null);
IWDCaption caption = (IWDCaption)view.createElement(IWDCaption.class, null);
Regards,
Satyajit.
}
I have tried just for test something like this:
if (fieldName != "VBELN") {
IWDTableColumn column = (IWDTableColumn)view.createElement(IWDTableColumn.class, fieldName);
IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class, null);
IWDCaption caption = (IWDCaption)view.createElement(IWDCaption.class, null);
column.setTableCellEditor(textView);
column.setHeader(caption);
textView.bindText(attrName);
caption.setText(fieldText);
tv.addColumn(column);
}
But did not work for me ?
Any idea what is wrong there....
Regards,
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.