Execute a Report with ERPConnect 
From Theobald Software
In this example an SAP report is executed with a custom function module. We retrieve the result of the report as a table and print it out on the console.
Create Z-Function module
Create a new function module called Z_XTRACT_IS_REMOTE_REPORT. Set the attribute “remote enabled” to true. The screenshots below show how the Import, Export and Tables parameters must be created.
Copy the source code from the file Z_XTRACT_IS_REMOTE_REPORT.txt into the text box for the source code using Ctrl+c and Ctrl+v. Activate the function module. Now the function module is ready to be used.
Executing the Report with .NET und ERPConnect
In the following sample code the report name is passed over with the parameter value PROGRAM_NAME. A table is filled and passed also for the Select-Options.
The result of the report is passed back in the table LIST_OUTPUT and put out with a loop.
static void Main(string[] args) { R3Connection con = new R3Connection("HOST", 11, "USER", "PW", "DE", "800"); con.Open(); RFCFunction func = con.CreateFunction("Z_XTRACT_IS_REMOTE_REPORT"); func.Exports["PROGRAM_NAME"].ParamValue = "RLT10010"; // Name of the Report func.Exports["ACTIONID"].ParamValue = "X"; //Execute immediatly RFCStructure mySelection = func.Tables["SELECTION_TABLE"].AddRow(); mySelection["SELNAME"] = "T1_LGNUM"; //Name of the Select-Option mySelection["SIGN"] = "I"; //Include mySelection["OPTION"] = "EQ"; //Equal mySelection["LOW"] = "001"; //LGNUM try { func.Execute(); } catch (ERPException e) { Console.WriteLine(e.Message); Console.ReadLine(); return; } //Output of the Report foreach (RFCStructure dr in func.Tables["LIST_OUTPUT"].Rows) { Console.WriteLine(dr["WA"].ToString()); } Console.ReadLine(); }
Screenshots of the Result in SAP and .Net







