Article Categories
» Arts & Entertainment
» Automotive
» Business
» Careers & Jobs
» Education & Reference
» Finance
» Food & Drink
» Health & Fitness
» Home & Family
» Internet & Online Businesses
» Miscellaneous
» Self Improvement
» Shopping
» Society & News
» Sports & Recreation
» Technology
» Travel & Leisure
» Writing & Speaking

  Listed Article

  Category: Articles » Technology » Computer Software » Article
 

SAP Business One Custom Integration with Service Management System




By Andrew Karasev

In this small article we will give you SAP BO integration example with C# code. Service Management System uses Microsoft Dynamics CRM 3.0 Case object to store service hours. Integration pulls Customer Number, Billable Time, Unit Price, Service Description and Item number from various MS CRM 3.0 objects, such as Activity, User Name, Account and sends them into staging table ALBATIMELOG and from there it sends these fields into SAP B1. Integration is implemented as SAP Business One SDK application – please refer to your SAP B1 reseller to help you with your specific integration challenges. In our opinion, if you already invested into eCommerce website and if it is already in production, you should probably consider integrate this legacy e-commerce, rather than redeploy brand new SAP B1 eCommerce solution, this is why such small integrations, as below – are feasible.

This specific case proves you that you can deploy SAP Business One as back end ERP solution for Servicing company: repair and maintenance, contracts, project organization, field service, consulting, auto-repair shops, communication, telephony, utilities maintenance, etc. SAP Business One supports multicurrency, integration to SAP mySAP, SAP all-in-one, R/3, plus we know cases when SAP B1 is integrated with Microsoft ERP systems, such as Microsoft Great Plains Dynamics GP, Oracle eBusiness Suite/Financials.

If you are looking to integrate your legacy MRP application with SAP BO in different module, Manufacturing/production, for example – SAP Business One SDK can help you to develop similar ongoing integration – it allows you to address virtually all SAP B1 objects

Below is application code, you should create is as C# console application project in MS Visual Studio


using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Data.SqlClient;

