cancel
Showing results for 
Search instead for 
Did you mean: 

Execution RFC Update Function Module

Former Member
0 Kudos

Hi everyone, I get problem when i want to update data in SAP.

I get this exception "com.sap.tc.webdynpro.modelimpl.dynamicrfc.WDDynamicRFCExecuteException"

This is the action i try to know what cause this problem :

1. I have test the Function Module and it's work well in SAP.

2. I have check JCo destination and it's work well too.

so I confused T_T

This is what i want. I have 3 view and each view have button to update. So when i click one of this button,data from all 3 view will be updated into SAP. So I think, I must set input data in my custom controller (not in view).

This is my Custom Controller Context

- Context (Root)

- UpdateAppraisalsDetail (model node)

---OutputUpdateAppraisal (model node)

---P_Input_Competency (model node) --> Table in FM

---P_Input_Evi_Perform (model node) --> Table in FM

---P_Input_Key_Acc (model node) --> Table in FM

---Begda (value attribute)

---Endda (value attribute)

---Pernr (value attribute)

---... (import in FM)

- TableCompetencyCore (valuenode)

- TableCompetencyJobFamily (valuenode)

- TableCompetencyManagerial (valuenode)

The Code

public void wdDoInit()

{

// Update Appraisal Detail

Zhr_Pms_Update_Apprsal_Details_Input updateAppraisalInput = new Zhr_Pms_Update_Apprsal_Details_Input();

wdContext.nodeUpdateAppraisalsDetail().bind(updateAppraisalInput);

}

public void executeZhr_Pms_Update_Apprsal_Details()

{

UpdateAppraisalsDetail model = (UpdateAppraisalsDetail)WDModelFactory.getModelInstance(UpdateAppraisalsDetail.class);

IPublicCore.IP_Input_Key_AcctElement keyAccElement = null;

if (condition 1)

{

keyAccElement = wdContext.nodeP_Input_Key_Acct().createP_Input_Key_AcctElement(new Zhr_Pms_Key_Acct());

keyAccElement.setXXX("01")

keyAccElement.setYYY(....)

....

wdContext.nodeP_Input_Key_Acct.addElement(keyAccElement);

}

if (condition 2)

{

keyAccElement = wdContext.nodeP_Input_Key_Acct().createP_Input_Key_AcctElement(new Zhr_Pms_Key_Acct());

keyAccElement.setXXX("02")

keyAccElement.setYYY(....)

....

wdContext.nodeP_Input_Key_Acct.addElement(keyAccElement);

}

IPublicCore.ITableCompetencyCoreElement coreElement = null;

IPublicCore.IP_Input_CompetencyElement competencyElement = null;

for(int i = 0; i < wdContext.nodeTableCompetencyCore().size();i++)

{

coreElement = wdContext.nodeTableCompetencyCore().getTableCompetencyCoreElementAt(i);

competencyElement = wdContext.nodeP_Input_Competency().createP_Input_CompetencyElement(new Zhr_Pms_Comp());

competencyElement.setXXX (coreElement.getXXX(..))

competncyElement.setYYY(coreElement.getYYY(...))

wdContext.nodeP_Input_Competency().addElement(competencyElement);

}

IPublicCore.ITableCompetencyManagerialElement managerialElement = null;

for(int i = 0; i < wdContext.nodeTableCompetencyManagerial().size() ; i++)

{

//same logic with core Element

....

wdContext.nodeP_Input_Competency().addElement(competencyElement);

}

IPublicCore.IP_Input_Evi_PerformElement evidenceElement = null;

// Mid Year Evidence

evidenceElement = wdContext.nodeP_Input_Evi_Perform().createP_Input_Evi_PerformElement(new Zhr_Pms_Evp());

evidenceElement.setSubty("EVMY");

evidenceElement.setDescr(wdContext.currentContextElement().getMidEvidence());

wdContext.nodeP_Input_Evi_Perform().addElement(evidenceElement);

// Other Data

wdContext.currentUpdateAppraisalsDetailElement().setPernr(wdContext.currentContextElement().getEmployeeNumber());

wdContext.currentUpdateAppraisalsDetailElement().setPhase(wdContext.currentContextElement().getPhase());

....

try

{

wdContext.currentUpdateAppraisalsDetailElement().modelObject().execute();

wdContext.nodeOutputUpdateAppraisal().invalidate();

}

catch(WDDynamicRFCExecuteException e)

{

logger.traceThrowableT( Severity.ERROR, "executeZhr_Pms_Update_Apprsal_Details( )", "ERROR", e );

model.disconnectIfAlive();

throw new FeedbackException( e );

}

model.disconnectIfAlive();

}

