Click here to Skip to main content
Click here to Skip to main content

Transferring Data from SAP to .NET using ERPConnect

, 23 May 2007
Rate this:
Please Sign up or sign in to vote.
Description of an interface programming tool for SAP and .NET integration.


In my last customer project, I had to implement a kind of "quick ordering software" for a machine manufacturer company. The goal of this project was to give the construction engineers the possibility to send an auto-generated order list to the buying department. The construction department uses a PDM system based on SQL Server 2000, with an Access front-end, while the buying department and the other economic departments use a SAP system. So, the main task in my project was to implement an interface for these two systems, especially to receive the necessary data from the SAP system into my .NET application. After a short search on the Internet, I found ERPConnect by Theobald Software. This tool allowed me to directly access the data from BAPIs and Tables in the SAP system I needed.

On The Code Project, I only found some articles about the .NET Connector by SAP, but no article dealing with ERPConnect, so I thought that it might be interesting for the other users to read about the usage, the features, and my personal experience with a second tool for SAP interface programming. Because of understandable reasons, I don't want to publish the code of my customer project, so I wrote two examples that explain the usage of ERPConnect basically. The first example deals with BAPI access, while the second example deals with directly reading from SAP tables.

I have included the two examples in VB.NET and C# in the download section above. I have removed the SAP login and connection data from the projects; to try the examples, you have to fill them with your own connection and login information.

SAP Background

For those of you with no SAP experience, I want to explain the most important SAP terms for interface programming.

Function Modules: A Function Module is equivalent to a normal function/procedure in any conventional programming language. Function Modules are SAP integrated modules written in ABAP and are accessible from any other ABAP program in the System. Like a function in any other programming language, Function Modules accept import and export parameters. Function modules also provide a third opportunity the bidirectional Tables. To access a Function Module from outside SAP (just like in our case) the Function Module has to be RFC-enabled. There is also a possibility to access Function Modules being RFC-disabled, this possibility I want to describe later in this article.

BAPIs: BAPIs work like Function Modules, the only difference is that they are the programming interface (API) for the SAP Business Object Repository.

IDocs: IDocs are used to exchange data between two SAP systems or an SAP system and a subsystem. You can imagine IDocs as an electronic kind of receipt written on paper. An IDoc can be uniquely identified by its name (and eventually the name of its extension). IDocs are also well structured; they have a header containing administrative information like the sender, information about the receiving system and the transport. Beside the header an IDoc has segments that are hierarchical like a tree structure. Every segment has one or more fields containing the economic data.

SAP Queries: SAP Queries work just like any other query. For unique identifying of a SAP Query there are three pieces of information necessary: user area (global or local); user group and the name of the query.

How to use ERPConnect

After installing ERPConnect on your computer, you just have to add a reference (ERPConnect.dll for use with .NET Framework 1.1 or ERPConnect20.dll for use with .NET Framework 2.0) to your project and add the using ERPConnect; statement in the header, that's all.

Example 1: Reading Data from a BAPI using the RFCFunction Object

In this short example, I want to show you how to receive the BANK_KEY value of customer 0000001172 and display the result on the console.

After creating a R3Connection object and opening the connection, we create a RFCFunction object on the connection calling our BAPI. Then we fill the Exports parameter of our RFC function object with the Import parameter of the BAPI. That means we send the Import value to the BAPI. After this is done, we execute the function and extract the data of interest from the result table. That's all.

