cancel
Showing results for 
Search instead for 
Did you mean: 

Add value to model nodes

Former Member
0 Kudos

hi all,

I have to populate a model node and execute the RFC so that its updated at the backend and the nodes are once again refreshed.

<b>It_Prcgprdg()</b> is the model to which i have to add the record which should be added in the backend and the outputnode should be refreshed.

here's my code.

IPrivatePriProdGrpView.IIt_PrcgprdgElement prod = wdContext.createIt_PrcgprdgElement(new Zsd_Pmt_S_Prcgprdg());

wdContext.nodeIt_Prcgprdg().validate();

prod.setZprigrp(wdContext.nodeEt_Pricegrp_out().getEt_Pricegrp_outElementAt(lead1).getZprigrp());

int Size = wdContext.nodeEt_Prodgrp_out().size();

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

{

int lead = wdContext.nodeEt_Prodgrp_out().getLeadSelection();

if(wdContext.nodeEt_Prodgrp_out().isMultiSelected(i) || lead == i )

{

prod.setZchngusr(Username);

prod.setZprodgrp(wdContext.nodeEt_Prodgrp_out().getEt_Prodgrp_outElementAt(lead).getZprodgrp());

wdContext.nodeIt_Prcgprdg().addElement(prod);

}

wdThis.wdGetPricingGrpCompController().execute_RFC();

Please correct if my code is wrong.

Thanks in advance,

Gopi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Gopi,

Instead of creating new elements and adding them to the node, create suitable structural instances and add them to the suitable modelObject. For that, you may modify your code like this.


Zsd_pmt_price_input priceInput = new Zsd_pmt_price_input();
wdContext.nodeZsd_pmt_price_input().bind(priceInput);

int outSize = wdContext.nodeEt_Prodgrp_out().size();
for( int j = 0; j< outSize ;j++)
{
  if(wdContext.nodeEt_Prodgrp_out().isMultiSelected(j) ||  
  lead == j )
  {
    /** Find out what is Struct by using the steps        
        mentioned below */
    Struct x = new Struct();
    x.setZprigrp(wdContext.nodeEt_Pricegrp_out()
        .getEt_Pricegrp_outElementAt(lead1).getZprigrp());
    x.setZchngusr(Username);
    x.setZprodgrp(wdContext.nodeEt_Prodgrp_out()
        .getEt_Prodgrp_outElementAt(lead).getZprodgrp());
    
    priceInput.addIt_Prcgprdg(x);
  } 
}

wdContext.nodeZsd_pmt_price_input().modelObject().execute();

wdContext.nodeOutput().invalidate();

Steps to find out the structure associated with the node It_Prcgprdg:

1) Go to the context tab of the view/CC whereever you have this node It_Prcgprdg.

2) Right Click the node It_Prcgprdg and select properties.

3) Look for a property called "Structure" and note down the value of this property. (Say, Struct)

Bala

Former Member
0 Kudos

Hi bala,

<b>Zsd_Pmt_Pricegrp_Rfc_Input input1 = new Zsd_Pmt_Pricegrp_Rfc_Input();

wdContext.nodeZsd_Pmt_Pricegrp_Rfc_Input().bind(input1);

int lead1 = wdContext.nodeEt_Pricegrp_out().getLeadSelection();

int outSize = wdContext.nodeEt_Prodgrp_out().size();

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

{

int lead = wdContext.nodeEt_Prodgrp_out().getLeadSelection();

if(wdContext.nodeEt_Prodgrp_out().isMultiSelected(i) || lead == i )

{

//Zsd_Pmt_S_Prcgprdg prod is the struc of It_Prcgprdg

Zsd_Pmt_S_Prcgprdg prod = new Zsd_Pmt_S_Prcgprdg();

prod.setZchngusr(Username);

prod.setZprigrp(wdContext.nodeEt_Pricegrp_out().getEt_Pricegrp_outElementAt(lead1).getZprigrp());

prod.setZprodgrp(wdContext.nodeEt_Prodgrp_out().getEt_Prodgrp_outElementAt(lead).getZprodgrp());

input1.addIt_Prcgprdg(prod);

}

}

wdContext.currentZsd_Pmt_Pricegrp_Rfc_InputElement().setIv_Zoperation("P");

wdThis.wdGetPricingGrpCompController().execute_RFC();</b>

I have written the above code in the <b>onActionAddProduct</b> method of the iview. I need to add the products to backedn when user clicks the buttonADD.

<b>Zsd_Pmt_Pricegrp_Rfc_Input input1 = new Zsd_Pmt_Pricegrp_Rfc_Input();

wdContext.nodeZsd_Pmt_Pricegrp_Rfc_Input().bind(input1);

<b>Zsd_Pmt_Pricegrp_Rfc_Input input1 = new Zsd_Pmt_Pricegrp_Rfc_Input();

wdContext.nodeZsd_Pmt_Pricegrp_Rfc_Input().bind(input1);

<b>Zsd_Pmt_Pricegrp_Rfc_Input</b> node i have already initialized in compcontroller as

Zsd_Pmt_Pricegrp_Rfc_Input inpri = new Zsd_Pmt_Pricegrp_Rfc_Input();

wdContext.nodeZsd_Pmt_Pricegrp_Rfc_Input().bind(inpri);

