Tuesday, May 29, 2012

Enterprise Portal Administration


What is single sign on (SSO)

Once a user has authenticated to the SAP EP, he doesn't need to enter his credentials again to access all the systems and backends (SAP and Non-SAP, ESS, MSS and services) integrated into the EP. SSO can be achieved in 3 ways:
- JSESSIONID: The JSESSIONID cookie is used for achieving SSO on the Server Node
- User Mapping: The user or administrator assign for a specific backend system the userid and password. These settings will be used to achieve SSO to the specified backend. If the user is using a different userid for a backend, this is the prefered solution to achieve SSO.
- SAP Logon Ticket. This is a session cookie named MYSAPSSO2 stored in the browser cache and is used to achive SSO to the backends, using the same userid for every backend system.
When talking about SSO, normally the SAP Logon Ticket is meant.

What is the SAP Logon Ticket?


SAP Logon Ticket (token) is a session cookie, stored inside the browsers cache. It get's permanently deleted from the cache after the user logs out or the token is expired. The Logon Ticket contains:

  • Highest Authentication Scheme 
  • Validity 
  • Issuing System 
  • Digital Signature 
  • One Mapped ABAP User ID 
  • User ID 
It doesn't contain the password.


What are the types of SSO?


  • SSO with SAP Logon Ticket 
  • SSO with User ID and password (User Mapping) 
  • SSO using a 3rd party system (Microsoft Active Directory, Kerberos, etc, but the Issuing System for the SAP Logon Ticket is an SAP NetWeaver AS!) 

What are the steps for SSO?

  • Create RFC destination in SM59 
  • Create JCO-RFC destination in Visual admin 
  • Maintain the profile parameters for single sign on in RZ10 
  • login/create_sso2_ticket=2 
  • login/accept_sso2_ticket=1 

4.Export portal certificate (verify.der)
5.Import Portal certificate in STRUSTSSO2
6.Export R/3 certificate in STRUSTSSO2
7.Import R/3 certificate in keystore administration
8.Create system alias in portal
9.Check the SAPJSF user in ABAP system
10.Map the ABAP user to Portal user if it is required.
Please check the below links for Portal administration:

Saturday, May 26, 2012

Remove Preceding 0 for any String.

Wile developing an application in SAP NWDS.  I got this requirement once, like:

Problem :

There is a String having UserId concatenated with User name followed by '-'. (00001234 - Test Sap, 00000102 - Test1 sap, 00000002 - Test2 sap) . 
The requirement was to get just no. 1234, 102, 2 respectively.

Solution:

  1. Split the string followed by space into parts using:
    String pernr = "00001234 - Test Sap";
    String[] tokens = "this is a test".split("\\s");
  2. Take the substring  tokens[0] and parse it to Integer.
    int result = Integer.parseInt(tokens[0]);
  3. You will get the required value in result.
    result will have value = 1234 .

Methods of IUserFactory API and Iuser API



There are various tasks which can be perfomed by using the IUSERFACTORY API of the UME(user management engine).


Instantiate user objects
Create New Users
Delete existing users
search users
and perform mass commit/rollback operations on a set of users
Access to the users factory is possible by using the following lines of code


import com.sap.security.api.*
IUserfactory userfact = Umfactory.getUserfactory();


You can obtain a user object by using the userfactory provided you know the logon ID or the Unique ID of the user.
getUserFactory.getUser(String UniqueID);
getUserFactory.getUserbyLogonID(String LogonID);


If you want to get user and prepopulate specific attributes, use the following method
getUserFactory.getUser(String UniqueID, AttributeList AttrList);




Most of the information needed for processing in a web dynpro java application is present in the IUser Object. Information about the name of the user, their unique ID, LDAP attributes, display name, role membership, etc are available from the IUser object.It is also possible to edit the corresponding profile data with the interface IUserMaint.


Obtaining information about the current User


The user associated with current portal request can be obtained by using getUser() methos in the IPortalComponentRequest Object.


IPortalComponentRequest request  = .... ;
IUser user  = request.getUser();
String Username  = user.getDisplayName();
String depname  = user.getDepartment();


Obtaining Information about another User


You can access any user by using the getuserbyLogonID() provided you have the logon ID of the desired user
An Exception would occur if the user does not exist


String uid = "demouser";
try
{
Iuser user  = UmFactory.getuserFactory().getUserbyLogonID(uid);
String username  = user.getDisplayName();
}
cartch(UME Exception e)
{
wdComponentAPI.getMessagemanager.reportexception(e.getlocalizedmessage, false);
}


