cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate table in RFC

Former Member
0 Kudos

How do I populate an abstractlist that is an input to an RFC? I read the post by Bertram Ganz, but my generated classes look different. I imported the RFC and the system generated the following:


-zbapi_appraisal_create
  -zbapi_appraisal_create_input
    -appraisees (bapiappraisee)
      -bapiappraisee
        -fields...
    -output (zbapi_appraisal_create_output)
      -same as output node below
    -appraiser_id
    -rest of input parameters...
  -zbapi_appraisal_create_output
...etc.

I have no problem setting the regular input parms, but how do I set the table? I tried the following, but I get a ClassCastException on the call to setAppraisees().

Zbapi_Appraisal_Create_Input input = new Zbapi_Appraisal_Create_Input();
wdContext.nodeZbapi_Appraisal_Create().bind(input);
input.setAppraisal_Model_Id(appraisalModelId);
input.setStart_Date(startDate);
input.setText(description);
input.setCreation_Date(appraisalDate);
input.setAppraiser_Id(appraiserId);
//static values
input.setPlan_Version("01");
input.setAnonymous(true);
input.setAppraiser_Type("P");
input.setAppraiser_Plan_Version("01");
//create appraisee
<b>Bapiappraisee obj = new Bapiappraisee();
obj.setPlan_Version("01");
obj.setType("P");
obj.setId(appraiseeId);
obj.setName(appraiseeName);		
List myList = input.getAppraisees();
if (myList == null) myList = new ArrayList();
myList.add(obj);
input.setAppraisees((AbstractList)myList);</b>
wdContext.currentZbapi_Appraisal_CreateElement().modelObject().execute();
wdContext.nodeOutput().invalidate();

Any input is greatly appreciated!!

John<b></b>

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi,

If input is declared and binded in custom controller then use following method to get object for Bapiappraisee -

wdThis.wdGetCustomControllerName()

.wdGetContext()

.zbapi_appraisal_create_inputElement()

.<b>modelObject()</b>.

There will be method like <b>input.addBapiappraiseeList()</b>.Use this method for adding inner nodes.

Also please check the binding for Bapiappraisee as zbapi_appraisal_create_input -> bapiappraisee

former_member182372
Active Contributor
0 Kudos

Hi John

Check

Best regards, Maksim Rashchynksi.

Former Member
0 Kudos

Thanks, Maksim. The third link had code with an add method. I didn't see that one. I modified my code as follows:

//create appraisee
Bapiappraisee obj = new Bapiappraisee();
obj.setPlan_Version("01");
obj.setType("P");
obj.setId(appraiseeId);
obj.setName(appraiseeName);		
<b>input.addAppraisees(obj);</b>
wdContext.currentZZBapi_Appraisal_CreateElement().modelObject().execute();
wdContext.nodeOutput().invalidate();

My code compiles; however, when I run it with the debugger, I get the following exception when the execute method is called:

com.sap.tc.webdynpro.modelimpl.dynamicrfc.WDDynamicRFCExecuteException

The detailMessage node is null and I can drill down forever in the cause and exceptionInfo nodes and never see an exception message.

Any ideas?

Thanks,

John

former_member182372
Active Contributor
0 Kudos

John, what is <a href="https://media.sdn.sap.com/javadocs/NW04/SPS15/wd/com/sap/tc/webdynpro/modelimpl/dynamicrfc/WDDynamicRFCExecuteException.html">WDDynamicRFCExecuteException</a> saying?

Former Member
0 Kudos

I don't know. How do I find out? I drilled down the node hierarchy for the exception, but I can't find the message. The nodes are recursive and repeat the same information.

Very frustrating!

John

Former Member
0 Kudos

Please read a good manual prepared by Arun Bhat -

<a href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f3f93ee7-0c01-0010-2593-d7c28b5377c2">Adaptive RFC Troubleshooting Guide</a>

WDDynamicRFCException most likely comes in the following cases:

a) JCo is not setup properly

b) Your function module does not exist in R/3 system referred by your JCo

c) Your function module is not RFC enabled

d) DD_DOMA_GET is not RFC enabled

Also make sure you have got your cardinality settings for your model node in context controller proper.

If you have used a template approach, just check your wdDoInit method of your custom/component controller for code similar to the following:


wdContext.nodeBAPI_Input().bind(new BAPI_Input());

If you have the above code and the code that you have just pasted , just comment this code and try executing your application again.

Regards,

Subramanian V.

Message was edited by: Subramanian Venkateswaran

Former Member
0 Kudos

John,

Check output of WDDynamicRFCExecuteException ex.getMessage() (in debugger add this to "watches")

VS