ERPConnect.Utils.ABAPCode
Namespace: ERPConnect.Utils
Assembly: ERPConnectStandard20.dll
ABAPCode is a class, that can be used to execute ABAP code on the fly and retrieve the result.
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
ABAPCode(R3Connection)
initializes a ABAPCode object that can be used to execute dynmic ABA code A valid SAP connection
Parameters
Con
R3Connection
ABAPCode()
initializes a ABAPCode object that can be used to execute dynmic ABA code
Properties
Connection
The R3Connection object which the ABAPCode object is assigned to.
Property Value
LastABAPSyntaxError
Returns the ABAP error message in case the programm is syntacly incorrect. The method Execute returns false.
Property Value
ResultLineCount
Returns the number of lines that a retrieved a report output.
Property Value
Methods
AddCodeLine(string)
Adds a new line of ABAP code.
Parameters
CodeLine
string
Line of ABAP code to append
Execute()
Executes ABAP code on the fly.
Returns
true / false depends if the program could have been executed without a syntax error.
Remarks
The following code shows, how to set some ABAP code (located in textBox1), execute it and write the list result in another TextBox. You'll find this samples in the directory AbapPad. [C#]
private void button1_Click(object sender, System.EventArgs e)
{
ERPConnect.R3Connection con = new ERPConnect.R3Connection();
if(!con.AskUserAndOpen(true))
return;
ERPConnect.Utils.ABAPCode code = new ERPConnect.Utils.ABAPCode();
code.Connection = con;
foreach(string s in textBox1.Lines)
code.AddCodeLine(s);
if (code.Execute())
{
for(int i=0; i code.ResultLineCount; i++)
textBox2.Text += code.GetResultLine(i) + "\r\n";
}
else
textBox2.Text = "ABAP Error: " + code.LastABAPSyntaxError;
}
[VB]
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
Dim con As New ERPConnect.R3Connection
If Not con.AskUserAndOpen(True) Then
Exit Sub
End If
Dim code = New ERPConnect.Utils.ABAPCode
code.Connection = con
Dim s As String
For Each s In textBox1.Lines
code.AddCodeLine(s)
Next
Dim i As Integer
If code.Execute() Then
For i = 0 To code.ResultLineCount - 1
textBox2.Text += code.GetResultLine(i) + vbCrLf
Next
Else
textBox2.Text = "ABAP Error: " + code.LastABAPSyntaxError
End If
End Sub
GetResultLine(int)
Returns a single at the given position the resultset of the abap report
Parameters
Index
int
Index of the result line
Returns
Result line of the report output
ResetCode()
Deletes the current code lines.