cancel
Showing results for 
Search instead for 
Did you mean: 

Change and Update values in a form via RFC

Former Member
0 Kudos

Dear Friends,

Here I am facing a scenerio in an application form. We have a Patient ID. On the base of this ID I have to display the details of patient in a form. But again if patient wants to change some details, he can do that in same form and after submitting the form values should be update in R/3.

I am able to display the values on the base of patient id by Display Rfc, but i dont know how to edit and update those fields.

kindly help me out.

thanks & regards

Nivedita

Accepted Solutions (1)

Accepted Solutions (1)

former_member185086
Active Contributor
0 Kudos

Hi Nivedita

Calling edit is same as you have done for create , code is same like create but with one unique attribute (as case for edit),I can give code for EJB section I have no idea rfc/bapi.

I explain : say a create part has 4 attribute ID,Name,Age,Address so at the time of creation u have to fill all these 4 value and call the create bapi.Same edit part will have 4 attribute since ID is unique so you will able to fill only 3 attribute, Based on your Id it will update the remaning details.(general database concept)

Hope its clear now?

Best Regards

Satish Kumar

Former Member
0 Kudos

Dear Satish,

Yes your concept is absolutely right. But in case of RFC, first I am displaying the values as per my patient ID in a form. for that purpose i have to map output parameters of RFC to my Form's field. Now same values I have to edit and for that purpose we have diff Edit Rfc.

Now how will i do this. Like for a form i have fiields to be display eg name , age and address. these fields are displayed according to patient id. and Form's field are mapped with Display RFC's output parameter. Now when i click on edit button, field should be in editable mode and Edit Rfc will be called. Here at this point I dont knw the solution. I cant map those fields with 2 diff rfcs.

Kindly help me out

Thanks & Regards

Nivedita

Former Member
0 Kudos

Dear Satish ,

Can u send me some sample code?

former_member214651
Active Contributor
0 Kudos

Hi Nivedita,

To make a field editable or non-editable, try using the Readonly option through the code, else how do you switch from one RFC to another without any notice,

Or do this way if u r using 2 RFC's for display and Edit, Provide a Button called Edit, Once the user clicks on the button and makes the changes, use these values and execute the Edit RFC.

Regards,

Poojith MV

Former Member
0 Kudos

Dear Poojith,

Exactly I want to do the same. I know what i have to do, but m not clear how to do.

Like my fields are mapped with Dispaly Rfc now hw will they identify the Edit Rfc after clicking on button Edit.

I need some code sample to understand this..

Eg- in Edit View, m doing something like this on Edit Button Action:

if (wdContext.currentPatientIdElement().getPatientid() != null)

{wdContext.currentZedit_Coun_InputElement().setPat_Id(wdContext.currentPatientIdElement().getPatientid());

wdContext.currentPatientIdElement().setPatientid("");

} else {wdComponentAPI.getMessageManager().reportSuccess("No Records Found"); }

Zpa_Counsel1 obj = new Zpa_Counsel1();

Zedit_Coun_Input xyz = wdContext.currentZedit_Coun_InputElement().modelObject();

Zedit_Coun_InputNode crnode = wdContext.nodeZedit_Coun_Input();

Zedit_Coun_InputElement crele;

obj.setZanna1(wdContext.currentZedit_Coun_InputElement().getZanna1());

wdContext.currentZedit_Coun_InputElement().setZanna1("");

xyz.addZpat_Detail(obj);

wdThis.wdGetEditndisplayController().executeZedit_couns();

but it is not working at all

Thanks & Regards

Nivedita

gill367
Active Contributor
0 Kudos

Hello nivedita,

Its very simple. you add one button to the form with name edit.

On click of edit you can make the fields property readonly to false.

and one more button named submit to submit the details to the backend.

and also instead of directly mapping the fields to the bapi use a third node and mapp all the fields to it.

and then on execution of display rfc put the output values of this bapi to the context node mapped to the fields.

on click of submit after editing the info. map the context node to the input parameters of the edit rfc and execute the rfc.

Still if you face any problem let me know.

thanks and regards,

Sarb

Former Member
0 Kudos

Dear Sarb,

Thanks for your inputs. I did as u suggested. But while deploying my program, Deployement Aborted is showing.

public void onActionsubmit(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionsubmit(ServerEvent)

if (wdContext.currentPatientIdElement().getPatientId() != null)

{wdContext.currentZpat_Couns_InputElement().setPa_Id(wdContext.currentPatientIdElement().getPatientId());

wdContext.currentPatientIdElement().setPatientId("");

} else {

wdComponentAPI.getMessageManager().reportSuccess("No Records Found"); }

wdThis.wdGetEditdisplayController().executeZpat_Couns();

//@@end

}

//@@begin javadoc:onActionEdit(ServerEvent)

/** Declared validating event handler. */

//@@end