The above lines of code also are applicable if you know the unique ID of the user whose information is required. Instead of method getUserbyLogonID(), use getUserbyUniqueID().


Searching for Users
steps are :
create a search filter from the userfactory.
set the search attributes for the search.
invoke the search
iterate thourgh the results


The result of the search is of type ISearchResult and returns an iterator containing the UniqueIDs of the principals returned.
The SearchReult also contain the state of the search.
Search_Result_Incomplete
Search_Result_OK
Search_Result_UNDEFINED
Search_Result_EXCEEDED
TIME_LIMIT_EXCEEDED


IUserFActory userfact = UMFactory.getUserFactory();
IUserSearchFilter userfilt  = userfact.getUserSearchFilter();
userfilt.setLastName("bohra*");
ISearchResult result  = userfact.SearchUsers(userfilt);
if (result.getState() == ISearchResult.SEARCH_RESULT_OK)
{
while(result.hasNext())
{
String uniqID = (string) result.next();
IUser thisuser  = userfact.getuser(uniqID);
}
}
else
{
// print error or warning.
}


}

Web Dynpro Generated Folders in the DTR perstective



I can see that in the DTR perspective, I have these many folders like gen_wdp, gen_mci etc. These folders as I know are generated by the web dynpro framework. There are other DCs in the DTR which do not have these folders. They have only src folder and .dcdef file. 
These folders are not required on the DTR. These should be manually removed from the DTR as they were manually checked in to DTR at the time of Checkin. Removing web dynpro generated folders from the DTR is easy. Just go to the DTR perspective of your NWDS. Drill down to the _comp folder of your project. Right click on each of the web dynpro generated folder and choose delete->delete subtree. This will ask you to create and activity. Just create an activity. The deletion action will be catured in this Activity. Then checkin this activity, delete the project from you workspace and create it again from the inactive DCs in you DC perspective . Then go to DTR perspective again and drill down to the _comp folder of your project. You will see that web dynpro generated folders are gone.

For a project, on the DTR, only 1 folder called src and only 1 file called .dcdef is required. Everything else is generated by the web dynpro framework when you build a DC. These folders are not needed on the DTR . If they are there on the DTR perspective, your DC will appear broken to whoever creates it on his/her machine.

What is SAP ?


This article is about SAP.SAP stands for systems, applications and products in data processing.SAP should be pronounced as S A P and not saap. SAP was founded by a german company in 1972, hence it’s a german company. SAP is an ERP software. 


ERP stands for enterprise resource planning. ERP solutions is an end to end solution for a company. Enterprise consists of multiple departments, for example finance, sales, human resources, manufacturing , sales and distribution, etc. each of these departments needs a software to manage its information. So one solution is that the company can have a unique software developed from scratch for each of these departments or this company can go for an ERP solution. If this company goes for an ERP solution then this department would be using one or more modules of the same ERP software. ERP is a modulated and integrated product so ERP has multiple modules designed for different departments. These modules are integrated in terms of data sharing. This shares the data. So they share the same back-end ,the same data source and the same database. 


Transactions are automatically created in these modules, based on connectivity going on in one module the other module can automatically capture that and can create transactions. Now the ERP market looks like this with the SAP market with the maximum share with 35% with its product my SAP. ORACLE has 28% market with three of its products ORACLE e-business suites, peoplesoft and JDEdward as well. Now we have two ERP applications taking third position with 28% market share. This category includes ERP software which include Baan, epicor, infor and syspro. Microsoft accounts to 14% with its product called greatplains. This is the evolution for SAP. 


SAP had started with SAP R/2 which became SAP R/3 and which has now become my SAP ECC. SAP R/2 was mainly designed for mainframe computers ,large and huge computers then it changed to SAP R/3 which went for catering to the client server environment when machined went from large size to smaller ones and multiple machines were being used together. Now the latest offering is my SAP ECC. ECC stands for ERP central component. My SAP ECC has multiple modules. 


FI and CO are modules within my SAP. So financial and controlling modules are a part of my SAP ECC suite. My SAP has multiple suites , each suite is a group of modules, so you can see this is a family of modules and together all these families are called as my SAP. So my SAP has ERP central component, supplier relationship management(SRM), strategic enterprise management(SEM), catalogue content management, compliance management for SAO, supply hain management(SCM), product lifecycle management( PLM), customer relationship management (CRM), and business intelligence( BI). All these families are a part of my SAP. 