Still i am unable to update the data. Do i need to write the code in compcontroller only?

<b>Iv_Zoperation</b> is the import parameter in RFC. i need to send this as "P".

Please suggest me.

gopi

Message was edited by: gopi nidjelli

Former Member
0 Kudos

Remove the below code from component controller and check again.


Zsd_Pmt_Pricegrp_Rfc_Input inpri = new Zsd_Pmt_Pricegrp_Rfc_Input();
wdContext.nodeZsd_Pmt_Pricegrp_Rfc_Input().bind(inpri); 

Regards,

Subramanian V.

Former Member
0 Kudos

hi Subramanian,

If i remove the below code from CC i am getting null pointer exception.

<b>Zsd_Pmt_Pricegrp_Rfc_Input inpri = new Zsd_Pmt_Pricegrp_Rfc_Input();

wdContext.nodeZsd_Pmt_Pricegrp_Rfc_Input().bind(inpri);</b>

when i run the application for the first time i need output nodes values to fill up and when i select the record from the displayed list it should add to another table.

how can we get the instance <b>inpri</b> in the view so that i can set the data to that element.

Thanks in advance,

Gopi

Former Member
0 Kudos

<i>Q: Still i am unable to update the data. Do i need to write the code in compcontroller only?</i>

1. No not necessary. You may do it from the view as well.

2. Add a debug code to the "for" loop and check if the control actually enters the loop.

3. From what you are trying to acheive, I guess your code in the for loop for setting Zprodgrp should be


  prod.setZprodgrp(wdContext.nodeEt_Prodgrp_out().
      getEt_Prodgrp_outElementAt(<b>i</b>).getZprodgrp());

Bala

Former Member
0 Kudos

hi Bala,

I am getting the Et_Prodgrp_out as Zero before the For loop begins. this is because I am creating the instance of the node.

i,e

Zsd_Pmt_Pricegrp_Rfc_Input input1 = new Zsd_Pmt_Pricegrp_Rfc_Input();

// wdContext.nodeZsd_Pmt_Pricegrp_Rfc_Input().bind(input1);

if i do not put this code then iam getting the size of the node.

with out creating the instance how can we add ?

Thanks in advance,

Gopi

Former Member
0 Kudos

Remove


Zsd_pmt_price_input priceInput = new Zsd_pmt_price_input();
wdContext.nodeZsd_pmt_price_input().bind(priceInput);

and use


int outSize = wdContext.nodeEt_Prodgrp_out().size();
for( int j = 0; j< outSize ;j++)
{
  if(wdContext.nodeEt_Prodgrp_out().isMultiSelected(j) ||  
  lead == j )
  {
    /** Find out what is Struct by using the steps        
        mentioned below */
    Struct x = new Struct();
    x.setZprigrp(wdContext.nodeEt_Pricegrp_out()
        .getEt_Pricegrp_outElementAt(lead1).getZprigrp());
    x.setZchngusr(Username);
    x.setZprodgrp(wdContext.nodeEt_Prodgrp_out()
        .getEt_Prodgrp_outElementAt(i).getZprodgrp());
    
    <b><i>wdContext.currentZsd_Pmt_Pricegrp_Rfc_InputElement().
         modelObject().addIt_Prcgprdg(x);</i></b>
  } 
}

  wdContext.currentZsd_Pmt_Pricegrp_Rfc_InputElement().
         modelObject().setIv_Zoperation("P");
  wdThis.wdGetPricingGrpCompController().execute_RFC();

Bala

Answers (3)

Answers (3)

Former Member
0 Kudos

hi bala,

Context Structure

zsd_pmt_price_input

Et_Pricegrp

Et_Prodgrp

It_Prcgprdg

Output

Et_Pricegrp_out

Et_Prodgrp_out

It_Prcgprdg_out

Intially i am executing the RFC and displaying the Et_Pricegrp_out

Et_Prodgrp_out

nodes data in tables.

I am populating It_Prcgprdg node with the data and once again executing the RFC.

But the data is not reflected in the backend.

Thanks in advance,

gopi

Former Member
0 Kudos

Hi

Try this

call the execute method first

wdThis.wdGetPricingGrpCompController().execute_RFC();

wdContext.nodeIt_Prcgprdg().invalidate();

int Size = wdContext.nodeEt_Prodgrp_out().size();

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

{

int lead = wdContext.nodeEt_Prodgrp_out().getLeadSelection();

prod.setZchngusr(Username);

prod.setZprodgrp(wdContext.nodeEt_Prodgrp_out().getEt_Prodgrp_outElementAt(lead).getZprodgrp());

prod.setZprigrp(wdContext.nodeEt_Pricegrp_out().getEt_Pricegrp_outElementAt(lead1).getZprigrp());

wdContext.nodeIt_Prcgprdg().addElement(prod);

}

see this thread

/message/2187817#2187817 [original link is broken]

Kind Regards

Mukesh

Former Member
0 Kudos

hi mukesh,

the data is already displayed in the table. the selected rows from the table should be updated in the backend and reflect in the other table. this code is executed in onActionADD method.

Thanks in advance,

Gopi

Former Member
0 Kudos

Post the context structure (including the attributes) of your RFC. Then it becomes easy for us to help you.