Friday, August 28, 2009

PIVOT table result

Table
create table source(id int identity(1,1)not null,postcode varchar(10),cust varchar(10))

insert into source(postcode,cust)values('AB10','AMI004');
insert into source(postcode,cust)values('AB10','CLI001');
insert into source(postcode,cust)values('AB10','HCL001');
insert into source(postcode,cust)values('AB10','MIL003');
insert into source(postcode,cust)values('AB10','OSB001');
insert into source(postcode,cust)values('AB11','AMI004');
insert into source(postcode,cust)values('AB11','CLI001');
insert into source(postcode,cust)values('AB11','HCL001');
insert into source(postcode,cust)values('AB11','MIL003');
insert into source(postcode,cust)values('AB11','OSB001');
insert into source(postcode,cust)values('AB12','AMI004');
insert into source(postcode,cust)values('AB12','CLI001');
insert into source(postcode,cust)values('AB12','ABC001');
insert into source(postcode,cust)values('AB12','THK010');
insert into source(postcode,cust)values('AB12','NHF001');
insert into source(postcode,cust)values('AB12','HGF002');


select postcode,
replace((
select cust as "data()"
from source b
where b.postcode = a.postcode
for xml path('')
), ' ', ', ') as cust
from source a
group by postcode

Wednesday, August 26, 2009

some good blog

http://sqltutorials.blogspot.com/2007/06/sql-string-functions.html

Wednesday, July 1, 2009

SAP : BAPIs

Definition

A Business Application Programming Interface (BAPI) is a precisely defined interface providing access to processes and data in business application systems such as R/3.

BAPIs of SAP Business Object Types

BAPIs are defined as API methods of SAP business object types. These business object types and their BAPIs are described and stored in the Business Object Repository (BOR). A BAPI is implemented as a function module, that is stored and described in the Function Builder.

BAPIs of SAP Interface Types

As of Release 4.5A BAPIs can also describe interfaces, implemented outside the R/3 System that can be called in external systems by R/3 Systems. These BAPIs are known as BAPIs used for outbound processing. The target system is determined for the BAPI call in the distribution model of Application Link Enabling (ALE).

BAPIs used for outbound processing are defined in the Business Object Repository (BOR) as API methods of SAP Interface Types. Functions implemented outside the R/3 System can be standardized and made available as BAPIs. For further information see BAPIs Used For Outbound Processing.

Integration

BAPIs can be called within the R/3 System from external application systems and other programs. BAPIs are the communication standard for business applications. BAPI interface technology forms the basis for the following developments:

  • Connecting:
  • New R/3 components, for example, Advanced Planner and Optimizer (APO) and Business Information Warehouse (BW).
  • Non-SAP software
  • Legacy systems
  • Isolating components within the R/3 System in the context of Business Framework
  • Distributed R/3 scenarios with asynchronous connections using Application Link Enabling (ALE)
  • Connecting R/3 Systems to the Internet using Internet Application Components (IACs)
  • PC programs as frontends to the R/3 System, for example, Visual Basic (Microsoft) or Visual Age for Java (IBM).
  • Workflow applications that extend beyond system boundaries
  • Customers' and partners' own developments

The graphic below shows how BAPI interfaces enable different types of applications to be linked together.

BAPIs - Interfaces to the R/3 System

For further background information on BAPIs refer to the document BAPI User Guide.

Friday, June 26, 2009

SAP and Visual Studio 2005

I wrote in a previous blog entry that the design-time of the SAP Connector for Microsoft .NET does not work in Visual Studio 2005. Work-arounds are possible using Visual Studio 2003 to generate the proxies or using SAP Web Services via Exchange Infrastructure (XI) or directly from SAP NetWeaver Application Server are possible.

You can also use the Microsoft BizTalk Server 2006 with the Microsoft BizTalk Adapter for mySAP Business Suite to access SAP backend systems from Visual Studio 2005. The adapter offers code-free access to SAP systems. You can access every BAPI, RFC or IDoc from within Visual Studio 2005 with this adapter. In addition, Microsoft BizTalk Server 2006 enables you to publish your BizTalk application as a Web Service; a wizard helps you with the steps. The resulting Web Service can be used in your Visual Studio 2005 project and so no additional connector for accessing your SAP system is necessary.