Hence this suite has many families or modules, so FI and CO are a part of ERP central component suite. SAP R/2 changed to SAP R/3 which changed to my SAP ECC. The company added other families as well. So initial offerings did not include these families. So these become a part of this one big giant product called my SAP.




Some SAP Terms


Most Common SAP terms are ABAP and ABAP 4, basis, variant, transaction code, parameter id , batch sessions, jobs, user menus and distributed systems (ALE)


ABAP and ABAP 4


ABAP stands for advanced business application programming 4th generation language. So ABAP is a 4 GL language stands for fourth generation language. The characteristic of 4 GL language is that the added abstraction layer to make them easy to understand. The other examples of 4 GL languages are SQL and PL/SQL. They are closer towards the human language, so if you look at the programming statement you can easily understand what the statement is trying to do. Now ABAP is also called the cousin of COBOL, though COBOL is a 3GL language. Now ABAP is the main programming language for SAP. If you really need to change the SAP software other than the customization and configuration options available on the screen, if you really need to modify under the hood you really need to understand the ABAP language. This Is the language within which SAP product is built.


Basis


Basis is a middleware that connects the SAP applications with the operating systems and the database. So the first layer is the operating system which is the hardware of course. Of the operating system we have the basis software running a swell as we have the database running. So we have choices of database but mostly ORACLE database is used with the SAP applications. So we have basis and database running on top of the system and SAP front run applications are runiing on top of the basis, so basis is the connection between the SAP applications and the operating system and as well as if the application need to talk to the database they have to go through the basis. So its called the middleware software. Now basis group is another term that is commonly used . before we talk about basis group lets see what basis administrator is. Basis administrator is the person who looks after the basis software. This person manages the basis software and security and if running properly and looks after any functional and technical problem related to the basis software while the DBA known as the database administrator looks after the health of the database. So basis administrator looks after the health of the basis software, which is the middleware and DBA looks after the health of the database. So the basis administrator and the DBA together are called a basis group which is more of a technical group looking after the health of the underlying software. So the basis group is a commonly used term as well, so that will mean DBAs and business administrators together.


Variant


When you run a program or report, you need to enter some parameter, for example you can enter January 2010 as a parameter for one of the report and display the data as January 2010. If you enter the data as February as the parameter then February as the parameter shows up. So each report has different parameters, a set of parameters that has to decode and based on those parameters you need to enter those values that are produced. Now same thing for the programs as well. You can save the settings and the saved settings is called as the variant. If you run the same report or program again and again, then you can have the settings saved as variant. Variants basically saves you time. Basically you can run routine programs without having to enter all parameters again and again. 


Transaction Codes


There are two ways to navigate to a screen in SAP. First method is to use the menu. Another method is you can enter the transaction code for that screen directly in the command field and you can go to the screen directly. Each screen has its own transaction code and there is a command field available to you all the time and you can enter in the field and you will be directed into the screen. So it’s a shortcut to go into a particular screen and it comes handy if you use one or few screens on a frequent basis, so then you would basically remember the transaction cades for that screen, then you can enter that in the command field 


Parameter ID


Parameter ID is an identifier given to some fields for example the parameter ID for the a company is BUK is considered as a parameter ID for a nickname of a field. Now what is the use. The use is that, for example if the user comes to the screen and this user work for a certain company 222 for example, then what this user can do is that he can go to the user profile screen and specify 222 as default value for parameter BUK. So you can use a parameter ID to set a default value to a particular field. Now as a result when the user is going to come to the screen, value 22 will always be defaulted. So he doesn’t have to enter 222 again and again. So, what you take home is parameter ID is a nickname to a field ,so most of the fields have parameter IDs. You can use the parameter ID to set a default value to a field so that when you come to the screen the default value is already there.


Input session


So what we see here is that a user is on the screen and is entering data into the SAP data entering screens and that this data is going into the SAP database. Other than the manual data entry, the SAP also receives data from the other non-SAP applications and other SAP installations. So how that process happens? First the data is stored as the batch input session . the batch input program could be used to read the data from the external world and save the data into batch input session. Then another program called process batch input runs which reads the data is stored under batch input session and feeds that into the SAP database. Now, something unique about this batch input session is that the data is stored in such a way that when it is read it is read as if a human being is sitting there and doing the data entry. So this data goes through the same validation process as if somebody is entering data manually in the SAP database. That’s something unique about batch input session. Its goes through the same validation process. It’s a little different concept from the interface tables. And sometimes this data is instructive as well. So if users enter this and asks the user this question then the user chooses this answer, so that is how the batch input session works. So this is how the data can be brought form an external input system to the SAP database. 


