on 07-15-2005 10:32 AM
hi
i want to explore SAPproxy class genereated by VS (.net connector). i want to list registered function in this SAPproxy class in program (C#). Is this possible?
thank you!
palo
Hi Pavol
> i want to explore SAPproxy class genereated by VS
> (.net connector).
By "explore" if you mean that you want to explore the class definition in the SAP proxy CS file then -
1. click "Show All files" in the solution explorer in VS.net
2. Expand the tree node besides the SAPproxy.sapwsdl file. The SAPproxy.cs would be listed under the sapwsdl file.
3. Double click it. The designer window would be shown. Now click on the link "Click here to switch to code view" in the designer window. You will now see the CS code for the SAPproxy file.
In your C# source code, create an object of the SAPproxy class and call methods on the SAPproxy.
VS.net would auto-list methods and members of the SAPproxy class in the same way as it would do for any other classes available in the .net framework.
I hope this helps....
Cheers
Gaurav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i know all of this.
but i dont want to explore this class members in designer, i want to explore it from my own program interface.
i call this functions from abstract layer, that mean : i dont want to know names of registered functions, i want to call it dynamicly from user interface.
The idea is that i have abstract user interface to bapi call, and if i change SAPproxy.dll -> by new SAPproxy.dll with new function i want to call it from my user interface:)
Hi Pavol
You can use the following code snippet to call a RFM/BOR dynamically.
Basically, the code uses reflection to get the type for the SAPProxy and then it displays all the methods available in the type. Then
it gets the method which you want to invoke (I'm accepting the method name from a textbox on the form). And finally, it invokes the method and passes the parameters for the method.
private void button4_Click(object sender, System.EventArgs e)
{
/// Create the SAP proxy and set the connection
SAPProxy2 sapproxy2 = new SAPProxy2();
sapproxy2.ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["DBConnection"].ToString();
sapproxy2.Connection.Open();
/// Display all the methods in the type
string methodlist = "";
Type type = sapproxy2.GetType();
foreach(MethodInfo methodinfo in type.GetMethods())
{
methodlist = methodlist.ToString() + "n" + methodinfo.Name.ToString();
}
MessageBox.Show(methodlist.ToString());
/// Now invoke the member on the fly
MessageBox.Show("Now invoking the member.n Sit back n njoy.");
if (textBox1.Text != "")
{
///Get the method to be invoked
MethodInfo mymethod = type.GetMethod(textBox1.Text);
if (mymethod != null)
{
object [] oarr = new object[]{new byte[1]};
//Invoke the BOR/RFM
mymethod.Invoke(sapproxy2, oarr);
}
else
{
MessageBox.Show ("Method not found");
}
}
}
I have tested the code using the commonly available RFM "System_Uuid_Create" which returns a byte array as the output. You can also retrieve the parameter information using reflection and remove the need to mention the parameter type, if required.
Please let me know if I can be of any more help.
Cheers
Gaurav
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.