SAP Business One Integration with Service Management System
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 - this is especially important for multinational companies, opening manufacturing or distribution facilities in Brazil.
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 );
}
}
}
} }
Related Tags: sap business one, sap integration
Andrew Karasev, Alba Spectrum Group. São Paulo - SP - Brazil +55-11-3444-4949, help@albaspectrum.com or skype: albaspectrum, US: 1-630-961-5918 or 1-866-528-0577, http://www.albaspectrum.com, http://www.enterlogix.com.br
Your Article Search Directory : Find in ArticlesRecent articles in this category:
- Improper Way Of Marketing Reflects Poorly On A Company.
New business, product or service everything requires visibility, awareness in order to come into the - Replacing Paper Prints With Online Versions
Nowadays saving out on resources and being additionally informative are both aspects that are in. In - Stop Smoking Effectively
If I told you of a way that you could stop smoking harmful tobacco would you believe it? Most people - What Is Runtime Error 182? And How To Fix It
Are you finding an effective way to fix runtime error 182? Do you think fixing runtime error 182 is - Do You Know How To Fix Runtime Error 87 In Minutes?
Are you finding an effective way to fix runtime error 87? Do you think fixing runtime error 87 is to - Knowledge About Avi, Avi Player, Avi Converter On Mac
Knowledge about AVI, AVI player, AVI Converter on MacWhat is an AVI?AVI, an acronym for Audio Video - Buy Your Highly Successful Email Survey Software Today
Email Survey Software- Boost Your Business and Increase ProfitsAn email survey software could be one - Xrm - The Anything Relationship Management Solution
I recently attended the Microsoft Dynamics West Region FY11 Sales Planning Retreat. This year's meet - What Are The Benefits Of Working With Electronic Medical Records
Recording medical information is a vital part of health care services. These records are necessary f - Basic Factor To Make Website Business Oriented
Internet is home for millions of websites. The online business is becoming more and more competitive
Most viewed articles in this category:
- Parental Control Software
Parental control software is software that can help parents protect their children when they are onl - Digital Asset Management Software
Managing and organizing your organization's documents is a critical component to your business's suc - AdobeRGB vs. sRGB
Understanding color spaces I'll try to explain it very simplified, but understandable for everyone - Confessions of a Prankster
I wanted to get a jump on April Fool's Day, partially because of the long, cold winter blues, and pa - Malicious Thoughts About The Spyware Ills Of My PC
Who would think I was capable of such revengeful thoughts about the parties responsible for inflicti - Recover File and Recover Deleted File Tools
Data recovery software is a very effective way of retrieving data from a worn or damaged hard disk d - Life without Windows
Ubuntu, a user-friendly version of Linux, has been running so nicely on my home PC that I decided to - What Benefit Does an Online Software Download Site Offer You?
Are you having a problem that where you find a good softeware when you consider to have a try or wan - Maintaining A Website
There was an era when people were talking about how to create a website using html coding or some ea - Benefits Of Proper Time Tracking
Have you ever written down time when you have started and finished your work? Maybe you have had mul