Jobs


When you run a program or report, you have two choices. Either you can run it immediately or schedule to run later. A program or report is which is scheduled to run later on is called a job. So can specify when you really want this job to run. If it’s a huge job then you can choose to run it over a night. So job is a technical term used for a program or report which is casual to run later on.


User Menus


When you log in you can see two menus in the system, standard menu and user menu. The standard menu comes with the system and it contains all the options. There is a huge list on the standard menu, but in reality the users use few options for day to-day use. So what you can do is, you can extract those options and put them in the user menu. So the standard menu will contain all the options that are in a system and user menu will contains all those options that a user frequently uses on daily basis. So when a user logs in he can go directly into the user menu and see only those options that he is interested in. so that is the concept of a user menu. 


Distributed systems (ALE)


What does ALE stand for? Application linked enabling. So what is the benefit of ALE? So lets imagine three SAP systems running individually. So they are separate SAPs , production 1, 2 and 3. Now sometimes a client may decide to go for different installations or for whatever technical reasons that happened. Now the need is whenever transaction takes place in system 2 and 3 , it should always automatically show up on system 1. And so system 1 should be in sync with system 2 and 3 in terms of the transactions. So you can use the distributed ALE technologies to achieve that. For example, if a transaction is happening in system 2 , it should automatically be flowing to system 1 , as if someone entered this transaction into system 1. So ALE could be used to keep one system in sync with the other. That’s the whole concept of ALE.

Delegated Administration


The process of "distributing" the administrative content and tasks in the portal to one or more administrators or group administrators is delegating administration. As opposed to the non-delegated portal environment this capability allows you to confining of each administrator or group of administrator, data, the tools, and tasks that is restricted to a specific user or group—, that can expose each administrator to all other administration tools, connected systems,and company data, without restriction.
Delegated administration allows you to do the following:


organizing of the administration framework totally according to your business scenario.
controlling the distribution of portal-related administrative tasks,hence reduces the total cost of ownership (TCO) significantly which is a key function for the "global portal" scenario.
managing large scale portal implementations.


SAP Enterprise Portal offers delegated administration that is fully customisable with user permissions, at these levels:
work sets and Portal roles , and the services (tools) provided by them.
Portal objects like content of the Portal Catalog


Features


1. Administrative Tasks delegation:


All administrative tools available in the portal are in effect iViews, that are integrated subsequently for task-oriented worksets. These worksets are assigned to a predefined sub-administration role in an off-the-shelf installation of SAP Enterprise Portal.
The worksets and pre-configured administration roles serve the purposes of:
Delivering the portal administration like modular building blocks, and hence providing the flexibility of addressing variations in administrative tasks that are performed by one administrator or a group of them.
Providing an example that resembles how one should structure the delegation of administration tasks.
Since the standard SAP role concept is followed by the the pre-configured administration roles you can easily adapt the pre-configured task delegation according to your own admininistration roles or vice versa to suit your environment.


2. Delegating Administration on the Portal Catalog


SAP Enterprise Portal allows the assigning of delegated administration at the level of the Portal Catalog.
The Portal Catalog may include the following objects:


System Landscape objects
Content Objects (iViews, pages, layouts, roles, worksets, packages)
Unification presentation components
KM Objects (resource, taxonomy)


The Portal Catalog does the organization of portal objects, that include the content objects, in a hierarchy. You can set permissions to a node, like a folder containing a group of iViews, or for one object. When objects are below a given node Permissions are inherited to the child . Permissions are editing and reading capabilities of the objects.


You assign permission to folders and objects per role, or user or user group; and hence define who is responsible for customization of object and who is able to just see the objects. After the initial deployment process, the first task of the super administrator is being assignment of default initial content given in the portal, to the which have been defined in the system.

Friday, May 25, 2012

Super Administration


The role of a super administrator is filled by a person who, after installating the SAP Enterprise Portal, stands responsible for initial administration.


This role holds the permissions given to all the other three administrator roles which include the user administrator, content administrator, and system administrator. For in depth details of the pre-framed administrative roles, I shall write an article for pre-configured roles. The super administrator can access the entire set of tools in this portal administration environment.
Following the installation,the super administrator is the first one to be entering the portal. SAP Enterprise Portal comes with a tough-coded username and also a password for the use of the super administrator. After the installation process, the super administrator can log on to the portal with the help of his user ID. When you go beyond the initial configuration stage, it is better to change the initial user IDs and passwords or disable the super user itself.


