cancel
Showing results for 
Search instead for 
Did you mean: 

Selective fields from node

Former Member
0 Kudos

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,

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

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,

Former Member
0 Kudos

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.

}

Former Member
0 Kudos

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,

Former Member
0 Kudos

Never compare strings using "==" or "!=" (unless you know what you're doing). Use equals() or equalsIgnoreCase() instead.

Armin

Former Member
0 Kudos

usually for == i use equal but equalsIgnoreCase() is new to me ....

I am doing java after a while last few years I was doing abap objects....

Thanks any way,

Former Member
Former Member
0 Kudos

and for != what you use usally, equalignorecase did not work for me ?

okey, I will see

Danke

caio

Former Member
0 Kudos

! x.equals(y)

Armin