Another alternative is to use third-party adapters such as the Sitrion iQL Studio 2006. This tool from the German based company Sitrion Systems enables rapid deployment and development of Microsoft-SAP based scenarios and .NET-based SAP Composite Applications. The iQL Studio works in Visual Studio 2005 without any restrictions. You can access all SAP instances and Business Entity-Repositories. You have access to RFCs, BAPIs, Queries, and also to Workflows in SAP. In addition you have the testing functionality of SAP transaction SE37 in Visual Studio and you can start the SAP ABAP Debugger from within Visual Studio. Sitrion also offers business entities and applications based on iQL Studio 2006 such as Travel Management, HR Manager Self Service, Employee Self Service, Sales Opportunity Management and a few more. For more information about the iQL Studio see www.sitrion.com.
http://blogs.msdn.com/saptech/archive/2006/04/20/579989.aspx

Connection to SAP using Visual Studio 2005 & 2008


SAP has not developed a connector API for Visual Studio 2005 and Visual Studio 2008 yet. I think the reason of not developing a connector API depends on some marketing strategies and the feasibility that can be developed web service that comes with the SAP 6.0, so the technology that can be developed web service in SAP will replace the connector API.

But, there is an important reality that some Visual Studio .NET 2003 projects which were developed before are connecting to SAP with SAP .NET Connector API. There is a ‘technology problem’ that has to be considered by developers if they want to migrate these projects to Visual Studio 2005 or Visual Studio 2008. Respect to this technology problem, SAP firstly suggest to their customers for examining SAP Application Server version whether higher than or equal to 6.0 or not and if higher than or equal to 6.0, developing a web service in SAP Application Server and solving the required connection via this web service. Of course, this is only one solution in all of solutions to this technology problem.

But, what happen if our SAP Application Server version is lower than 6.0 or we don’t want to connect SAP with web service respect to our analyzing decisions although our application server version is higher than or equal to 6.0? SAP has already a solution to this question, too. In fact, this is not an original solution, it is possible that every software specialist can find this solution after thought a while.

In fact, we are now mentioning a solution using SAP .NET Connector in Visual Studio 2005 or in Visual Studio 2008. So, how can do this operation? We have to use Visual Studio .NET 2003 to implement this solution although we are developing our applications with Visual Studio 2005 or Visual Studio 2008. Because, 2.0 version is the last version of SAP .NET Connector is produced for Visual Studio .NET 2003. The meaning of this that, SAP .NET Connector 2.0 is an add on API for only Visual Studio .NET 2003.

Alright, what is the solution method?

The solution method is so simple. We need to create a class library project using Visual Studio .NET 2003. With this project, we will define the desired SAP Application Server(s) and create connection to these servers. Then, we will choose the required functions/bapis of SAP Application servers. Finally, we will have a dll that belongs to this application, so this dll will be a reference for Visual Studio 2005 or Visual Studio 2008 project. I will explain in detailed this solution method of SAP Connection methods with practises in my next essays.

We have mentioned a problem of this solution method. What happen if we don’t have Visual Studio .NET 2003? Unfortunately, you can not use this solution method. The mean of this that there is a must that SAP says; ‘If you will use this solution method, you have to use Visual Studio .NET 2003′.

There are some third party programs that can connect to SAP Application Servers with Visual Studio 2005 or Visual Studio 2008. But, there is reality for enterprise firms; ‘If we are using SAP for ERP sulution, and if I need to connect to SAP via other systems, I should take care the suggestions of SAP priorly’. The mean of this that ‘if we need connector, we should use SAP connector’. I think this is the true approach. Because, if there is a problem based on third party program while our project is in live usage, you have to give a solution to this problem, and your customers will see you as person addressed who is responsible for this problem. So, now the technology problem has to have good analyzing in deep that you did not do before.

Friday, June 12, 2009

Browser disable refresh button

window.history.forward(1);
document.attachEvent("onkeydown", my_onkeydown_handler);
function my_onkeydown_handler()
{
switch (event.keyCode)
{
case 116 : // 'F5' event.returnValue = false; event.keyCode = 0; window.status = "We have disabled F5"; break;
}
}

Install Northwind database in your local machine

http://blog.sqlauthority.com/2007/05/23/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases/

http://blog.sqlauthority.com/2007/06/15/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases-part-2/