class Program
    static void Main(string[] args)

    static void Connect()
        ERPConnect.LIC.SetLic("licence code");

        //creating the connection object
        R3Connection con = new R3Connection("name of the application server",
                    "system number",
        //open the connection
        //creating the RFCFunction object 
        RFCFunction func = con.CreateFunction("BAPI_CUSTOMER_GETDETAIL2");

        //sending the import parameter to the BAPI 
        func.Exports["CUSTOMERNO"].ParamValue = "0000001172";

            //execute the function
        catch (ERPException e)

        /*Reading the BANK_KEY from func and store it in a string.
        We do only have one row in our result table, because there 
        can be only one customer according to our customer number
        so we only have to select the column of interest from the result table*/
        string Bank_Key = 
        Convert.ToString(func.Tables["CUSTOMERBANKDETAIL"].Rows[0, "BANK_KEY"]);

        //after all don't forget to close the connection

        //display the Data 
        Console.WriteLine("Customer: 0000001172");
        Console.WriteLine("Bank Key: {0}", Bank_Key);

The result should look like this:


It is also possible to store the result in a DataTable, by adding the line...

DataTable dt = func.Tables["CUSTOMERBANKDETAIL"].ToADOTable();

... after the Try Catch block, then we receive all data from CUSTOMERBANKDETAIL according to customer number 0000001172.

In this example, I have shown the basic use of ERPConnect to communicate with Function Modules, but there are some more very interesting features (I'm going to describe later on in this article) handling the RFC and IDoc communication and even the possibility to directly read from SAP tables.

Example 2: Reading Directly from a SAP Table using the ReadTable Class

In my opinion, the ReadTable class is one of the most useful special classes, because it provides the possibility to directly read from SAP tables. For my customer project, it was very important to extract data from a SAP table into a .NET DataSet, so this class was very helpful for me.

This example shows how to use the ReadTable class by using a "where - like" statement to get the address of all customers in table KNA1 that match an entered name criteria and display the result in a DataGridView.

The logic of this example is encapsulated in a class called SAPConnect. Just like in the example above the using ERPConnect; statement and also the using ERPConnect.Utils; for using the ReadTable class have to be added to the header.

The private properties we need are:

private  string _userName;
private  string _password;
private  string _client;
private  R3Connection _con;

Parameters for the constructor are username, password and client that are stored in local properties.

public SAPConn(string userName, string password, string client)
    _userName = userName;
    _password = password;
    _client   = client;

Because the address of the application server, the system number and the language mostly have the same value we can enter these parameters directly into the code or store it in a configuration file. In my customer project, I had a lot of methods using the same connection string, so I thought it was useful to store the procedure of opening the connection in a separate private function called openConnection:

private void openConnection()
    ERPConnect.LIC.SetLic("licence code");

    R3Connection con = new R3Connection("name of the application server",
                    "system number",
    catch (ERPException e)

    _con = connection;

And of course we need a method to close the connection:

private void closeConnection()

Now we can implement the method to read directly from a SAP table and return the result in a DataSet. Let me first explain the way this function works:

At first, we have to create a ReadTable object and fill the TableName property with the name of the SAP table we want to read from. After that, we can add the fields of interest by using the AddField method. When this is done, we can fill the WhereClause with our Like string. In this example I have set the optional RowCount property on 100, so that we only receive 100 rows in our result. After executing the query, we have the Result as DataTable.

public DataTable WhereLikeSearch(string sapTable, string nameCriteria)

    //creating a ReadTable object
    ReadTable table = new ReadTable(_con);

    //setting the table name that we want to read from
    table.TableName = sapTable;

    //adding the fields we want to display in our DataTable
    //this is the 
    table.WhereClause = string.Format("NAME1 LIKE '%{0}%'", nameCriteria);    

    //this is an optional property
    table.RowCount = 100;

    //executing the query
    catch(ERPException e)

    DataTable dt = table.Result;


    return dt;


Instead of the like clause we can use the = operator to search for results that match our nameCriteria exactly, then the table.WhereClause looks like that:

table.WhereClause = string.Format("NAME1 = '{0}'", nameCriteria);

In this statement, it is important to care about the correct syntax especially the spaces before and after the = or an ERPException will be raised.

To display the data in a DataGridView, we have to add the following code to the button1_Click eventhandler. After the button is clicked, the content of textBox1 will be our nameCriteria.

private void button1_Click(object sender, EventArgs e)
    string nameCriteria = textBox1.Text;

    SAPConn sapConn = new SAPConn("userName", "password", "client");
    DataTable dt = sapConn.WhereLikeSearch("KNA1", nameCriteria);

    dataGridView1.DataSource = dt;

After executing the program we should have the DataGridView filled with 100 Customers matching our criteria (e.g. entering t in the TextBox returns all customers with a t in their name).

ReadTable in action

Other ERPConnect Features

There are a lot of more features coming along with ERPConnect than the classes I have used in the two examples above. I haven't used them all yet, but I have also worked with the following classes for my customer project.

Not RFC-enabled Function Modules: If a Function Module is not RFC-enabled, ERPConnect provides a solution to access these Function Modules and use them like RFC-enabled Function Modules by building an internal wrapper around the Function Module executing this Function Module indirectly. In the .NET application, you just have to set the UseRFCWrapper property of the RFCFunction object on true.

ASP.NET: ERPConnect also can be integrated into an ASP.NET application. To use ERPConnect in a Web Application, you have to add a reference on ERPConnect20.dll and the libfcr32.dll which can be found in the System32 directory of a SAP client computer. After adding these references, you can use ERPConnect described above.

SAP Queries: It is also possible to access any kind of SAP queries by using the namespace ERPConnect.Queries.

To execute a query, the following steps are necessary:

  • Create an R3Connection object and open the connection (just like in the examples above)
  • Create a query object Query q = con.CreateQuery("user area","user group","query name");
  • Add the criteria q.SelectionParameters["the parameter"].Ranges.Add(Sign.Include, RangeOption.Equals, "criteria");
  • Execute the query q.Execute
  • Now we find the result in DataTable dt = q.Result;

In this namespace, you also find the very helpful class ERPConnect.Query.QueryHelper.QueryHelper providing kind of "search for Queries" functionality.

IDocs: Another interesting feature is the sending of IDocs by using the CreateIDoc method. Let me explain this using a short listing taken from the ERPConnect online documentation. This example will send a STATUS IDoc. The STATUS IDoc is designed to manipulate the status of another IDoc. The STATUS IDoc can be used to confirm the successful processing of receiving another IDoc.

static void Main(string[] args)
    R3Connection con = new R3Connection("hamlet", 11,"Theobald", 
                                        "pw", "DE", "800");
    Console.WriteLine("Which Idocnumber would you like to manipulate?");
    string IdocNo = Console.ReadLine();
    Idoc i = con.CreateIdoc("SYSTAT01", "");

    // Fill Message Type 
    i.MESTYP = "STATUS";

    // Fill Information about Idoc Receiver
    i.RCVPRN = "PT4_800"; // Partner number 
    i.RCVPRT = "LS"; // Partner type

    // Fill information about idoc sender
    i.SNDPOR = "ERPCONNECT"; // Partner port
    i.SNDPRN = "ERPCONNECT"; // Partner number
    i.SNDPRT = "LS";// Partner type 

    // Fill the right fields in the segments 
    i.Segments["E1STATS", 0].Fields["LOGDAT"].FieldValue = "20060101";
    i.Segments["E1STATS", 0].Fields["LOGTIM"].FieldValue = "152301";
    i.Segments["E1STATS", 0].Fields["STATUS"].FieldValue = "12";
    i.Segments["E1STATS", 0].Fields["DOCNUM"].FieldValue = IdocNo;


    Console.WriteLine("Idoc sent");

Receiving IDocs is a little bit different from sending IDocs. To receive IDocs, we have to implement an small IDoc server by setting the CanReceiveIdocs property on true and catch the incoming IDocs:

//create an RFCServer object

RFCServer s = new RFCServer();
s.Logging = true;

//setting the properties (you have to fill the empty
//strings with your specific values)

s.GatewayHost = "";
s.GatewayService = "";
s.ProgramID = "";

//this property is important
s.CanReceiveIdocs = true;

//here we catch the incoming IDocs to handle them in function s_IncomingIdoc
s.IncomingIdoc += new ERPConnect.RFCServer.OnIncomingIdocs(s_IncomingIdoc);

//start the server
//let the server work
//after all stop the server


In this short listing, I show how to receive the IDOCTYPE of the received IDoc:

private static void s_IncomingIdoc(RFCServer Sender, Idoc idoc)

Of course, you can read all the content of the received IDoc, but for details I refer to the documentation. For implementation of the server in a productive area, you also have to implement a kind of threading to manage plenty of incoming IDocs.

The IDoc classes also provides the possibility to handle IDocs as XML files. For example you can create an XML scheme defining how the IDoc has to look like or an XML file storing the data of an IDoc.

Special Classes: For recurring tasks, ERPConnect provides the special classes encapsulated in the ERPConnect.Utils namespace, like the ReadTable class demonstrated in example 2.

Another special class is the ABAPCode class that allows you to generate ABAP code on the fly in your .NET application. Instead of writing a Function Module in the SAP system, you can write the ABAP code in your .NET application without declaring a new Function Module in your SAP system.

Just as written above, there are some more features that come along with ERPConnect like an XML based SOAP/HTTP protocol or the RFC-Server, so that nearly every interface programming task can be solved.


In my opinion, one of the major tasks for consultants and software engineers in our days is to develop interfaces for the different IT-Systems like ERP, PDM or CRM systems. One of the most used ERP systems in bigger companies is SAP. In consideration of this fact, it is very important to know an easy way of programming an interface for SAP. I think ERPConnect is a very big help for this task because it supports the possibilities of the .NET Framework like ASP.NET or the Compact Framework, also ERPConnect supports any IDE like SharpDevelop. The documentation coming along with the software was very understandable (I have only read the German one, but I think the English one is the same) with a lot of examples explaining the usage of the classes. You can also download the documentation from here.


  • 23rd May, 2007: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Frank Mayer-Potschak
Software Developer FMP software & process engineering GmhH
Germany Germany
Im working as freelance consultant and software engineer in southern germany. If you have any questions about this article please contact me.

Comments and Discussions

QuestionGreat contribution PinmemberKike Kikee10-Sep-13 4:35 
QuestionSAP Dotnet Integration Pinmemberrohitnegi0921-Nov-12 21:25 
QuestionWell,... Could you show me how to bind the data which we recieve from BAPI and bind that data to Crystal Report Pinmembervenu gopal reddy m7-Jun-12 0:09 
QuestionIssue With ERPConnect While Retriving Decimal Values Pinmembersnehalpatel8421-Mar-12 20:44 
GeneralNot able to call BAPI_FIXEDASSET_GETLIST with structure GENERALDATA PinmemberMember 30282654-Feb-11 23:34 
GeneralGood article but old technologies Pinmemberchoopie2-Jan-10 6:04 
JokeRe: Good article but old technologies PinmemberBrian Shifrin27-Jan-10 12:52 
GeneralRe: Good article but old technologies Pinmemberchoopie31-Jan-10 9:51 
GeneralRegarding Pinmembermadhura014-Oct-09 18:04 
GeneralRe: Regarding PinmemberFrank Mayer-Potschak14-Oct-09 22:45 
GeneralRgrading Article Pinmembermadhura014-Oct-09 18:00 
GeneralCodepage of server Pinmemberintecai25-Feb-09 1:24 
QuestionEine Frage zum Senden von IDocs per Pinmemberswapp15-Dec-08 21:32 
GeneralGreat article Pinmemberbobcapilontra30-Sep-08 14:46 
GeneralGreat Article PinmemberSunil_Pawar6-Jul-07 1:28 
GeneralRe: Great Article PinmemberFrank Mayer-Potschak7-Jul-07 7:55 
Generalhelal olsun Pinmemberel_aristo23-May-07 23:18 
AnswerRe: helal olsun PinmemberFrank Mayer-Potschak24-May-07 0:47 
GeneralSehr guter Artikel PinmemberEDVBS23-May-07 20:49 
AnswerRe: Sehr guter Artikel PinmemberFrank Mayer-Potschak23-May-07 22:07 
Generalgood article Pinmemberguveno23-May-07 20:32 
good article. I use only libfcr32.dll and class that i wrote; i add new function when i need.
ConvertDataTabletOSaptable and ConvertSaptableToDataTable functions tables beetwen sap table and ado .

Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.OleDb
Namespace Saputilty
'ABAP/4 data types ANSI C Visual Basic Comment
'Const gTYPC = 0 'RFC_CHAR STRING $ characters
'Const gTYPP = 2 'RFC_BCD STRING $ packed numbers
'Const gTYPX = 4 'RFC_BYTE STRING $ raw data
'Const gTYPTABH = 5 'not used here
'Const gTYPNUM = 6 'RFC_NUM STRING $ digits
'Const gTYPFLOAT = 7 'RFC_FLOAT FLOAT # floating point
'Const gTYPINT = 8 'RFC_INT LONG & 4 byte integer
'Const gTYPINT2 = 9 'RFC_INT2 INTEGER % 2 byte integer
'Const gTYPINT1 = 10 'RFC_INT1 INTEGER % 1 byte integer
'Const gTYPB = 11 'not used here
'Const gTYP1 = 12 'not used here
'Const gTYP2 = 13 'not used here
'RFC_MODE Rfc open modus
'Const RFC_MODE_R3ONLY = 0 'only for R/3 systems, any kind of user
'Const RFC_MODE_CPIC = 1 'can be used for R/2, but CPIC-Users only
'T2.Columns(3).Decimals 0 say ise decimal ksm
'T2.Columns(3).Name MSNUMBER ad
'T2.Columns(3).Type 0 tipi
'T2.Columns(3).TypeName String RFC tip adi
'T2.Columns(3).intlength 10 uzunluk
'RFC_RC Rfc return codes
'Const RFC_OK = 0 'OK
'Const RFC_FAILURE = 1 'error occured
'Const RFC_EXCEPTION = 2 'exception raised
'Const RFC_SYS_EXCEPTION = 3 'system exception raised, connection closed
'Const RFC_CALL = 4 'call received
'Const RFC_INTERNAL_COM = 5 'internal communication, repeat
'Const RFC_CLOSED = 6 'connection closed by the other side
'Const RFC_RETRY = 7 'no data yet (RfcListen only)
'Const RFC_NO_TID = 8 'no transaction ID available
'Const RFC_EXECUTED = 9 'function already executed
'Type As STRING * 1
'Code As STRING * 5
'Message As STRING * 220
'LogNo As STRING * 20
'LogMsgNo As STRING * 6
'MessageV1 As STRING * 50
'MessageV2 As STRING * 50
'MessageV3 As STRING * 50
'MessageV4 As STRING * 50
'End Type
Public Class Saptools
Public Structure SapConnectionOptions
Public logfilename As String
Public loglevel As Integer
Public ApplicationServer As String
Public user As String
Public Password As String
Public Destination As String
Public Client As String
Public Language As String
Public System As String
Public systemid As String
Public SystemNumber As Integer
Public GatewayHOST As String
Public Gatewayservice As String
Public tracelevel As Integer
End Structure
Public Structure Personel_bil
Public BUKRS As String 'Snrlama nasl 4 katrakter
Public ADSOYAD As String
Public AUFNR As String
Public GSBER As String
Public KOSTL As String
Public CEPTEL As String
Public PLAKA As String
Public KUNNR As String
Public SP_GL_IND As String
Public DB_CR_IND As String
Public LOC_CURRCY As String
Public LC_BAL As String
Public HATA As String
End Structure
Public Structure musteri_bil
Public UNVAN1 As String
Public UNVAN2 As String
Public ADRES1 As String
Public ADRES2 As String
Public SEMT As String
Public POSTCODE As String
Public KENT As String
Public TEL_NUMBER As String
Public FAX_NUMBER As String
End Structure
Public Structure MasrafBaslik
Public MANDT As String
Public BUKRS As String
Public MSNUMBER As String
Public MSTARIHI As String
Public PERSNOB As String
Public VALUT As String
Public WAERS As String
Public MSAVANSTOP As String
Public MSAVANSBKY As String
Public MSAVANSKAL As String
End Structure
Public Structure MasrafBelgeSatir
Public MANDT As String 'Üst birim
Public BUKRS As String 'irket kodu
Public MSNUMBER As String 'Masraf Numaras
Public MSTARIHI As String 'Masraf Tarihi
Public WAERS As String 'Para Birimi
Public BUZEI As String 'Masraf Satir No
Public MSCESIDI As String 'Masraf Çeidi
Public MSFATTARIHI As String 'Fatura/Fi Tarihi
Public MSFATURANO As String 'Fatura No
Public WRBTR As String 'Belge para birimi cinsinden tutar
Public MWSKZ As String 'Kdv Göstergesi
Public FWBAS As String 'vergi matrah
Public WMWST As String 'vergi tutar
Public BELNR As String 'Muhasebe belge no
Public BUDAT As String 'Belgedeki kayt tarihi
Public SGTXT As String 'Masraf Kalemi açklama
Public KOSTL As String 'Masraf Yeri
Public AUFNR As String 'ç Sipari
Public PERSNO As String 'Personel No
Public KFZKZ As String 'Tat Plakasi
Public ANLN1 As String 'Duran varlk ana numaras
Public ANLN2 As String 'Duran varlk alt numaras
Public MENGE As String 'Miktar
Public MEINS As String 'Temel ölçü birimi
End Structure
Private Personel As Personel_bil
Private SapFunctions As Object
Dim FNS As Object
Dim CONN, RS, MYFUNC, T1, T2, T3, t4_reserved As Object
Private T_ConnectionState As Boolean
Private T_ShowConnectDialog As Boolean
Private T_FunctionCalledState As Boolean = False
Public Sub New()
T_ShowConnectDialog = True
T_ConnectionState = False
End Sub
Public Sub New(ByVal ShowConnectDialog As Boolean)
T_ShowConnectDialog = ShowConnectDialog
T_ConnectionState = False
End Sub
Sub SAP_CONNECT(ByVal Connectoption As SapConnectionOptions, ByVal VarsayilanBaglanti As Boolean)
FNS = CreateObject("SAP.Functions")
CONN = FNS.Connection
RS = Nothing
MYFUNC = Nothing
T1 = Nothing
T2 = Nothing
T3 = Nothing
If Not VarsayilanBaglanti Then
If Connectoption.logfilename <> "" Then FNS.logfilename = Connectoption.logfilename
If Connectoption.loglevel > -1 Then FNS.loglevel = Connectoption.loglevel
If Connectoption.ApplicationServer <> "" Then CONN.ApplicationServer = Connectoption.ApplicationServer
If Connectoption.user <> "" Then CONN.user = Connectoption.user
If Connectoption.Password <> "" Then CONN.Password = Connectoption.Password
If Connectoption.Destination <> "" Then CONN.Destination = Connectoption.Destination
If Connectoption.Client <> "" Then CONN.Client = Connectoption.Client
If Connectoption.Language <> "" Then CONN.Language = Connectoption.Language
If Connectoption.System <> "" Then CONN.system = Connectoption.System
If Connectoption.systemid <> "" Then CONN.systemid = Connectoption.systemid
If Connectoption.SystemNumber <> Nothing Then CONN.SystemNumber = Connectoption.SystemNumber
If Connectoption.GatewayHOST <> "" Then CONN.GatewayHOST = Connectoption.GatewayHOST
If Connectoption.Gatewayservice <> "" Then CONN.Gatewayservice = Connectoption.Gatewayservice
If Connectoption.tracelevel > -1 Then CONN.tracelevel = Connectoption.tracelevel
FNS.logfilename = "C:\RFSsap.txt"
FNS.loglevel = 7
CONN.ApplicationServer = 'xxx'
CONN.user = "xxxxxx"
CONN.Password = "xxxxxxx"
CONN.Client = "xxx"
CONN.Language = "T"
CONN.tracelevel = 6
End If
T_ConnectionState = CONN.Logon(0, T_ShowConnectDialog)
End Sub
If T_ConnectionState = True Then
T_ConnectionState = False
FNS = Nothing
CONN = Nothing
MYFUNC = Nothing
T1 = Nothing
T2 = Nothing
T3 = Nothing
End If
End Sub
Public ReadOnly Property ConnectionState() As Boolean
' Return T_ConnectionState
' T_ConnectionState = CONN.isconnected
If CONN Is Nothing Then
Return False
'Return CONN.isconnected
Return T_ConnectionState
End If
Catch ex As Exception
Return False
End Try
End Get
End Property
Public ReadOnly Property FunctionCalledState() As Boolean
Return T_FunctionCalledState
End Get
End Property
Public Property ShowConnectdialog() As Boolean
Return T_ShowConnectDialog
End Get
Set(ByVal Value As Boolean)
T_ShowConnectDialog = Value
End Set
End Property

Sub ConvertDataTabletOSaptable(ByVal DtTable As DataTable, ByRef saptable As Object)
Dim readrow As DataRow
Dim sira As Integer = 1
For j As Integer = 0 To DtTable.Rows.Count - 1
readrow = DtTable.Rows.Item(j)
For k As Integer = 0 To DtTable.Columns.Count - 1
If DtTable.Columns(k).ToString <> "MsCesID" Then
saptable.Value(sira, DtTable.Columns(k).ToString) = readrow(DtTable.Columns(k).ToString)
End If
sira += 1
Next j
End Sub
Function ConvertSaptableToDataTable(ByVal Saptable As Object) As DataTable
Dim TableName As String =
Dim dt As New DataTable(TableName)
Dim myRow As DataRow
For i As Integer = 1 To Saptable.COLUMNCOUNT
With dt.Columns.Add
.ColumnName = Saptable.Columns(i).Name.ToString
Select Case Saptable.Columns(i).typename
Case "String RFC"
.DataType = System.Type.GetType("System.String")
Case "Date RFC"
.DefaultValue = Now
.DataType = System.Type.GetType("System.DateTime")
Case "Numerical RFC"
.DataType = System.Type.GetType("System.Int32")
Case "BCD RFC"
.DataType = System.Type.GetType("System.Decimal")
Case "Time RFC"
.DefaultValue = Now
.DataType = System.Type.GetType("System.DateTime")
Case "Byte RFC"
.DataType = System.Type.GetType("System.Int16")
Case "Short RFC"
.DataType = System.Type.GetType("System.Int16")
Case "Long RFC"
.DataType = System.Type.GetType("System.Int64")
Case "Float RFC"
.DataType = System.Type.GetType("System.Double")
End Select
End With
Next i
For i As Integer = 1 To Saptable.RowCount
myRow = dt.NewRow()
For j As Integer = 1 To Saptable.COLUMNCOUNT
Dim gecici As String = dt.Columns(j - 1).ToString
myRow(gecici) = Saptable.Value(i, gecici.ToString)
Next j
Next i
Return dt
End Function
Sub personel_bilgi(ByVal pers_no As String, ByVal KEYDATE As String, ByVal UMSKZ As String, ByRef Personel As Personel_bil)
If T_ConnectionState Then
MYFUNC.exports("PERNR") = pers_no
T_FunctionCalledState = MYFUNC.Call
If T_FunctionCalledState Then
Personel.BUKRS = MYFUNC.ImportS("BUKRS").Value
Personel.ADSOYAD = MYFUNC.ImportS("ADSOYAD").Value
Personel.KOSTL = MYFUNC.ImportS("KOSTL").Value
Personel.SP_GL_IND = MYFUNC.ImportS("SP_GL_IND").Value
Personel.GSBER = MYFUNC.ImportS("GSBER").Value
Personel.KUNNR = MYFUNC.ImportS("KUNNR").Value
Personel.PLAKA = MYFUNC.ImportS("PLAKA").Value
Personel.HATA = MYFUNC.ImportS("HATA").Value
Personel.CEPTEL = MYFUNC.ImportS("CEPTEL").Value
Personel.AUFNR = MYFUNC.ImportS("AUFNR").Value
Personel.LC_BAL = MYFUNC.ImportS("LC_BAL").Value
Dim bakiye As Long
bakiye = Convert.ToDouble(Personel.LC_BAL)
Personel.LC_BAL = bakiye.ToString
End If
End If
End Sub

Function musteri_bakiye(ByVal skod As String, ByVal must As String, ByVal KEYDATE As String, ByVal odk As String) As DataSet
Dim ds As New DataSet("sap1")
must = must.PadLeft(10, Char.Parse("0"))
If T_ConnectionState Then
T2 = MYFUNC.imports("RETURN")
MYFUNC.exports("COMPANYCODE") = skod
MYFUNC.exports("CUSTOMER") = must
MYFUNC.exports("BALANCESPGLI") = odk
T_FunctionCalledState = MYFUNC.Call
If T_FunctionCalledState And Not T1 Is Nothing Then
End If
End If
Return ds
End Function

Function Bapi_get_orders(ByVal CustomerNumber_ As String, _
ByVal SalesOrganization_ As String, _
ByVal Material_ As String, _
ByVal DocumentDate_ As String, _
ByVal DocumentDateTo_ As String, _
ByVal PurchaseOrder_ As String, _
ByVal TransactionGroup_ As Char, _
ByVal PurchaseOrderNumber_ As String) As DataSet
Dim ds As New DataSet("sap1")
If T_ConnectionState Then
T2 = MYFUNC.imports("RETURN")
CustomerNumber_ = CustomerNumber_.PadLeft(MYFUNC.exports("CUSTOMER_NUMBER").length, Char.Parse("0"))
MYFUNC.exports("CUSTOMER_NUMBER") = CustomerNumber_
MYFUNC.exports("SALES_ORGANIZATION") = SalesOrganization_
MYFUNC.exports("MATERIAL") = Material_
MYFUNC.exports("DOCUMENT_DATE") = DocumentDate_
MYFUNC.exports("DOCUMENT_DATE_TO") = DocumentDateTo_
MYFUNC.exports("PURCHASE_ORDER") = PurchaseOrder_
MYFUNC.exports("TRANSACTION_GROUP") = TransactionGroup_
MYFUNC.exports("PURCHASE_ORDER_NUMBER") = PurchaseOrderNumber_
T_FunctionCalledState = MYFUNC.Call
If T_FunctionCalledState And Not T1 Is Nothing Then
End If
End If
Return ds
End Function


Function masraf_belge_kaydet(ByRef BelgeBaslik As MasrafBaslik, ByRef BelgeSatir() As MasrafBelgeSatir) As Boolean
If T_ConnectionState Then
T1 = MYFUNC.tables("ZRFCFI04")
T2 = MYFUNC.tables("ZRFCFI05")
'***********************belge balk*************************************
T1.Value(1, "MANDT") = BelgeBaslik.MANDT
T1.Value(1, "BUKRS") = BelgeBaslik.BUKRS
T1.Value(1, "MSNUMBER") = BelgeBaslik.MSNUMBER
T1.Value(1, "MSTARIHI") = BelgeBaslik.MSTARIHI
T1.Value(1, "PERSNOB") = BelgeBaslik.PERSNOB
T1.Value(1, "VALUT") = BelgeBaslik.VALUT
T1.Value(1, "WAERS") = BelgeBaslik.WAERS
T1.Value(1, "MSAVANSTOP") = BelgeBaslik.MSAVANSTOP
T1.Value(1, "MSAVANSBKY") = BelgeBaslik.MSAVANSBKY
T1.Value(1, "MSAVANSKAL") = BelgeBaslik.MSAVANSKAL
For k As Integer = 0 To BelgeSatir.Length - 1
T2.Value(k + 1, "MANDT") = BelgeSatir(k).MANDT
T2.Value(k + 1, "BUKRS") = BelgeSatir(k).BUKRS
T2.Value(k + 1, "MSNUMBER") = BelgeSatir(k).MSNUMBER
T2.Value(k + 1, "MSTARIHI") = BelgeSatir(k).MSTARIHI
T2.Value(k + 1, "WAERS") = BelgeSatir(k).WAERS
T2.Value(k + 1, "BUZEI") = BelgeSatir(k).BUZEI
T2.Value(k + 1, "MSCESIDI") = BelgeSatir(k).MSCESIDI
T2.Value(k + 1, "MSFATTARIHI") = BelgeSatir(k).MSFATTARIHI
T2.Value(k + 1, "MSFATURANO") = BelgeSatir(k).MSFATURANO
T2.Value(k + 1, "WRBTR") = BelgeSatir(k).WRBTR
T2.Value(k + 1, "MWSKZ") = BelgeSatir(k).MWSKZ
T2.Value(k + 1, "FWBAS") = BelgeSatir(k).FWBAS
T2.Value(k + 1, "WMWST") = BelgeSatir(k).WMWST
T2.Value(k + 1, "BELNR") = BelgeSatir(k).BELNR
T2.Value(k + 1, "BUDAT") = BelgeSatir(k).BUDAT
T2.Value(k + 1, "SGTXT") = BelgeSatir(k).SGTXT
T2.Value(k + 1, "KOSTL") = BelgeSatir(k).KOSTL
T2.Value(k + 1, "AUFNR") = BelgeSatir(k).AUFNR
T2.Value(k + 1, "PERSNO") = BelgeSatir(k).PERSNO
T2.Value(k + 1, "KFZKZ") = BelgeSatir(k).KFZKZ
T2.Value(k + 1, "ANLN1") = BelgeSatir(k).ANLN1
T2.Value(k + 1, "ANLN2") = BelgeSatir(k).ANLN2
T2.Value(k + 1, "MENGE") = BelgeSatir(k).MENGE
T2.Value(k + 1, "MEINS") = BelgeSatir(k).MEINS
End If
T_FunctionCalledState = MYFUNC.Call
Dim Hata As String = MYFUNC.ImportS("HATA").ToString 'error döner
If Hata <> "" Then
Return True
Return False
End If
End Function

Function SD_RFC_CUSTOMER_GET(ByVal CUSTNAME As String) As DataTable
Dim dt As New DataTable
If T_ConnectionState Then
T1 = MYFUNC.tables("CUSTOMER_T")
T_FunctionCalledState = MYFUNC.Call
If T_FunctionCalledState And Not T1 Is Nothing Then
dt = ConvertSaptableToDataTable(T1)
Dim dcolCustCodeName= New DataColumn
dcolMusteriVekodu.ColumnName = "CustomercodeName"
dcolMusteriVekodu.DataType = System.Type.GetType("System.String")
dcolMusteriVekodu.Expression = "KUNNR + ' ' + NAME1"
End If
End If
Return dt
End Function
End Class
End Namespace


güven özdemir
GeneralRe: good article PinmemberFrank Mayer-Potschak23-May-07 22:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 23 May 2007
Article Copyright 2007 by Frank Mayer-Potschak
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid