C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » General »

Connection Between SAP and Dotnet


Posted Date: 20 Jun 2009    Resource Type: Articles    Category: General
Author: UltimateRenganMember Level: Diamond    
Rating: 1 out of 5Points: 5



Connection Between SAP and Dotnet



Step1:-
First add the Empty Project
File->New Project->Empty Project

Step 2:-
Right click the Project Name->Choose Add Reference->Add Reference window will display ->Choose COM Tab-->Choose SAP Business One DI API version 2007 and SAP Business One UI API version 2007 A-->Then ok

Step 3:-
Right click the Project Name->Add->Add NewItem->Module

Step 4:-
Import the System.Reflection name space.

Step 5:-

Create the objects for SAPbouiCOM and SAPbobsCOM


Add the below code in Module and run it


Imports System.Reflection
Module Module1
Public WithEvents application As SAPbouiCOM.Application
Public company As SAPbobsCOM.Company
Public Function SetConnectionContext() As Integer
Try
Dim bnnStrCookie As String
Dim bnnStrConnectionContext As String
company = New SAPbobsCOM.Company
bnnStrCookie = company.GetContextCookie
bnnStrConnectionContext = application.Company.GetConnectionContext(bnnStrCookie)
If company.Connected = True Then
company.Disconnect()
End If
SetConnectionContext = company.SetSboLoginContext(bnnStrConnectionContext)

Catch Ex As Exception
application.MessageBox(Ex.Message)

Finally

End Try

End Function
Public Sub SetApplication()


Dim bonGuiSboGuiApi As SAPbouiCOM.SboGuiApi
Dim bnnStrConnectionString As String
bonGuiSboGuiApi = New SAPbouiCOM.SboGuiApi

Try
bnnStrConnectionString = Environment.GetCommandLineArgs.GetValue(1)
bonGuiSboGuiApi.Connect(bnnStrConnectionString)
application = bonGuiSboGuiApi.GetApplication()

Catch Ex As IndexOutOfRangeException
bnnStrConnectionString =

"0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D00560049004

90056"
bonGuiSboGuiApi.Connect(bnnStrConnectionString)
application = bonGuiSboGuiApi.GetApplication()

Catch Ex As Exception
application.MessageBox(Ex.Message)

Finally

End Try

End Sub
Private Sub Class_Init()
SetApplication()
If Not SetConnectionContext() = 0 Then
application.MessageBox("Failed setting a connection to DI API")
End
End If
If Not ConnectToCompany() = 0 Then
application.MessageBox("Failed connecting to the company's Data Base")
End
End If
application.StatusBar.SetText("Connected...", SAPbouiCOM.BoMessageTime.bmt_Short,

SAPbouiCOM.BoStatusBarMessageType.smt_Success)
End Sub
Public Function ConnectToCompany() As Integer

Try
If company.Connected = True Then
company.Disconnect()
End If
ConnectToCompany = company.Connect

Catch Ex As Exception
application.MessageBox(Ex.Message)

Finally

End Try

End Function

Sub Main()
Try
Class_Init()

Catch Ex As Exception
application.MessageBox(Ex.Message)

Finally

End Try

End Sub

End Module



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Connection Between SAP and Dotnet  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Creating Themes in MOSS 2007
Previous Resource: Keywords in C# .Net
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use