ABAP Objects, BSPs, and Java

This tip highlights some of the similarities between the BSP and JSP development from an object-oriented perspective.

With the development of ABAP Objects, SAP began to take a more object-oriented view to application development. The introduction of Business Server Pages carried the use of ABAP objects to Web application development. This tip highlights some of the similarities between the BSP and JSP development from an object-oriented perspective.

OO deals with discrete objects and methods for acting on those objects. You have already seen some Java in previous JCo tips. Let's take a look at how a method is called in Java

MyObject objectInstance = new MyObject();
String[] myData = objectInstance.getData((String)parameter);

This code creates a new instance of the MyObject class and calls the getData() method. getData() requires a single parameter and returns an array of String values to the calling class. The values in this String array can now be accessed anywhere else within your application.

Now, let's look at a similar call to an ABAP object. This code assumes that the ABAP class is part of your current application package.

  data: objectInstance type MyObject.
  data: myData type zmydata.
  
  create object objectInstance.
  myData = objectInstance->getData( 'parameter' ).

Notice that both pieces of code incorporate the concept of a named method as well as the ability to return different data types. In the case of the ABAP object, this example uses a custom Z* table to provide the String array return. This is just one of the ways such a table might be implemented but it allows the classes' developer more defined control of the output. In the same way, we could have defined a custom Java object to maintain our return values, rather than using a standard String array.

Now onto BSPs and JSPs. Both provide simplified mechanisms for retrieving and setting common types of data. Let's take a look at pulling a saved parameter from the HTTP request. In a JSP that would look something like this:

String fieldValue = request.getParameter('fieldkey');

While that same code in a BSP would look like this:

data field_value type String.
field_value = request->get_form_field( 'fieldkey' ).

Of course, BSPs allow you to create page attributes that can be automatically filled when the page is loaded whereas the strict JSP requires you to do this manually.

Though the syntax may differ, BSPs and JSPs are relatively close cousins. The concepts adhered to in each share a mutual understanding of objects and serve to simplify the more common functions of Web application development. If you are not ready or able to jump into Java development, I highly recommend getting some time in doing BSPs. The experience will definitely serve to prepare you for any future Java effort. Likewise, you will get more comfortable with standard means and mechanisms to building applications for the Web.

Note: This is a trial BSP tip. Please let me or SearchSAP know if you are looking for more info on BSPs and how their development correlates with Enterprise Java

Author Austin Sincock is a freelance Java/SAP consultant who contributes regularly to Web and print journals. He can be reached at austin@opensourceguru.com. Check out his upcoming book Enterprise Java for SAP


This was first published in December 2002

Dig deeper on SAP ABAP

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close