The main tasks of the super administrator after logging on to the portal and after qualifying the basic functionality are as follows:


Connecting to the base of users who will be working in the portal so that the super administrator sets up at least the minimal user management configuration. We should know configuration of user management in the Enterprise portal for further information.


The end user and the administrative roles needed for the organization should be planned out carefully. The role structure can be put in gradually, starting with a test environment in mind set up and later on gradually moving towards a live production portal with the primary target audience being the end users.


At this point, the super administrator assigns users for the other administrator roles, thereby distributing the responsibilitiesof administration. The super administrator can modify the pre-configured administration roles when they do not fit the needs of the company,and in turn extend them as needed.Before you begin the modification of the pre-configured roles, delta links and SAP Content objects should be well known.


Now the super administrator distributes the default initial content to relevant system administrators and content administrators in the company by assigning permissions for these users. Initial content has objects and templates and portal components, which can be used as a base for creating portal content.


Once delegating the administrative tasks is done by the super adminostrator, the assigned content managers start the process of importing content and roles which can be from their own sources and iViewStudio, and also in-house content developers can parellally start developing content which is specific to the organization. Needs


One optional thing is that parellal to the steps above , the process of setting up and configuring the Knowledge Management platform in the portal should also be done.

User Administration


User administrator does the tasks that are relevant to role assignments and user management. SAP User Management Engine (UME) provides user management functions in SAP Enterprise Portal. This runs as an integrated service in the SAP EP framework.
Portal Content Directory (PCD) manages the Roles.


In this post we will discuss about the tasks that a user administrator performs. These tasks are mostly routine tasks such as: 
Unlocking users, searching for users, creating users etc. User Management Administration Console is used to perform these tasks. 
Assigning roles to users and groups
Mapping users
Replication of user data into external systems.
Importing user data


Assigning roles to users and groups


SAP enterprise portal provides a user interface for each user according to the roles allocated to him or her. Things in the top-level navigation and in the portal pages are determined from his or her roles. So based on their function in the company, it is very important to assign users and groups to specific roles.


Prerequisites


To do this, administrator must have following roles: pcd:portal_content/administrator/super_admin/super_admin_role pcd:portal_content/administrator/content_admin/content_admin_role pcd:portal_content/administrator/system_admin/system_admin_role pcd:portal_content/administrator/user_admin/user_admin_role


Procedure


Select user or group to which you wnat to assign a role.
Select Edit in the right column.
Select one or more roles if you want to assign one or more roles to the user or group. select Add. Similarly you can remove one or more roles chosen by you.
Choose Save.


the same procedure is followed to assign users and groups to roles as is followed for assigning roles to users and groups except that Edit needed to chosen for a role in the first screen. And in the second screen, users and groups are chosen. 


The user's portal user ID is stored in the user repository for the enterprise portal. To enable Single Sign-On, a user's portal user ID and password must be mapped to the corresponding user ID for each system in which the user ID is different. 


Mapping Users


There are two methods of Single Sign-On for which User mapping is required:


SSO using user ID and password: 
here, it is necessary to map the portal user ID and password to the user ID and password in component system.


Using SAP logon tickets for Single Sign-On: 
If the SAP user IDs are the same as the portal user IDs, user mapping is not needed. If not, we must define a SAP reference system. This system is used for user mapping. In the user's SAP logon ticket, a user's portal user ID and the SAP user ID is stored. When a logon attempt to the component system is made, the system extracts the user ID from the logon ticket.


It is possible to map a user, a group, or a role to a user ID in a system which is connected to the SAP Enterprise portal. But in case of the SAP Systems connected to SAP EP, we cannot map roles or groups to a user in a SAP System. Only a user can be mapped to a user. When a iView that needs data from a connected system is accessed, SAP logon tickets are not supported, the procedure is that SAP Enterprise portal checks whether the user is mapped to a user in the corresponding system and if yes then SAP EP logs on using the mapped user data. If not, it checks for the group to which the user belongs whether the group is mapped in the component system or not. If yes, SAP EP logs on using the mapping. If not, it checks for roles. If not, the iView will prompt the user to enter mapping data but foe this, iView needs to be Programmed.

Content Administration




Content creation and maintenance is done by Content Administrator. Content are the objects or components on the portal desktop that bring information to portal users.