namespace ConsoleApplication2
{

sealed public class OrderApp
{
public static DataTable TableLines; // the datasource of the datagrid called DataLines.
public static SAPbobsCOM.Documents oOrder; // Order object
public static SAPbobsCOM.Documents oInvoice; // Invoice Object
public static SAPbobsCOM.Recordset oRecordSet; // A recordset object
public static SAPbobsCOM.Company oCompany; // The company object

// Error handling variables
public static string sErrMsg;
public static int lErrCode;
public static int lRetCode;


static string description, itemnumber, accountNumber;


public static void Main()
{
int docNumber=0;
OrderApp.oCompany = new SAPbobsCOM.Company();
OrderApp.oCompany.Server = "localhost"; // change to your company server
OrderApp.oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English; // change to your language
OrderApp.oCompany.UseTrusted = true;

OrderApp.oCompany.CompanyDB = "TEST_SAPBO_ALBA_US";
OrderApp.oCompany.UserName = "manager";
OrderApp.oCompany.Password = "manager";

OrderApp.oCompany.Connect();
Console.WriteLine("Company is: "+OrderApp.oCompany.CompanyName);

SqlConnection connection = new SqlConnection();
connection.ConnectionString = "Integrated Security = true;Data Source = CRMSERVER; Initial Catalog = CRMCUSTOMIZATION;";
connection.Open();

SqlCommand command = new SqlCommand();
command.CommandType = System.Data.CommandType.Text;
command.CommandText = "SELECT + FROM ALBATIMELOG";
command.Connection = connection;
SqlDataReader reader = command.ExecuteReader();

while(reader.Read())
{
decimal billableTime, unitPrice, lineTotal;
double bTime, uPrice;

description="";
itemnumber="";
accountNumber="";

Console.WriteLine("Record:");
//reading from timelog
accountNumber=reader.GetSqlString(0).ToString();
billableTime=reader.GetSqlDecimal(1).Value;
unitPrice=reader.GetSqlDecimal(2).Value;
lineTotal=reader.GetSqlDecimal(3).Value;
description=reader.GetSqlString(4).ToString();
itemnumber=reader.GetSqlString(5).ToString();
//add fields

bTime=(double)billableTime;
uPrice=(double)unitPrice;

Console.WriteLine(billableTime);
Console.WriteLine(billableTime.ToString());
Console.WriteLine(unitPrice.ToString());
Console.WriteLine(lineTotal.ToString());
Console.WriteLine(description.ToString());
Console.WriteLine(itemnumber.ToString ());
Console.WriteLine();

//Adding order
OrderApp.oOrder = ( ( SAPbobsCOM.Documents )( OrderApp.oCompany.GetBusinessObject( SAPbobsCOM.BoObjectTypes.oOrders ) ) );

// set properties of the Order object
OrderApp.oOrder.CardCode = accountNumber;
OrderApp.oOrder.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO;

SAPbobsCOM.Recordset rs = null;
// Create the next Order number
object sSQL = "SELECT TOP 1 DocNum FROM dbo.ORDR ORDER BY DocNum DESC";
rs = ( ( SAPbobsCOM.Recordset )( OrderApp.oCompany.GetBusinessObject( SAPbobsCOM.BoObjectTypes.BoRecordset ) ) );
rs.DoQuery( System.Convert.ToString( sSQL ) );
while ( !( ( rs.EoF ) ) )
{
docNumber=System.Convert.ToInt32( rs.Fields.Item( 0 ).Value ) + 1;
rs.MoveNext();
}

// Default Currency
string dfcurrency="";
sSQL = "SELECT MainCurncy FROM dbo.OADM";
rs = ( ( SAPbobsCOM.Recordset )( OrderApp.oCompany.GetBusinessObject( SAPbobsCOM.BoObjectTypes.BoRecordset ) ) );
rs.DoQuery( System.Convert.ToString( sSQL ) );
while ( !( ( rs.EoF ) ) )
{
dfcurrency= System.Convert.ToString(rs.Fields.Item( 0 ).Value);
rs.MoveNext();
}

OrderApp.oOrder.DocNum = docNumber;
OrderApp.oOrder.DocDate = System.DateTime.Today;
OrderApp.oOrder.DocDueDate = System.DateTime.Today.AddDays(30);
OrderApp.oOrder.DocCurrency = dfcurrency;
OrderApp.oOrder.Lines.ItemCode = itemnumber;
OrderApp.oOrder.Lines.ItemDescription = description;
OrderApp.oOrder.Lines.Quantity = bTime;
OrderApp.oOrder.Lines.Price = uPrice;
OrderApp.oOrder.Lines.TaxCode = "00";
OrderApp.oOrder.Lines.LineTotal = uPrice+bTime;

//ATTENTION - you should NOT add last row!!!
//OrderApp.oOrder.Lines.Add();

OrderApp.oCompany.GetLastError( out lErrCode, out sErrMsg );
lRetCode = OrderApp.oOrder.Add(); // Try to add the order to the database
if ( lRetCode != 0 )
{
OrderApp.oCompany.GetLastError( out lErrCode, out sErrMsg );
}
}
}
}
}
 
 
About the Author
Andrew Karasev, Alba Spectrum Group. We serve SAP Business One customization, integration, software development, reporting projects USA nationwide from Chicago and Houston. http://www.albaspectrum.com http://www.enterlogix.com.br , help@albaspectrum.com or skype: albaspectrum, US: 1-630-961-5918 or 1-866-528-0577, Sao Paulo: +55-11-3571 4992

Article Source: http://www.simplysearch4it.com/article/48164.html
 
If you wish to add the above article to your website or newsletters then please include the "Article Source: http://www.simplysearch4it.com/article/48164.html" as shown above and make it hyperlinked.



  Some other articles by Andrew Karasev
SAP Business One Integration
SAP B1 has multiple tools to enable integration with your legacy system, eCommerce, etc. In this small article we would like to give you highlights on SAP Business One SDK integrations. ...

  
  Recent Articles
How to Evaluate Survey Software in 3 Steps
by Brian Henderson

A practical use of Open Source Code Softwares
by Roberto Sedycias

Clean up sensitive information in a secure way!
by Alexander Rodichev

Remove Protection and Recover OpenOffice Documents After Losing a Password
by Dmitry Rozenbaum

Advantages Of Buying A Non Profit Accounting Software
by Javier Fuller

Microsoft's Windows Vista
by Vinay Choubey

Tracking and organizing a growing movie collection
by Max Smirnoff

Clear IE History and Remove Search History Tools
by Sam Roberts

Manufacturing Accounting Software: A Right Choice
by Javier Fuller

How To Clean Your Windows Registry
by Drew Pilton

Improving the Management of Output in an SAP Environment
by Nicole Summerfield

Internet Privacy and Online Privacy Tools
by Sam Roberts

Clear Yahoo History and Clear Google History Tools
by Sam Roberts

How To Speed Up Your PC
by Drew Pilton

Recover Microsoft Office Passwords with Office Password Recovery
by Dmitry Rozenbaum

Delete Search History and Clear Search History Tools
by Sam Roberts

What to Look For in Print Spooler Software
by Plus Technologies

Can't connect to database