What in this code that make my execuion of rfc not success ? Thank you...

Accepted Solutions (1)

Accepted Solutions (1)

former_member189631
Active Contributor
0 Kudos

Hi Satria,

  • In some Occasions the data u updated might not be stored.

  • Some you need to do commit for the changes the made. (Similar to <b>commit Work</b> )

  • Its always a good practice to use BAPI_TRANSACTION_COMMIT When we update data.

Regards,

<b>Ramganesan K</b>

Former Member
0 Kudos

I have using BAPI_TRANSACTION_COMMIT, and still it display exception. Anyone can help me ? Thank you

Regards,

Satria

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi

can you post the exception, before that try out some things ,the only odd thing in your code is about binding of the nodes which are tables in r3, for them some different approach need to be followed,

for passing table we need to create the abstract list for the table node, like as,

Bapiparnr.Bapiparnr_List PartnerList = new Bapiparnr.Bapiparnr_List(); 
Bapiparnr Partner = new Bapiparnr();
Partner.setPartn_Numb(PartnerNumber);
Partner.setPartn_Role("AG");
PartnerList.addBapiparnr(Partner);
SO.setOrder_Partners(PartnerList);

//SO is the instance of models input class
//Order_Partners is the model class name of structure Bapiparnr
//Bapiparnr is a model node with table structure in r3

also check the thread for the same, i think this will solve your problem.

https://forums.sdn.sap.com/click.jspa?searchID=2474404&messageID=3302674

if the exception is not coming then there are some other things to be checked ,

just let me know if you face any problem

regards

Message was edited by:

Abhijeet

Former Member
0 Kudos

Satria,

Let us add a grain of clarity to the discussion: please post exception stack trace (with nested exceptions if any).

VS

Former Member
0 Kudos

Hi Abhijeet,

Thank you for your answer. It not raise any exception again but the funny is the data is not changed. Can you give me some reason why this happened ? I try using BAPI_TRANSACTION_COMMIT, but still not changed

For Valery,

Thank you for your suggestion, I comment my try{}catch{}, and i find something that make help me disappear this exception

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi,

If such thing happens, then try evaluating any of following possibilities:

1) Through external debugging check out if proper values are being sent to backend or not(for external debugging goto transaction code se37, open your bapi->goto Utilities->Setting->Debugging->Here check if "Act" check box is activated or not), then put a break point in code and run application from WD.

2) If proper values are sent to backend then check in backend that all required data is being passed or not. Or because of some missing field backend is not updating the data.

3) In worst case it may happen that, backend itself is throwing some exception and it is not being caught.

4)If backend is returning something then check out the size of Output node in WD.

regards

Answers (2)

Answers (2)

balaji_bodagala5
Participant
0 Kudos

Hi,

create UpdateAppraisalsDetail and Transaction Bapi into <b>Single Model</b>,

write this code where your going to call that means some events on that method

Zhr_Pms_Update_Apprsal_Details_Input updateAppraisalInput = new Zhr_Pms_Update_Apprsal_Details_Input();

Bapi_Transaction_Commit_Input commitInput = new Bapi_Transaction_Commit_Input();

updateAppraisalInput.setxx();

// set all the intial values ......

commitInput.setWait(true);

bind the UpdateAppraisalsDetail object

bind the BapiTransaction also,

try{

wdContext.currentUpdateAppraisalsDetailElement().modelObject().execute();

wdContext.nodeOutputUpdateAppraisal().invalidate();

wdContext.currentBapi_Transaction_Commit_InputElement().modelObject().execute();

wdContext.nodeTransactionCommitOutput().invalidate();

UpdateAppraisalsDetail detail =(UpdateAppraisalsDetail)WDModelFactory.getModelInstance(UpdateAppraisalsDetail.class)

detail.disconnectIfAlive();

}

catch(WDDynamicRFCExecuteException e){}

Thanks,

Balaji

former_member189631
Active Contributor
0 Kudos

Hi Satria,

  • Please check your RFC, Binding and Mapping.

  • I suggest you to Bind and Map the return node of your BAPI.

  • Use BAPI_TRANSACTION_COMMIT in your model.

Regards,

<b>Ramganesan K</b>

Former Member
0 Kudos

Hi Ramganesan,

So basically the BAPI "BAPI_TRANSACTION_COMMIT" <b>always</b> must i call after update data ? Thank you.

Regards,

Satria B