cancel
Showing results for 
Search instead for 
Did you mean: 

Calling FM in SAP

Former Member
0 Kudos

I have a requirement wherein i need to pass a user input value to a FM created in ABAP.

Based on that i need to display the results or display a message if no results found.

Can any of the forum member supply me with the code/documentation which can help me achieve this?

I have already gone thru the basic webdnpro tutortial for calling rfc's.

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

vmadhuvarshi_
Contributor
0 Kudos

Stride,

This should be fairly easy for you after going through[ this tutorial|/docs/DOC-8061#15]. You can download the ready to use project to learn from actual coding.

Hope this helps.

Vishwas.

Former Member
0 Kudos

Thanks .

I did try the example.I am able to compile and deploy the project.

I do see the webdynpro screen with an empty grid.

When i click search it seems the application is not able to get the value from SAP.

How can i know if the FM is getting called on the SAP side?

vmadhuvarshi_
Contributor
0 Kudos

There are a few ways to check this.

If you have authorization in ABAP side, there are transactions to check the RFC Error Log (SM58) and User RFC monitor (SWU1), I think one of them should be helpful to you but check with your BASIS people to help you out with this - double check on TCodes too as I used them way back.

There is another possibility that your Component Context or View Context is not maintained properly and that might be the reason for data not showing up in WD application. This would mean that RFC is being called properly but data is not being displayed in WD side. What is the cardinality of node to which data is being returned? If this is 0..N, change this to 1..N and then check again.

If you can provide me more information about your Component / DC structure, I may be able to help you better.

Vishwas.

Answers (4)

Answers (4)

Former Member
0 Kudos

Stride,

This online demo explains very clearly what you are looking for :

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b017bd92-320d-2b10-81ae-ac921eff...

Some More:

Already SDN friends provided some information , jsut i am trying to share some info and it might be helpful.

Step1: Once you know which function module your going to use , make sure that Funcation module is working in expected way. Ex: what are the input parameters you suppose to give , is returning the expected results are not? if there is no results found in the backend table what kind of error message it should throw?

These things you can perform while logging on to the SAP Backend System and use the TCODE : SE37 , enter the FM name and display. Once you open the required function module provide the expected input parameters and Execute it.

Now we expected to see the results if the data is avaialable if not you will see the appropriate error message or some other message based on the program developed.

Step2: From the NWDS Import the model while importing the model you required to provide the appropriate backend system details to call the RFC.

Step 3: Say example , when the user selects Results button on view then it should return the results in a table. The Results Button event calls the appropriate methos from the controller.

in View controller under Results action event you call the methos from the controller as below:


public void onActionResults(com.sap.xxx.webdynpro.progmodel.api.IWDCustomEvent wdEvent){

    //@@begin onActionResults(ServerEvent)
    wdThis.wdGetCOMPNAMEController().getRsults();
    //@@end
  
}

Step 4: Now in the component controller create a method called getresults() and execute your function module as below shown:



public void getResults{

//Initializing The RFC model class
Zs_results_volume_Input input = new Zs_results_volume_Input();

//if the RFC expect any manadatory parameters you have to set them before excuting the function module, normally most of the rfc'S expect input
parameters as Userid, Role, laungauge as input parameters.

// set user id which is retrived from the portal frame work in the runtime
input.setUser(WDClientUser.getCurrentUser().getSAPUser().getUserAccounts()[0].getLogonUid().toUpperCase());
//if you want to send launguage also as a mandatory parameter you can
input.setLanguage("EN");

//after settting the values bind the input object

wdContext.nodeAllowedValues().bind(input);


//if RFC execution is done from some different method
wdThis.executeZs_Results_Volume();
}


//implementation of the executeZs_Results_Volume() method:




public void executeZs_Results_Volume()
  {
    //@@begin executeZs_Results_Volume()
    
	try 
		{
			// Calls remote function module Zs_results_volume_Input
			wdContext.currentZs_results_Volume_InputElement().modelObject().execute();

			// Synchronise the data in the context with the data in the model
			wdContext.nodeOuput_Results_Vol().invalidate(); 
		}
		catch (Exception ex) 
		{
			// If an exception is thrown, then the stack trace will be printed
			wdComponentAPI.getMessageManager().reportException("Error while executing RFC: Zs_results_volume_Input Details : " + ex.getMessage(), true);
		}        
    
   //@@end
  }

For mor help:

Creating a Web Dynpro Application Accessing ABAP Functions

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/355b9c90-0201-0010-d2a8-89fece42...

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b017bd92-320d-2b10-81ae-ac921eff...

http://help.sap.com/saphelp_nw04s/helpdata/en/15/0d4f21c17c8044af4868130e9fea07/frameset.htm

tps://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e07753b9-fa0c-2a10-64a8-c6754c45396e

Former Member
0 Kudos

Hi Stride,

You can go thriugh the following link for some documents in adaptive rfc call.

https://www.sdn.sap.com/irj/sdn/nw-wdjava?rid=/webcontent/uuid/403e6bf5-426e-2910-b0a8-a95548724af9

Hope this link is useful.

Thanks,

Uvendu.

former_member254270
Participant
0 Kudos

Hi Stride,

Once check whether ur RFC is working or not by going to SE37 and testing it.If it works then u follow the same steps keenly which gives u the correct result.

Follow this link if ur RFC works fine.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a00f7103-6790-2a10-ac9c-fcac7c5b...

Thanks.

lokesh_kamana
Active Contributor
0 Kudos

Hi,

I had a demo video for this.If you want that i will send you.It will help you.Send me ur mail Id.

Thanks & Regards,

Lokesh.