public void onActionEdit(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionEdit(ServerEvent)

Zpa_Counsel1 obj = new Zpa_Counsel1();

Zedit_Coun_Input xyz = wdContext.currentZedit_Coun_InputElement().modelObject();

IZedit_Coun_InputNode crnode = wdContext.nodeZedit_Coun_Input();

IZedit_Coun_InputElement crele;

obj.setZberuf(wdContext.currentContextElement().getZberuf());

obj.setZbhist(wdContext.currentContextElement().getZbhist());

obj.setZbland(wdContext.currentContextElement().getZbland());

obj.setZbpl(wdContext.currentContextElement().getZbpl());

obj.setZdall(wdContext.currentContextElement().getZdall());

obj.setZdiet(wdContext.currentContextElement().getZdiet());

obj.setZdrink(wdContext.currentContextElement().getZdrink());

xyz.addZpat_Detail(obj);

wdThis.wdGetEditdisplayController().executeZedit_couns();

//@@end

}

and my Context of view is like this now

+Context

....+Zedit

....+Zdisplay

....+PatientId

.......++patientid

..........++zberuf (All editable parameters under root Context)

Kindly Suggest

Thanks & Regards

Nivedita

gill367
Active Contributor
0 Kudos

Hi

Could you please tell me what is the error that you are getting while deploying

Thanks

Former Member
0 Kudos

Dear Sarb,

I am getting this error:

Result

=> deployment aborted : file:/E:/DOCUME1/rama/LOCALS1/Temp/temp59868editDisplay.ear

Aborted: development component 'editDisplay'/'local'/'LOKAL'/'0.2009.10.12.16.57.14'/'0':

Caught exception during application deployment from SAP J2EE Engine's deploy service:

java.rmi.RemoteException: Cannot deploy application local/editDisplay.. Reason: Clusterwide exception: Failed to deploy application local/editDisplay. Check causing exception for details (trace file). Hint: Are all referenced components deployed and available on the engine?; nested exception is: com.sap.engine.services.deploy.container.DeploymentException: Clusterwide exception: Failed to deploy application local/editDisplay. Check causing exception for details (trace file). Hint: Are all referenced components deployed and available on the engine?

I checked the log file also, but nothing explained there also.

I have one more confusion.

As i have to display values as per my patient id, now I am binding input fields with manually created fields for display as well as edit. So while executing the display Rfc, i have to get the parameters or not. as simply I am executing like:

public void executeZpat_Couns( )

{

//@@begin executeZpat_Couns()

try{wdContext.currentZpat_Couns_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

} catch(WDDynamicRFCExecuteException ex) {

wdComponentAPI.getMessageManager().reportException("Error: "+ex.getMessage(),true);

}

//@@end

}

Thanks & Regards

Nivedita

gill367
Active Contributor
0 Kudos

Dear Nivedita,

For this exception, try to repair the project structure and classpath.

right click on the project name in web dynpro explorer and go to reapir --> project structure and classpath

I hope this should work otherwise you may need to create the project again.

and for the second question

yeah you need to get the values after executing the DIsplay rfc.

regards,

Sarb

Former Member
0 Kudos

Dear Sarb,

Kindly tell me how will i get th values via code? Where should i right the code, means in Submit methode or execute method?

And I repaired the project but still it is not deploying.So making the new one.

Kindly tell me how will i get values for display.

Thanks & Regards

Nivedita

gill367
Active Contributor
0 Kudos

Dear Nivedita

You can write the code in the submit method after calling the execute method.

you just need to fetch the details from the ouptu parameters of the disaply bapi and set the context node used for display 's attributes by using these output parameters.

reagrds,

sarb

Former Member
0 Kudos

Dear Sarb,

Thanks for ur suggetions, will give u max pts.

Now my Display part is running perfectly and i created the edit part also. I am getting the values from manually created Node (now this node has values from display rfc) and setting those values in Structure's object.

when i do this in seprate project its working fine, bt here it is note updating. I feel in a single model , m using 2 RFCs. is this the reason or something else??

Thanks & Regards

Nivedita

gill367
Active Contributor
0 Kudos

Hi Nivedita,

This should not be the reason.

You check whether you are passing all the values properly and are you executing the RFC after filling the details in the structure.

regards,

Sarb

Former Member
0 Kudos

Dear Sarb,

I created two diff models for each RFC in a single project after that its working fine.

I hav to do some more functionality in this project. So i'll bother you again.

  • Can I have your personal mail id for future perspective if you dont mind?

note- max pts given

Thanks & Regards

Nivedita

gill367
Active Contributor
0 Kudos

sorry can't write the id here. Its against SDN Rules.

you can check my id in my profile.

regards,

Former Member
0 Kudos

Dear Sarb,

As I informed you earlier that I have to add some more functionalities in my application so here I am. Now in my Form I have to add F4 help for some input fields. I dont knw really , how can i do this. I feel I should use OVS for that purpose but again I am not aware with the procedure.

Kindly Help me out.

Thanks & Regards

Nivedita

Answers (2)

Answers (2)

Former Member
0 Kudos
former_member185086
Active Contributor
0 Kudos

Hi

For Edit/Update you have to call seperate rfc (or discussed it with person who wrote this rfc).

Best Regards

Satish Kumar

Former Member
0 Kudos

Dear Satish,

Yes i know , that i have to use diff Rfc for that purpose. But how will i do this, what will be the code, .. i am blank in that case. if you can provide some sample code or something then i can have idea.

so kindly suggest me in detail.

thanks & regards

Nivedita