cancel
Showing results for 
Search instead for 
Did you mean: 

Pass table data to RFC

Former Member
0 Kudos

Hello Everyone,

I have a difficulty to pass a table data to a RFC. here is my main code lines:

Zrfc_Input rfcInput = new Zrfc_Input();

wdContext.nodeZrfc_Input().bind(rfcInput);

// some code lines to fill table data in model node and display model node data successfully

.....................

wdContext.currentZrfc_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

I use above to retrieve the table data without problem, but have trouble to pass tabel data to RFC (then save data). Do I miss some code statements? Any advices / suggestions?

Thanks, Jin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Traverse the contents of the value node and pass the values to the the table to the function module

Regards

Saravanan K

Former Member
0 Kudos

Thanks Saravanan for your quick reply. I did that and also display model node data successfully.

Any advices / suggestions with sample code are appreciated.

Thanks, Jin

Answers (1)

Answers (1)

former_member214651
Active Contributor
0 Kudos

Hi,

Follow these steps to send the table data to RFC:

1. Get the value from the Model Node.

2. Copy the values toValue Node

3. Set the values to the Model Node using the values of Value Node:

Zrfc_Input rfcInput = new Zrfc_Input();
wdContext.nodeZrfc_Input().bind(rfcInput);

// Create the instance of the structure which needs to be sent to RFC
for(int i = 0; i < <valuenodesize>; i++)
{
     //create an instance of the model node structure
     <structurename> structname = new <structurename>();
     structname.set<attribute>(<vakuenodeelement>At(i).get<attribute>);
     <structireme>.add(structname);
}.
wdContext.currentZrfc_InputElement().set<structurename>(<structireme>);
wdContext.currentZrfc_InputElement().modelObject().execute();
wdContext.nodeOutput().invalidate();

Hope this helps you

Regards,

Poojith MV

Former Member
0 Kudos

Hi Poojith,

Thank you very much for your help with detail steps / sample code. I have a trouble to use below statement: wdContext.currentZrfc_InputElement().set<structurename>(<structireme>);

I don't have set method for the structure, did I do something wrong?

I have this one: wdContext.currentZrfc_InputElement().modelObject.set<structurenameli>(<AbstractList st>);

but I don't know it's same or not and how to set AbstractList.

Any advice / suggestions?

Thanks, Jin

Former Member
0 Kudos

Hi

Can you please remove that trouble giving line code and test again.

Can you please give the complete coding?

Regards

Saravanan K

Former Member
0 Kudos

Hi Saravanan,

Sorry for my delay reply and thanks for you help. Here is my code lines:

****************************************************

Zrfc_Input objInput = new Zrfc_Input();

wdContext.nodeZrfc_Input ().bind(objInput );

Zbp_Wf_Determ tab1 = new Zbp_Wf_Determ();

// set 1 row test data in the table

tab1.setDivision("55");

tab1.setPhone("2100");

objInput.addT_Zbp_Wf_Determ(tab1);

// I can't find wdContext.currentZrfc_InputElement().set<structurename>(<structireme>),

wdContext.currentZrfc_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

**************************************************

T_Zbp_Wf_Determ Like ZBP_WF_DETERM is the Table parameter setting in RFM.

I can not find wdContext.currentZrfc_InputElement().set<structurename>(<structireme>),

I can find this one: wdContext.currentZrfc_InputElement().modelObject().setT_Zbp_Wf_Determ(abstractlist);

Any advices / suggestions?

Thanks, Jin

T_Zbp_Wf_Determ Like ZBP_WF_DETERM is the Table parameter setting in RFM

Former Member
0 Kudos

Hi,

After commenting that line are you getting the expected output? I understand, you did a correct steps.

Regards

Saravanan K

p330068
Active Contributor
0 Kudos

Hi Jin,

Please check the thread for initializing AbstractList

Hope it will helps

Regards

Arun Jaiswal

Former Member
0 Kudos

Thanks Saravanan and Arun for your help.

I followed Arun's link and added 2 more lines as below before .execute():

Zbp_Tool_Get_Determ_Output objOutput = new Zbp_Tool_Get_Determ_Output();

objOutput.addT_Zbp_Wf_Determ(tab1);

I still have the same problem: the table data not pass to RFM.

Any advices / suggestions?

Thanks, Jin

p330068
Active Contributor
0 Kudos

Hi Jin,

It should be Zbp_Tool_Get_Determ_Input object not "Zbp_Tool_Get_Determ_Output". Please make check change and try again will help to resolved the issue.

Regards

Arun Jaiswal

Former Member
0 Kudos

Thanks Arun for your quick reply.

Actually I did for Input before, I have the same problem.

Any advices?

Thanks alot, Jin

p330068
Active Contributor
0 Kudos

Hi Jin,

Can you please post your code and try to print the values which you have set before the exceute statement.

Regards

Arun Jaiswal

Former Member
0 Kudos

Hi Arun,

Thanks for your help, here is the coding (T_Zbp_Wf_Determ Like ZBP_WF_DETERM is the Table parameter setting in RFM, ZBP_WF_DETERM is not a Structure is a Table, can it be a problem?)

****************************************************

Zrfc_Input objInput = new Zrfc_Input();

wdContext.nodeZrfc_Input ().bind(objInput );

