Business Objects Tutorial Pdf
I started working in SAP TM module (Version 8.1) 1 year back and we hardly find little help since we started working on it. My past experience enforced me to publish this blog which I hope it will definitely help developers to learn and understand how to retrieve the data by making use of Business objects based out in BOPF framework.
business objects tutorial pdf
BOPF controls the application business logic as well as the data retrieval of the buffer and persistency layer. The main design principles are a clear separation of the business logic and the buffering of data as well as a clear structuring of the business logic into small parts with a clear separation of changing and checking business logic. The BOPF approach for implementing business objects breaks down business logic into the following four concepts:
/BOBF/CUST_UI: This transaction is used for launching the BOPF Enhancement workbench. This transaction is used for enhancing the standard business objects and for creating a new business objects.
In this example, we are trying to display shipment (FWO) information, invoicing amount and Forwarding agreement. To achieve the expectedresults, we are going to access different business objects such as /SCMTMS/TRQ, /SCMTMS/CUSTFREIGHTINVREQ and /SCMTMS/TCC_TRNSP_CHRG. Relations between 2 business object nodes are associated via a direct, unidirectional and binary relationship.
Lucene is an extremely rich and powerful full-text search librarywritten in Java. You can use Lucene to provide full-text indexingacross both database objects and documents in various formats(Microsoft Office documents, PDF, HTML, text, and so on). In thistutorial, we'll go through the basics of using Lucene to add full-textsearch functionality to a fairly typical J2EE application: an onlineaccommodation database. The main business object is the Hotelclass. In this tutorial, a Hotel has a unique identifier, aname, a city, and a description.
Roughly, supporting full-text search using Lucene requires two steps:(1) creating a lucence index on the documents and/or databaseobjects and (2) parsing the user query and lookingup the prebuilt index to answer the query. In the first part ofthis tutorial, we learn how to create a lucene index. In the secondpart, we learn how to use the prebuilt index to answer userqueries.
For your convenience, all of the code for this article's Lucenedemo is included inthe lucene-tutorial.zip file. Inthis demo, the class Indexer insrc/lucene/demo/search/Indexer.java is responsible forcreating the index. The class SearchEngine insrc/lucene/demo/search/SearchEngine.java is responsible forsupporting user queries. The class Main in src/lucene/demo/Main.java has a test code thatbuilds a Lucene index using a small dataset(the actual data is provided by the Hotel classstored in src/lucene/demo/business/HotelDatabase.java)and performs a simple keyword query on the data using the index.Briefly go over the two java source files, Indexer.java andSearchEngine.java, toget yourself familiar with the overall structure of the code. 1. Creating an IndexThe first step in implementing full-text searching with Lucene is to build anindex. Here's a simple attempt to diagram how the Lucene classes go together when you create an index:
At the heart of Lucene is an Index. You pump your datainto the Index, then do searches on the Index to getresults out. Document objects are stored inthe Index, and it is your job to "convert" your data intoDocument objects and store them to the Index. Thatis, you read in each data file (or Web document, database tuple orwhatever), instantiate a Document for it, break down the datainto chunks and store the chunks in the Documentas Field objects (a name/value pair). When you're donebuilding a Document, you write it to the Index usingthe IndexWriter. Now let us get into details on how this is done.
It isn't difficult to implement your own analyzer, though thestandard ones often do the job well enough. When you createan IndexWriter, you have to specify which Analyzeryou will use for the index as we did before. In our previous example, we usedthe StandardAnalyzer as the document analyzer. 1.3 Adding a Document/object to IndexNow you need to index your documents or business objects. To index an object,you use the Lucene Document class, to which you add thefields that you want indexed. As we briefly mentioned before, aLucene Document is basically a container for a set of indexedfields. This is best illustrated by an example:
Now that we've indexed our data, we can do some searching. In our demo,this part is implemented by the SearchEngine class in src/lucene/demo/search/SearchEngine.java.In most cases, you need to use two classes to support full-text searching:QueryParserand IndexSearcher. QueryParser parsesthe user query string and constructs a Lucene Query object,which is passed on to IndexSearcher.search() as theinput. Based on this Query object and the prebuilt Luceneindex, IndexSearcher.search() identifies the matching documentsand returns them as an TopDocs objects in the result.To get started, look at the following example code. package lucene.demo.search;import java.io.FileNotFoundException;import java.io.IOException;import java.io.File;import java.util.ArrayList;import java.util.List;import org.apache.lucene.document.Document;import org.apache.lucene.analysis.Analyzer;import org.apache.lucene.analysis.standard.StandardAnalyzer;import org.apache.lucene.index.DirectoryReader;import org.apache.lucene.index.IndexReader;import org.apache.lucene.queryparser.classic.QueryParser;import org.apache.lucene.queryparser.classic.ParseException;import org.apache.lucene.search.Query;import org.apache.lucene.search.TopDocs;import org.apache.lucene.search.IndexSearcher;import org.apache.lucene.store.Directory;import org.apache.lucene.store.FSDirectory;import org.apache.lucene.util.Version;import lucene.demo.business.Hotel;import lucene.demo.business.HotelDatabase;public class SearchEngine private IndexSearcher searcher = null; private QueryParser parser = null; /** Creates a new instance of SearchEngine */ public SearchEngine() throws IOException searcher = new IndexSearcher(DirectoryReader.open(FSDirectory.open(new File("index-directory")))); parser = new QueryParser("content", new StandardAnalyzer()); public TopDocs performSearch(String queryString, int n) throws IOException, ParseException Query query = parser.parse(queryString); return searcher.search(query, n); public Document getDocument(int docId) throws IOException return searcher.doc(docId); Inside the constructor of SearchEngine, we first createan IndexSearcher object using the indexin index-directory that we created before. We then createa QueryParser. The firstparameter to the QueryParser constructor specifies thedefault search field, which is content field in thiscase. This default field is used if the query string does not specifythe search field. The second parameter specifiesthe Analyzer to be used when the QueryParser parsesthe user query string.The class SearchEngine provides a methodcalled performSearch which takes a query string and the maximum number of matching documents that should be returned as the input parametersand returns the list of matching documents as a Lucene TopDocsobject. The method takes the query string, parses it using QueryParserand performs search() using IndexSearcher.Important Note: There's a very common mistakes that peopleoften make, so I have to mention it here. When you use Lucene, youhave to specify the Analyzer twice, once when you createan IndexWriter object (for index construction) and once morewhen you create a QueryParser (for query parsing). Pleasenote that it is extremely important that you use the sameanalyzer for both. In our example, since wecreated IndexWriter using StandardAnalyzer before,we are also passing StandardAnalyzer to QueryParser.Otherwise, you will get into all sorts of problems that you do notexpect. The last method getDocument of the SearchEngine class takes the unique ID of a document and returns the corresponding Document object from the index. This method is used to retrieve a particular matching document from the index.Now we briefly explain the syntax of the user's query string.2.1 Query Syntax In the simpliest form, the query string canbe a simple list of keywords like Mariott Hotel. This query willreturn the documents that contain either Mariott or Hotel in thedefault field (i.e., the content field in our example). Ifyou want to search for documents that contain both keywords, the queryshould be Mariott AND Hotel. Note that AND boolean operator must beALL CAPS.The general syntax for a query string is as follows: A query is aseries of clauses. A clause may be prefixed by: a plus (+) or a minus (-) sign, indicating that the clause is required or prohibited respectively; or a field name followed by a colon, indicating the search field. This enables one to construct a query on multiple search fields. A clause may be either: a keyword, indicating all the documents that contain this keyword; or a nested query, enclosed in parentheses.For example, the following query string will search for "Mariott" in the name field or "Comfortable" in the description field: name:Mariott OR description:ComfortableThe following query will search for a hotel that contains both the words "Mariott" and "Resort" in the name field:name:(+Mariott +Resort)More examples of query strings can be found in the query syntax documentation.2.2 Retrieving Matching DocumentsThe search() function of the Lucene IndexSearcher object returns the list of matching document informationas a Lucene TopDocs object. Thisobject contains a list of ScoreDoc objects in the scoreDocs field, which, in turn, has the doc field (the unique document ID of the matching document) and the score field (the document's relevance score).More precisely, from the TopDocs object you can obtain the matching Document objects as follows:// instantiate the search engineSearchEngine se = new SearchEngine();// retrieve top 100 matching document list for the query "Notre Dame museum"TopDocs topDocs = se.performSearch("Notre Dame museum", 100); // obtain the ScoreDoc (= documentID, relevanceScore) array from topDocsScoreDoc hits = topDocs.scoreDocs;// retrieve each matching document from the ScoreDoc arryfor (int i = 0; i 350c69d7ab