Skip to Content
avatar image
Former Member

Reg: Inserting values into table

Hi,

I have a context node dealer and attribute as dealer code.

I have assigned this context to a table.

i want to insert some values into the dealer code field of the table.

when i use the below code, its giving outofbound exception.

for(i=0;i<5;i++)

{

wdContext.nodedealer.getdealerelementatindex(i).setdealercode(i);

}

kindly suggest.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 08, 2008 at 07:58 AM

    Hi,

    You want to append values to your table in addition to the values in the node Dealer. You can do it in many ways one way is iterate a loop say up to 5 and if counter value is greater than your node size then create a element, set element values and then bind to the node.

    In action Button

    for(int i=0;i<5;i++)

    {

    if (i>wdContext.nodeDealer.size())

    {

    IPrivateview.IDealerelement ele = wdContext.createDealerelement();

    ele.setDealercode("XYZ");

    wdContext.nodeDealer().addElement(ele);

    }

    }

    Hope this will solve your problem, revert me if you have any clarifications

    Regards

    Raghu

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 08, 2008 at 07:37 AM

    Hi,

    you can use the following code:

    IPrivate<View Name>.I<DealerNode>Element elemet = wdContext.node<DealerNode>().create<DealerNode>Element();

    elemet.set<DealerAttribute>(<some Value>);

    wdContext.node<DealerNode>().addElement(element);

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 08, 2008 at 07:25 AM

    Hi,

    rather then the code for(i=0;i<5;i++)

    use for (i = 0; i < wdContext.nodeDealer().size(); i++)

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 08, 2008 at 07:28 AM

    Hi,

    The above code will work if you already have some values in you node element. If not you may need to create an element of the node, set the values on that element and then bind the element to the node.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 08, 2008 at 07:29 AM

    hi,

    Create One action add and write the following code.

    
    public void onActionAdd(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
      {
        //@@begin onActionAdd(ServerEvent)
        
       
        for(int j=0;j<=wdContext.nodeTable_1().size();j++)
        {
        
        
    	IPrivateAssi3View.ITable_1Element tabadd = wdContext.createTable_1Element();
     
    		tabadd.setDept_ID(wdContext.currentTable_1Element().getDept_ID());
    	    tabadd.setName(		wdContext.nodeTable_1().addElement(tabadd);
    	  
        }
        //@@end
      }
    
    

    hpe it wl help u.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 08, 2008 at 07:36 AM

    Hi,

    according to me there is no elements in your table.

    if you want to add elements to table do like this,

    IPrivate<name>View.InodedealerNode inodedealerNode = wdContext.nodedealer();

    IPrivate<name>View.InodedealerElement inodedealerElement =inodedealerNode.creatededealerElement();

    inodedealerElement.setCode("1111");

    inodedealerNode.addElement(inodedealerElement);

    if you have some elements already then follow the Aishwarya Sharma's first post.

    Regards,

    ramesh

    Add comment
    10|10000 characters needed characters exceeded