Skip to Content
author's profile photo Former Member
Former Member

Getting the value for many entries(using for loop) and displaying in table

Hi,

I have requirement like this,

Step :1

I want to pass particular task id(import parameter)

and get all external id(export parameter)from one bapi "SWN_UWL_GET_WORKLIST "

and pass this external id to the work_id(import parameter) of other bapi " SWK_WI_CONTAINER_READ".

Step 2: I want to retrieve only particular values(Empno,TripNo,TotalCost) from the output tables of the same Bapi " SWK_WI_CONTAINER_READ".

Step 3: I want to bind this values to the view.

In the view, we want to dispay the values in the table(3 columns,n rows) according to number of external id.

In the component Contoller, I have created 3 value attributes.

In the view context, I have created 3 value attributes.

I have mapped them

Step 4 : I have done the following coding,

//Passing the task id

if(taskCount1.equals("TS90000414"))

{

// getting cnt for that task id

int cnt = wdThis.wdGetContext().nodeSwn_Uwl_Get_Worklist_Input().nodeOutput().nodeWorklist().size();

wdContext.currentContextElement().setVa_ExpenseReportsCount(cnt);

String[] externalidList = new String[cnt];

String[] workidList = new String[cnt];

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

{

//Retrieve the external id from Bapi "Swn_Uwl_Get_Worklist"

externalidList<i> = wdContext.nodeSwn_Uwl_Get_Worklist_Input().nodeOutput().

nodeWorklist().getWorklistElementAt(i).getExternal_Id();

//Passing to the work id of the bapi "Swk_Wi_Container_Read"

Swk_Wi_Container_Read_Input containerInput = new Swk_Wi_Container_Read_Input();

wdContext.nodeSwk_Wi_Container_Read_Input().bind(containerInput);

containerInput.setIm_Wi_Id(externalidList<i>);

try

{

wdContext.nodeSwk_Wi_Container_Read_Input().currentSwk_Wi_Container_Read_InputElement().modelObject().execute();

wdContext.nodeSwk_Wi_Container_Read_Input().nodeOutput_ContainerRead().nodeCnt_Elem_Tab_Read().invalidate();

}

catch(Exception e)

{

e.printStackTrace();

}

// Getting the count of the output tables under bapi "Swk_Wi_Container_Read" , so we can retrieve the particular value

tripdatacount = wdThis.wdGetContext().nodeSwk_Wi_Container_Read_Input().nodeOutput_ContainerRead ().nodeCnt_Elem_Tab_Read().size();

String[] element = new String[tripdatacount];

String[] value = new String[tripdatacount];

for (k=0;i<tripdatacount<i>;k++)

{

// Getting the particular element

element[k] = wdContext.nodeSwk_Wi_Container_Read_Input().nodeOutput_ContainerRead().

nodeCnt_Elem_Tab_Read().getCnt_Elem_Tab_ReadElementAt(k).getElement();

}

for (k=0;j<tripdatacount<i>;k++)

{

if(element[k].equals("PersonnelNo"))

{

// checking the particular element and retriieving the value and set to the value attribute of the component controller

value[k] = wdContext.nodeSwk_Wi_Container_Read_Input().nodeOutput_ContainerRead().

nodeCnt_Elem_Tab_Read().getCnt_Elem_Tab_ReadElementAt(k).getValue();

wdContext.currentContextElement().setVa_PersonnelNo(value[k]);

}

if(element[k].equals("TripNumber"))

{

// checking the particular element and retriieving the value and set to the value attribute of the component controller

value[k] = wdContext.nodeSwk_Wi_Container_Read_Input().nodeOutput_ContainerRead().

nodeCnt_Elem_Tab_Read().getCnt_Elem_Tab_ReadElementAt(k).getValue();

wdContext.currentContextElement().setVa_TripNumber(value[k]);

}

if(element[k].equals("TotalCost"))

{

// checking the particular element and retriieving the value and set to the value attribute of the component controller

value[k] = wdContext.nodeSwk_Wi_Container_Read_Input().nodeOutput_ContainerRead().

nodeCnt_Elem_Tab_Read().getCnt_Elem_Tab_ReadElementAt(k).getValue();

wdContext.currentContextElement().setVa_TotalCost(value[k]);

}

}

But if i do like this all the entries of PersonnelNo, TripNumber and Total Cost whether it will display in table of view controller.

Could You please guide me to get these values and store it in the table of view contoller.

Regards,

Anitha

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Aug 26, 2009 at 03:49 AM

    Hi Anitha,

    Please define your prolem clearly so that we can give some suggestion/solutions to you.

    Regards

    SM Nizamudeen

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Anitha,

      Please check the cardinality of ur node which is bound to table, it should be 0 to n and u should create node elements, set the values from the model to node attributes and finally add the elements to the node .

      for eg :

      for (int i=0;i<wdContext.nodeTest().size();i++){

      ItestElement testElement = wdContext.nodeTest().getTestElement(i);

      ITabelElement element = wdContext.nodeTable().createTableElement();

      element.setName(testElement.getName());

      //// Similarly set the required parametrs.

      wdContext.nodeTable().addElement(element);

      }

      here Table is Value Node bound to table and Test is Model node.

      if the cardinality is o to n , then u might be adding the last element to the no, i mean to say u might have placed this line outside the For loop wdContext.nodeTable.addElement(element); so only the last element is displyed in ur table.

      Hope it helps.

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2009 at 10:34 AM

    thanks

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.