New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



Connection Between SAP and Dotnet


Posted Date:     Total Responses: 0    Posted By: UltimateRengan   Member Level: Gold   Points/Cash: 6   


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


Project Feedbacks


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

Post Feedback
You must Sign In to post a feedback.
Next Project: How to clear IE cache through vb.net
Previous Project: How to show Empty gridview using C#?

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.