iViews are major part of Portal content. Each iView brings to the portal desktop specified data from an information resource such as a ERP system, relational database, CRM system, collaboration tool, enterprise application, e-mail exchange system, World Wide Web, intranet etc. Each time iViews are launched, they bring latest information.




From iViewStudio (www.iviewstudio.com), iViews can be imported into the portal environment Yahoo! content modules also can be integrated into the portal as iViews, There are few templates provided with portal installation; those can be used to create iviews. Also Enterprise Portal administration tools, can be used to create custom iviews.




So where are the iviews displayed ? Generally in portal pages. Again, pages can be created or imported . The page would contain a list of iViews and layout specifications. Also worksets and business packages can be imported. Worksets bring together the pages, iViews and roles. Business packages are groups of worksets. These worksets are related with each other.




Which content will accessed by which user is defined by role definitions. task-oriented content is what a portal contains. Also, role determines the navigation structure in the SAP EP. The navigation structure contain top-level navigation and detailed navigation tree. A user can navigate in the SAP Enterprise portal content by clicking tabs in top-level and detailed navigation.




Unifier projects are part of Additional content. A Unifier project can integrates an external application such as a database, enterprise application, legacy system into the SAP Enterprise Portal. For example, a Unifier project can launch SAP system transactions and enable end-user t use it. Also Drag&Relate can be used to interrelate data from the SAP system transactions and various other portal information resources. You can integrate various Unifier projects into SAP Enterprise portal environment.

System Administration




System administration consists of system configuration and monitoring. System configuration consists of content management configuration and TREX configuration and Index administration.
You need to configure various Content Management (CM) components so that CM matches your system environment and your usage scenarios.


Content Management Components to be Configured are


For storing and/or retrieving metadata and content, repositories are needed. You need to configure repositories.
There are few Global services which provide functions to be used in those repositories
These services may be index management service used for classification and retrieval, publishing pipeline that can be used for rendering and transforming content and the notification service which can be used for informing users about content-related functions.
These services include
the subscription service for making users aware of the changes to content
Discussion service for managing discussion groups.
Repository filters to process metadata and content.
Utilities to provide supplementary functions for applications and services
KM user interface
Content access protocols (WebDAV)
Form-based publishing application




Where is Configuration Data Stored 


It is stored on the portal server:
in In the directory which contains central configuration data.
in In the directory that is accessible through /etc repository.
in In the directory which contains  Java parameter files related to Knowledge Management. 


Central Configuration Data


The CM data is managed by the the configuration framework and it is stored in XML form. You can edit this data in the portal with a configuration iView.This data is stored under 
/usr/sap/  /j2ee/j2ee /global/config/cm/config/local/plugins/cm/ when using SAP J2EE Engine
The variables  and  are specified during installation process.

Connecting SAP EP to a SQL database


This post will explain the procedure of connecting SAP EP to a SQL database.

Create a portal project. Create a portal component of type abstractportalComponent in the project. Add few external Jar files in the portal project. These external jar files will be needed while writing some code for the connection. The Jar Files to be added in the project build path are :

j2eeclient/activation.jar
j2eeclient/connector.jar
portalapps/com.sap.portal.ivs.connectorserviceapi.jar
other/genericConnector.jar
j2eeclient/jta.jar

The Code to open a connection is written below


