cancel
Showing results for 
Search instead for 
Did you mean: 

Unbound fields in a table built with rfc model

former_member212767
Participant
0 Kudos

Hi,

I would like to have unbound fields in a table in addition to the fields that are coming from the model.

I have a model from an RFC function. I use this to build a table. There are 5 columns. This works fine. I would like to add two additional columns to the table that have their data coming from elsewhere (not from the rfc function).

I've tried using the wdDoModifyView as below:

IWDTextView text = (IWDTextView)view.getElement("TextView2");

text.setText("This is the text");

The problem here is that the value is shown on all the rows, not just one.

And if I try to use the object that contains the getters and setters for the table data, these additional unbound fields do not have the getters and setters.

How can I get to these unbound fields so I can fill them in a loop ? Can I create additional fields in the model so I can bind them to the context ?

I do not wish to change the rfc code to have these additional fields in there. I am also not able to add fields to the model by hand (should I be able to ?).

Any help greatly appreciated

Kind Regards,

Jari Pakarinen

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Jari,

Inside the supply function write your own code to populate the newly added attributes. Then, whenever an element is created for the parent node or the lead selection changes, the supply function will be automatically invoked and the inner attributes will be populated.

For more help on supply function refer to this example :

http://help.sap.com/saphelp_nw04/helpdata/en/d6/078aa26b73fb47b43d9330f1a207cf/content.htm

Hope this helps,

Best Regards,

Nibu.

former_member212767
Participant
0 Kudos

Ok, Thanks.

Now I'm able to add data to the table with the supply function.

The table is originally filled in the wdDoInit() of the view. All the data is gathered (also the additional fields) in that function also.

Does this mean that the additional data I want to show in the table has to be stored in an array/collection etc. and then inserted to the table in the supply function?Sounds a bit cumbersome. Shouldn't the table be filled in the same function where the data is gathered?

Regards,

Jari

Former Member
0 Kudos

Jari,

You may skip supply function creation and populate additional data in wdDoInit as well.

You may iterate over original node elements, then access helper node element from original one and set attributes.

VS

former_member212767
Participant
0 Kudos

Thanks.

I will need a clarification though

Here is the code snippet from wdDoInit():



for (Iterator iter = list.iterator(); iter.hasNext();) {
	Object skeduLine = iter.next();
	StringTokenizer toker = new StringTokenizer(((Ztab4000)skeduLine).getWa(), "t");
	Zmaterials zMats = new Zmaterials();
	String blaa = (toker.nextToken().split("\,"))[0];
	if (blaa.indexOf('.') != -1);
		blaa = blaa.replaceAll("\.", "");
	zMats.setWmeng(Integer.parseInt(blaa));
	zMats.setEtdat(getDate(toker.nextToken()));
	zMats.setMatnr(toker.nextToken());
	zMats.setKdmat(toker.nextToken());
	wdContext.nodeZ_Rfc_Schedagrt_Save_Input().currentZ_Rfc_Schedagrt_Save_InputElement().modelObject().addMaterials(zMats);
}

I'm going thogh a list that contains String objects.

Each String object contains fields separated by a tab. There are 6 fields, and 4 of them are going to the Zmaterilas object, and the rest 2 should be put to the additional fields of the table.

I create the Zmaterials (table contents minus the additional fields) object and populate these fields with the 4 fields of data.

How should I put the additional data to the table here ?

Kind regards,

Jari

Former Member
0 Kudos

Jari,

Say node for 2 additional attributes is named "Extras" (1..1, non-singleton)

Before loop place this:


/* if node materials is non-singleton */
final IPrivate<ViewControllerName>IMaterialsNode nMaterials =
wdContext
  .nodeZ_Rfc_Schedagrt_Save_Input()
    .currentZ_Rfc_Schedagrt_Save_InputElement()
      .nodeMaterials()
/* or if materials node is singleton then */
final IPrivate<ViewControllerName>IMaterialsNode nMaterials = wdContext.nodeMaterials();

Place this as last statements inside for-loop:


final IPrivate<ViewControllerName>IMaterialsElement elLastAddedMaterial = nMaterials.getMaterialsElementAt( nMaterials.size() - 1 );
final IPrivate<ViewControllerName>IExtrasElement elExtras = elLastAddedMaterial.nodeExtras().getCurrentExtrasElement();
elExtras.setMyAttr1(...);
elExtras.setMyAttr2(...);

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com/

former_member212767
Participant
0 Kudos

I got it working! Great, could not have done it without your help.

IPrivate<ViewControllerName>IMaterialsNode neede a dot between like this:

IPrivateSkeduComponent.IMaterialsNode

Also a cast was necessary in this part:


final IPrivateSkeduComponent.IAddtionalElement elExtras 
	 	= (IPrivateSkeduComponent.IAddtionalElement)elLastAddedMaterial.
	 		nodeAddtional().
	 			getCurrentElement();

10 points to Valery

Regards,

Jari

Answers (1)

Answers (1)

Former Member
0 Kudos

Jari,

Create a sub-node under your model node (cardinality 1..1, non-singleton, initialize lead selection), add your "extra" attributes here. Then create additional column(s) and bind cell editor(s) as usually.

You may create supply function for this node to populate values.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

former_member212767
Participant
0 Kudos

Hi,

Thanks for the reply.

I've now created the sub-node and bound the cell editors. I also created the supply function.

however I'm at a loss on how to populate the values in the supply function ?

Thanks!

Jari Pakarinen