Zbp_Wf_Determ tab1 = new Zbp_Wf_Determ();

// set 1 row test data in the table

tab1.setDivision("55");

tab1.setPhone("2100");

objInput.addT_Zbp_Wf_Determ(tab1);

// I try to display the value, but don't know how to, any code sample is appreciated.

for (int i = 0; i < objInput.getT_Zbp_Wf_Determ().size(); i++) {

wdComponentAPI.getMessageManager().reportWarning("Row" + i + objInput.getT_Zbp_Wf_Determ().get(i).toString());

}

// I can't find wdContext.currentZrfc_InputElement().set<structurename>(<structireme>),

wdContext.currentZrfc_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

**************************************************

Any advices / help?

Thanks, Jin.

Former Member
0 Kudos

Hello Jin,

As you are saying that set method is showing an error in your code might be you didnt mapped the corresponding tabble node to the controller where you are writing the code.

Please check that.

Thanks,

Raju Bonagiri

Former Member
0 Kudos

Hi Raju,

Thanks for your help. The problem is that I don't have set<structurename>(<structireme>) method in wdContext.currentZrfc_InputElement() class object. I have this one: wdContext.currentZrfc_InputElement().modelObject().setT_Zbp_Wf_Determ(AbstractList); Also I checked the mapping and can't find any problem (simply drag).

Maybe in RFM I use a table type to define the Table parameter not a structure is the probjem?

Any advices?

Thanks, Jin

p330068
Active Contributor
0 Kudos

Hi Jin,

Your code looks good. you can also try with last statement and use it in try, catch and finally block.


//Executing Model
objInput.execute();
wdContext.nodeOutput().invalidate();

Also use the [Logging and Tracing in Web Dynpro |http://wiki.sdn.sap.com/wiki/display/WDJava/LoggingandTracinginWeb+Dynpro] AND /people/jacek.wozniczak/blog/2010/02/05/logging-in-web-dynpro-java--a-guide-and-tutorial-for-beginners-part-1

Refer to [Linking Remote Function Call to Web Dynpro|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/761eba66-0401-0010-b982-d5f5bd9e8f90]

Hope it will helps to resolved your issue.

Regards

Arun Jaiswal

former_member185879
Active Contributor
0 Kudos

Hello,

1. Please check the mapping between the model and component controller.

2. check the cardinality of tha particular node

3. your snippet will definitely work if the above two is right.

Regards

Nizamudeen SM

Former Member
0 Kudos

Thanks Arun and Nizamudeen both very much for your help, the links are very helpful.

I checked again, the mapping looks good and the node cardinality is 0... n.

by the way, no problem to pass input parameters and retrieve the table data from RFC, the problem is send table data back to RFM.

Any advices?

Thanks, Jin

former_member214651
Active Contributor
0 Kudos

Hi,

First check with the ABAP team as to which is the Input structure which needs to be sent to the RFM. Once you know the name of the structure, u can create an instance of the input structure and set the values and add it to the list and send it back to RFM.

If possible, kindly send the hierarchy of the RFM imported in WDJ model which you are trying to send a table.

Regards,

Poojith MV

Former Member
0 Kudos

Hi Poojith, thank you for your help.

Here is RFM setting forTable: T_Zbp_Wf_Determ Like ZBP_WF_DETERM (ZBP_WF_DETERM is not a Structure is a Table).

Here is the Model hierarchy looks like:

Zrfc_Input

Output (Zrfc_Output)

Zrfc_Output

T_Zbp_Wf_Determ (ZBP_WF_DETERM)

Zbp_Wf_Determ

T_Zbp_Wf_Determ (ZBP_WF_DETERM)

Zbp_Wf_Determ

I use table T_Zbp_Wf_Determ for import and export both directions. My guess it maybe the problem. I will create another RFM or add another table in same RFM to see if the table data can be passed back to RFM.

Any advices?

Thanks, Jin

former_member214651
Active Contributor
0 Kudos

Hi,

Tables are bi-directional parameters which can be used for both importing and exporting data. so that should not be the problem. try this piece of code to send the values:

//get the size of the value node
int size = wdContext().node<valuenodename>().size();

//loop to get everyrecord
for(int i = 0; i < size; i++
{
    I<valuenodename>Element objValueNode = wdContext().node<valuenodename>().get<valuenodename>ElementAt(i);
    Zbp_Wf_Determ objZbp_Wf_Determ = new Zbp_Wf_Determ();
    objZbp_Wf_Determ.set<attributename>(objValueNode.get<attaribute>());
    wdContext().currentZrfc_Input().nodeT_Zbp_Wf_Determ().add(objZbp_Wf_Determ);
}
//execute the RFM

Hope this helps you

Regards,

Poojith MV

Former Member
0 Kudos

Hi Poojith,

Very sorry for my late reply and thanks again for your help and code sample. You're very right bi-directional table can be used for both importing and exporting data and my dummy test (add another table) got the same result.

One thing I am sure is that the data is in model node T_Zbp_Wf_Determ, but the problem is the data is not passed to RFM's table.

Let me create new thread, so that I can give more points (I feel bad about you all give me so much help but I can't give back anything).

Thank you all very much for all your time and help, I learnt so much from all of you.

Thanks again, Jin