public class JDBC extends AbstractPortalComponent {
public void doContent(
IPortalComponentRequest request,
IPortalComponentResponse response) {
// Open a connection
IConnectorGatewayService cgService =
(IConnectorGatewayService) PortalRuntime
.getRuntimeResources()
.getService(
IConnectorService.KEY);
ConnectionProperties prop =
new ConnectionProperties(request.getLocale(), request.getUser());
IConnection client = null;
try {
client = cgService.getConnection("myDB", prop);
} catch (Exception e) {
response.write(e.toString());
return;
}
try {
// Issue SQL Query statement
INativeQuery query = client.newNativeQuery();
String queryStr =
"SELECT name, address, zip FROM hotel.hotel";
Object result = query.execute(queryStr);
// Iterate returned result
ResultSetMetaData recordMetaData =
((ResultSet) result).getMetaData();
int colNum = recordMetaData.getColumnCount();
//result.beforeFirst();
response.write("<table border=1>");
while (((ResultSet) result).next()) {
response.write("<tr>");
for (int i = 1; i <= colNum; i++) {
response.write("<td>" + ((ResultSet) result).getString(i)+ "</td
}
}
// Close the connection
client.close();
} catch (QueryExecutionException e) {
response.write(e.toString());
} catch (CapabilityNotSupportedException e) {
response.write(e.toString());
} catch (ConnectorException e) {
response.write(e.toString());
} catch (InvalidQueryStringException e) {
response.write(e.toString());
} catch (ResourceException e) {
response.write(e.toString());
} catch (SQLException e) {
response.write(e.toString());
} catch (Exception e) {
response.write(e.toString());
}
}
}

After writing this code, if error occur, right click in the editor and say organize imports. Make sure that you have service reference in the <application-config> tag. 
<application-config> <property name="ServicesReference" value="com.sap.portal.ivs.connectorservice"/> </application-config>

Then upload the PAR file.
Thats it. The portal application you created above is ready to be tested. Now by merely changing the query you wrote i nthe above code to fetch data from the hotel table can be changed to fetch data from any other database table as well.

SAP EP - J2EE architechture


Introduction

This article will discuss about the important components of portal technical infrastructure. I will talk mainly about the SAP WAS, ABAP and TREX. I will also dicuss about the minimal WAS java installation and a large cluster installation in which we use load balancer.  Once you have a complete understanding of the J2EE infrastructure, you are in a position to design a optimal portal infrastructure which will have all the important features : high availability, scalability, performance, security, and so on.

Components of a Portal Infrastructure



Various systems and devices comprise or come together to form the technical infrastructure :  operating systems, network systems, firewalls, high availability solutions, load-balancing devices, and storage devices etc…


Major components of a portal technical infrastructure are : 



• Web clients• Internet browsers• PDAs• Mobile solutions• Web infrastructure• Load balancer• Web servers• Web dispatchers• Proxy servers• Portal server• Portal platform• Knowledge management• Content management• Collaboration platform• J2EE engine• Web AS database• User Management Engine (UME)• TREX components• Web server• Retrieval and Classification Engine• Retrieval and Classification Index

In this post I shall discuss mainly about the J2EE architecture and the TREX components. 


Web AS Java Architecture

We will have a look at components in a Web AS Java installation. A typical installation hasa central instance, a central services instance, a Java instance, and a database instance.What does the central instance consist of ? it consists of a dispatcher, a server, and a Software 
Delivery Manager (SDM).

The central services instance contains the message service and the enqueue serviceinstalled together on one machine.

The Java instance does not contain an SDM. The Java instance can contain a dispatcher and one or more J2EE server processes.

These various instances can be installed on separate physical machines and if they are installed in this way, scalability and availability of the system can be enhanced. 
When we form a java cluster, more than one java instances can be there but only one central service instance. If there are more than one java instances then there has to be a load balancer such as a sap web dispatcher to distribute the load or the incoming requests to various java instances in the cluster. A java instance has n number of server processes. The number of server processes available in a java instance depends upon RAM of the host on which that Java instance is installed.

Apart from server processes, a Java  instance has something called java dispatcher.

It is a kind of load balancer that receives the client request and forwards it to the server process. Message service tells the java dispatcher as to which is the most suitable server process to which the request should be routed.

Server process will process  the request and will store the user session.The java instance in the cluster which has a SDM installed on it is called the central java instance.

There is something called Java Startup and Control Framework which is used for starting and stopping the Java instance. So it can be controlled and monitored using the SCF.

SAP EP abbreviations



Abbreviations (Taken from scn)


