cancel
Showing results for 
Search instead for 
Did you mean: 

Clearing the contents of a node

Former Member
0 Kudos

Hi,

I have an application where I have a table displaying data from R/3 in a table. The user is allowed to make modifications to this and on click of a button I am trying to send the modified row back to R/3. ( The user can modify only the last row and hence I am trying to send only the last row ). This works fine the first time the BAPI executes. But when the user changes the data after that and tries clickin on the button, even the previous data is sent to the backend. The new data is getting appended as a new row in the node.

Hence i want to know how I can refresh my node before sending it to the backend.

I have used the followind lines of code.

int rows = wdContext.nodeZl_Wrailshipnom_Ret_Nomination_Input().nodeOutput2().nodeLi_Nominations().size();

rows = rows - 1; // Since I want to send only the last row

IPublicRailShipmentNomComp.ILi_NominationsNode nominationnode = wdContext.nodeZl_Wrailshipnom_Ret_Nomination_Input().nodeOutput2().nodeLi_Nominations();

Zsl_Railshipnom_Nominations post_nom = new Zsl_Railshipnom_Nominations();

post_nom.setConsignee(nominationnode.getLi_NominationsElementAt(rows).getConsignee());

post_nom.setCust_Ref_No(nominationnode.getLi_NominationsElementAt(rows).getCust_Ref_No());

input_post.addLi_Nominfo(post_nom);

wdContext.currentZl_Wrailshipnom_PostNominatio_InputElement().modelObject().execute();

wdContext.nodeOutput3().invalidate();

My node structure is as follows:

Znode

-


Output3

-


Li_Nominfo

-


Li_Return

Can anyone let me know where I am going wrong?

Thanks and Regards,

Reena

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Reena,

Modifying your code as below may help you:

<b>Zl_Wrailshipnom_PostNominatio_Input input = new Zl_Wrailshipnom_PostNominatio_Input();</b>

int rows = wdContext.nodeLi_Nominations().size()-1;

// Since I want to send only the last row

IPublicRailShipmentNomComp. ILi_NominationsElement nominationElmt = wdContext.nodeLi_Nominations().getLi_NominationsElementAt(rows);

Zsl_Railshipnom_Nominations post_nom = new Zsl_Railshipnom_Nominations();

post_nom.setConsignee(nominationElmt.getConsignee());

post_nom.setCust_Ref_No(nominationElmt.getCust_Ref_No());

input.addLi_Nominfo(post_nom);

<b>wdcontext.node Zl_Wrailshipnom_PostNominatio_Input.bind(input);</b>

wdContext.currentZl_Wrailshipnom_PostNominatio_InputElement().modelObject().execute();

wdContext.nodeOutput3().invalidate();

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Nibu,

I tried your code, but the problem still persists.

try

{

<b>Zl_Wrailshipnom_Post_Nominatio_Input input = new Zl_Wrailshipnom_Post_Nominatio_Input(); </b>

int rows = wdContext.nodeZl_Wrailshipnom_Fetch_Carrier_Input().nodeOutput_Carrier().nodeLi_Carrier_Nominations().size();

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

{

nominationupdate = wdContext.nodeLi_Carrier_Nominations().getLi_Carrier_NominationsElementAt(i);

check_box = nominationupdate.nodeEnableCells().currentEnableCellsElement();

if ( check_box.getCheckAttribute() == true )

{

com.bp.ngl.cust.railshipnom.updatecarriers.Zss_Carrier_Nominations car_nom = new com.bp.ngl.cust.railshipnom.updatecarriers.Zss_Carrier_Nominations();

car_nom.setNomtk(nominationupdate.getNomtk());

car_nom.setNomnr(nominationupdate.getNomnr());

car_nom.setNomit(nominationupdate.getNomit());

car_nom.setIdate(nominationupdate.getIdate());

input_update.addLi_Carrier_Nominations(car_nom);

} // if loop

} // for loop

wdContext.nodeZl_Wrailshipnom_PostNominatio_Input().bind(input);

wdContext.currentZl_Wrailshipnom_Update_Carnom_InputElement().modelObject().execute();

}

Hi Radha Krishna,

I tried running a decremental loop and deleting the contents. But Im getting a 'java.lang.IndexOutOfBoundsException: Index: 1, Size: 1' exception

int size = wdContext.nodeLi_Carrier_Nominations_update().size();

for (int k=size;k>0;k--)

{

wdContext.nodeOutput_update().nodeLi_Carrier_Nominations_update().removeElement(wdContext.nodeLi_Carrier_Nominations_update().getLi_Carrier_Nominations_updateElementAt(k));

}

Can someone help me with this?

Thanks and Regards,

Reena

Former Member
0 Kudos

Hi Reena,

The loop should be

for (int k=size-1;k>=0;k--)

and not

for (int k=size;k>0;k--)

Thanks and regards

RK

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Reena,

If you don't want to the prvious data, run a loop thru the elements of the node and delete all before executing the steps (run a decremental loop).

Thanks and regards

RK

Former Member
0 Kudos

Hi Reena,

It happens because, the old records (Zsl_Railshipnom_Nominations) are still present in the model.

It'll work fine if you bind a new model to the node everytime before you execute.

Use a temporary node to store any existing rows if u find it necessary.

Rajit