usingSystem;usingERPConnect;usingERPConnect.Utils;// Set your ERPConnect licenseLIC.SetLic("xxxx");// Open the connection to SAPusingvarconnection=newR3Connection(host:"server.acme.org",systemNumber:00,userName:"user",password:"passwd",language:"EN",client:"001"){Protocol=ClientProtocol.NWRFC,};connection.Open();conststringcode="""REPORTztestreportNOSTANDARDPAGEHEADING.TABLESkna1.DATAcTYPEi.SELECTCOUNT(*)INTOcFROMkna1.WRITE:/'Systemtime',sy-timlo.WRITE:/'NumberofrowsinKNA1:',c.""";varabapCode=newABAPCode{Connection=connection};string[]lines=code.Split('\n');foreach(stringsinlines){abapCode.AddCodeLine(s.Trim());}if(abapCode.Execute()){for(inti=0;i<abapCode.ResultLineCount;i++){Console.WriteLine(abapCode.GetResultLine(i));}}else{Console.WriteLine($"ABAP Error: {abapCode.LastABAPSyntaxError}");}
Output:
System time 11:17:46
Number of rows in KNA1: 7.705