cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Table as Input to Model RFC?

Former Member
0 Kudos

hi @,

I have a RFC which needs input table. I have data populated in another node.How to pass the data directly from Node to Model input table as this input table doesn't have any method like .add or so.

My RFC struct is like this --

Z_A havning struc

-


strucZ_B having ele

-


1

-


2

-


3

I have to loop at the available niode and populate but in the add method for the RFC context I am getting method with model as input .

Regards,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Private<name>View.I<value node name >Node node = wdContext.node<value node name >();

Private<name>View.I<value node name>Element ele;

<your rfc name> input = new <your rfc name>(); // your rfc name

wdContext.node<your rfc name>().bind(input); // bind

<table name> inputTable;

for (int i=0; i < node.size(); i++ ) // value node - where data is available

{

inputTable= new <table name>();

ele = node.get<value node>ElementAt(i);

inputTable.set<Attribute>(ele.get<Attribute>());

......

input.add<table name>();

}

// execute rfc.

Former Member
0 Kudos

Hi @,

Thanks for yr replies I have incorporated similar way in my code also. Now is it essential to add the table to RFC and then bind and execute or we can bind the rfc in wdDOInit and then in the execute method populate the table and add it to the object and execute.

REgards

Former Member
0 Kudos

Hi,

<your rfc name> input = new <your rfc name>(); // your rfc name

wdContext.node<your rfc name>().bind(input); // bind

input.add<table name>();

needed.

Former Member
0 Kudos

hi Ramesh,

Thnks for yr prompt reply My Doubt is not in the approach but normally we bind the RFC in wdDoinit and In this case i have to add the table also so I think i will have to do the whole process in custom method and perform both binding and add ing table and then execute the method.

Regards

Former Member
0 Kudos

HI Ramesh,

I have included the whole approach starting from creating RFC object, binding and adding table and then executing the same in one method and called tht and its working fine dont know whether the approach is correct or not but again this query is resolved points awarded

Regards

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

It depends on the context structure you are using. Is the input table of the RFC having the same structure as your table node?

passing a table to RFC you write these code :

. so value node to model node.

1.create an instance of the Input class;

<BAPI_name>_Input input = new <BAPI_name>_Input ()

TAB table;

IPrivate<view>.I<table_node>Element elmt;

for(int i=0;i<wdContext.node<table_node>().size();i++)

{

table = new TAB();

elmt = wdContext.node<table_node>).get<table_node>ElementAt(i);

table.set<property1>(elmt.get<corresponding property1>);

.

.

table.set<propertyN>(elmt.get<corresponding propertyN););

input.add<MyTable>(table);

}

wdcontext.node<BAPI_name>_Input().bind(input);

Now execute the BAPI using the following line

wdContext.current<BAPI_Name>_InputElement().modelObject().execute();

wdContext.nodeOutput.invalidate()

// clears the old value in the output node

hope it will help u.

former_member197348
Active Contributor
0 Kudos

Hi,

If both are model nodes, you can use

WDCopyService.copyCorresponding(sourcenode, targetnode);
WDCopyService.copyElements(sourcenode, targetnode);

or else you need to use loop on the node like

Private<name>View.I<modelnode>Element  ele; // RFC input node 
for (int i=0; i<Valuenode>.size(); i++ ) // value node - where data is available
{
ele.create<modelnode>Element();
ele.setXXX(wdContext.node<Valuenode>().get<Valuenode>ElementAt(i).getXXX());
..........

wdContext.node<modelnode>().addElement(ele);
}

Regards,

Siva

PradeepBondla
Active Contributor
0 Kudos

Hi,

Check this [THREAD|;

PradeeP