  • ADoW = Application Delivery Over WAN
  • BSP = Business Server Page
  • CAF = SAP Composite Application Framework (CAF)
  • CBS = Component Build Service
  • CI = Central Instance
  • CM = Content Management
  • CMS = Change Management Server (CMS in non-SAP world is Content Management System)
  • DC = Development Component
  • DI = Dialog Instance
  • DQE = Distributed Query Engine
  • DSM = Distributed Session Management
  • DTR = Design Time Repository
  • ENQ = Enqueue Server
  • EP = Enterprise Portal
  • EPCF = Enterprise Portal Client Framework
  • EPCM = Enterprise Portal Client Manager
  • ESA = Enterprise Service Architecture (SAP implementation of SOA)
  • HTMLB = HTML-Business
  • IRJ = iView Runtime Java
  • JCO = SAP Java Connector
  • JDI = Java Developer Infrastructure
  • JRA = Java Resource Adapter (JCA implementation of JCO)
  • KM = Knowledge Management
  • KMC = Knowledge Management and Collaboration
  • MSG = Message Server
  • NW = NetWeaver
  • NW04 = NetWeaver 2004 (WAS 6.40)
  • NW04S = NetWeaver 2004 mySap Business Suite Edition (WAS 7.00)
  • NWDI = NetWeaver Developer Infrastructure
  • NWDS = NetWeaver Developer Studio
  • OBN = Object Based Navigation
  • PAM = Product Availability Matrix
  • PAR = Portal Archive
  • PCD =Portal Content Directory
  • PDK = Portal Development Kit
  • POM = Portal Object Model
  • PRT= Portal Runtime
  • RTC = RealTime Collaboration
  • SC = Software Component
  • SCA = Software Component Archive
  • SCS = SAP Central Services
  • SDA = Software Delivery Archive
  • SDM = Software Deployment Manager
  • SLD = System Landscape Directory
  • SNC = Secure Network Communications
  • SP = Support Package
  • SPS = Support Package Stack
  • TREX = Text Retrieval and Information Extraction
  • UME = User Management Engine
  • WAS = Web Application Server
  • WD = WebDynpro
  • WDA = Webdynpro ABAP
  • WDJ = Webdynpro Java
  • xAPP = Cross application

Originally posted by Dagfinn Parnas in dagfinn.parnas (SAP SCN ) on Feb 5, 2006 6:42:52 AM

Tuesday, May 22, 2012

Find IP Address (WebDynPro Java)


InetAddress thisIp=InetAddress.getLocalHost();
String ipadd = thisIp.getHostAddress();

Extract User information like LoginID (WebDynpro Java)



IWDClientUser User = WDClientUser.getCurrentUser();
Iuser user1 = User.getSAPuser();
String login = user1.getUniquename();

Extract Active Users List from portal (PAR / WebDynpro Java)


Create Abstarct Portal Component and write code in doint() method

         try
                  {

                  IUserFactory userfactory = UMFactory.getUserFactory();
                  IUserSearchFilter userfltr = userfactory.getUserSearchFilter();

                  ISearchResult userResult = userfactory.searchUsers(userfltr);
                  while (userResult.hasNext())
                  {

                  response.write("<table border = 0 >\n");
                  String uniqueid = (String) userResult.next();
                  IUser user = userfactory.getUser(uniqueid);
                 
*********************************** if you are using WebDynpro Java use this code

                    ele = wdContext.nodeEmpDetails().createEmpDetailsElement();
                    wdContext.nodeEmpDetails().addElement(ele);
                    ele.setEmpID( user.getUniqueName());
                    ele.setDisplyName( user.getDisplayName());
                    ele.setEmailID( user.getEmail());

***********************************

response.write("<tr><td>"+user.getUniqueName()+"</td>\n");
response.write("<td>"+user.getDisplayName()+"</td>\n");
response.write("<td>"+user.getEmail()+"</td></tr>\n");
response.write("<table>/n");
response.write("\n");
                  }
                  }
                  catch (Exception e)
                  {
**********************************
wdComponentAPI.getMessageManager().reportException("Exception Caught: "+e, false);
**********************************
System.out.println("Exception Caught: "+e);
           
      }

Extract Logged in User Info:(PAR)


Create Abstract Portal Component type par file.


In Java file

IUser user = Proxy.getActiveUser();
String city = user.getcity();

  • Include  required imports and lib files...include logon-proxy.txt(dbt)


In JSP.file
<%@ page import="com.sapportals.portal.prt.component.IPortalComponentRequest" %>
<%
  IPortalComponentRequest currentRequest = (IPortalComponentRequest) pageContext.getAttribute(javax.servlet.jsp.PageContext.REQUEST);
 %>
<%= currentRequest.getUser().getUniqueName()%>

Extra:
<a href='your portal url?userid=<%= currentRequest.getUser().getUniqueName()%>'>Portal</a>


  • you will get portal link. When u click on it,it opens that user account.

Create Runtime PopUp - (WebDynpro Java)



try
{

IWDControllerInfo controllerInfo = wdControllerAPI.getViewInfo().getViewController();
    
String dialogText = "Are you sure you want to delete?";

IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationWindow(dialogText, controllerInfo.findInEventHandlers("DeleteYes"),"Yes");
dialog.addChoice(controllerInfo.findInEventHandlers("DeleteNo"),"No");
dialog.show();     

}
catch(Exception e)
{
wdComponentAPI.getMessageManager.reportException("Exception Caught:"+e,false);
}


Create two Event Handlers -->Goto Methods and create.
  1. DeleteYes
  2. DeleteNo


Write codes in that DeleteYes--> Delete Records.
                             DeleteNo --> nothing/print info as deleted.