cancel
Showing results for 
Search instead for 
Did you mean: 

Making Customer Exits Work in the Portal

Former Member
0 Kudos

[NetWeaver 04 - SP9, NetWeaver Developer Studio 2.0.9]

Hello all

I've developed and deployed a portal service that maps users to the stores they belong to. The idea is to use the service as a Customer Exit in an AppIntegrator iView. This is pretty well documented in the Application Integrator HOWTO, chapter 6.

However, I haven't really found any good documentation on how to set up the AppIntegrator iView. I've experimented with all kinds of different combinations for which names and IDs go where in the iView configuration. Can anyone shed some light on this?

The relevant parameters are set like this:

ApplicationParameter: G_STOREWB_EINSTIEG-WERKS=<StoreID>&~OKCODE=TAKE

CustomerExit.ParameterProvider: store_id

I get this error message when running the iView:

Unable to process template 'G_STOREWB_EINSTIEG-WERKS=<StoreID>&~OKCODE=TAKE', because 'StoreID' is an invalid terminal property of the context ''..

The service has this portalapp.xml:

<?xml version="1.0" encoding="utf-8"?>

<application>

<registry>

<entry path="/com.sap.portal.appintegrator/customer_exits/parameter_provider/store_id" name="StoreIDProvider" type="service"/>

</registry>

<application-config>

<property name="SharingReference" value="com.sap.portal.appintegrator"/>

</application-config>

<components/>

<services>

<service name="StoreIDProvider">

<service-config>

<property name="className" value="com.bogus.portal.storeidprovider.StoreIDProvider"/>

<property name="startup" value="true"/>

</service-config>

</service>

</services>

</application>

BTW, the service seems to be deployed okay - in the portal, under Java Development -> Tools -> PRT Registry Browser, my service is listed under "ROOT/com.sap.portal.appintegrator/customer_exits/parameter_provider".

Name: store_id

Class name: java.lang.String - com.bogus.portal.storeidprovider|StoreIDProvider

Any help with this will be greatly appreciated. Thanks!

-martin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Martin,

according to chapter 4.3.3.1, I can't see the error...

What I did once is changing a profile property via customer exit. Profile properties can also be accessed in the template via <Profile.[id]>.

Or maybe the expression (StoreID) should match the custom provider? Just a guess.

Maybe it's worth a try.

Regards, Karsten

Former Member
0 Kudos

I can't see the error either... It's a mystery why it won't work.

First: Is it correct to put "store_id" in the CustomerExit.ParameterProvider property (see portalapp.xml above), or should I use something else? No matter what I enter in this field, the service is not run. I've tried throwing an exception in the getParameter() method just to see if it is run at all, but it isn't.

Second: I've also tried to put all sorts of expressions in the template (<StoreID>, <store_id>, <store_id.StoreID>, ...). They all fail with the message

-


Unable to process template 'G_STOREWB_EINSTIEG-WERKS=<StoreID>&~OKCODE=TAKE', because 'StoreID' is an invalid terminal property of the context ''..

-


...or the message

-


Unable to process template 'G_STOREWB_EINSTIEG-WERKS=<store_id.StoreID>&~OKCODE=TAKE', because 'store_id' is an invalid sub-context of the context ''..

-


A few about the service implementation. I've followed chapter 6 of the HOWTO. This is the relevant parts of StoreIDProvider.java:

-


public class StoreIDProvider implements IStoreIDProvider, ICustomerParameterProvider {

private IServiceContext mm_serviceContext;

/** Vector to hold the enumeration of the parameters this service provides. */

private static Vector parameters;

/**

  • Generic init method of the service. Will be called by the portal runtime.

  • @param serviceContext

*/

public void init(IServiceContext serviceContext) {

mm_serviceContext = serviceContext;

/* Add all parameters here. */

parameters.add("StoreID");

}

/**

  • This method should return a string that is unique to this service amongst all

  • other services deployed in the portal runtime.

  • @return a unique key of the service

*/

public String getKey() {

/* Set to "StoreIDProvider" in IStoreIDProvider.java */

return KEY;

}

public String getParameter(IPortalComponentRequest request, String id) {

String userID;

//userID = request.getUser().getLogonUid();

/* Throw an exception just to see if this service is run at all. */

throw new java.lang.NullPointerException();

//return null;

/*

if (id.equals("StoreID")) {

//TODO

return "foo";

} else {

return null;

}

*/

}

public String getParameterDefault(IPortalComponentRequest request, String id) {

return null;

}

public Enumeration getAllParameterNames() {

return parameters.elements();

}

public String getProviderName() {

return KEY;

}

}

-


Former Member
0 Kudos

Hi Martin,

your custom provider seems to be correct in principle, but the service isn't even called. The failure is raised earlier, when the template processor starts his work.

Unfortunately, my experience with these templates is very weak.

Did you enable custom providers in general?

Go to:

System Administration -> System Configuration -> Service Configuration

In the tree go to: Applications/com.sap.portal.appintegrator/services/Common_Configuration

There is a flag Use_CustomerExit_ParameterProvider which has to be set to "true". This is turned of by default, because customer exits are rather expensive.

The next step would be, as you did, filling the "Customer Exits for ParameterProvider" property of the iView. I guess it's correct to enter the alias, which you registerd in portal registry.

Regards, Karsten

Former Member
0 Kudos

Thanks for answer, Karsten.

I have enabled Customer Exits in general. I've also entered the name ("store_id") of the parameter provider in the "Customer Exits for ParameterProvider" property of the iView.

In the ApplicationParameter property, how can I get to my parameter provider? That is the million dollar question. The documentation says that the template parser first checks custom providers for variable resolution. If this was the case, then my service should be run, and an exception should be thrown (since that is all that it does at the moment).

Do I need to be more explicit in the template expression? I've already tried <store_id.StoreID> and all sorts of variations. "store_id" is the name of the parameter provider service, and "StoreID" is the parameter name. What I'm supposed to put in the expression is only guesswork.

Thanks for the help so far. I'm thankful for further suggestions.

-martin

Former Member
0 Kudos

Maybe you should move your parameters and expressions into the "URLTemplate" instead of "ApplicationParameter"?

Neither in the howto paper nor in the property description expressions are used in the "ApplicationParameter" property.

just another guess...

Former Member
0 Kudos

Solved: The getParameter() method must return a non-null value for the parameter you're trying to provide data for.

This should be fairly obvious, but when I was testing and debugging, I just returned null (or an exception, in which case the portal runtime just ignores the parameter). What confused me was that even when getParameter(StoreID) was called, I got the error message above. I didn't know if it was called or not.

Finally I was tired of speculating, and started logging all method calls (se code below). Then I realized getParameter() was called all along. When I returned a real string instead of null in the <i>if (id.equals("StoreID"))</i> part, it started working.

The relevant iView properties are:

---

ApplicationParameter: G_STOREWB_EINSTIEG-WERKS=<StoreID>&~OKCODE=TAKE

CustomerExit.ParameterProvider: store_id

---

This is the Java code (in the StoreIDProvider class):

private ILogger logger;

private final static boolean DEBUG = true;

public void init(IServiceContext serviceContext) {

mm_serviceContext = serviceContext;

/* Set up the logger */

logger = PortalRuntime.getLogger();

}

public String getParameter(IPortalComponentRequest request, String id) {

String storeID;

if (id.equals("StoreID")) {

if (DEBUG) logger.info(this, "getParameter" + id + ")");

storeID = getStoreID(request);

if (DEBUG) logger.info("Found StoreID: " storeID); return storeID;

}

return null;

}

Former Member
0 Kudos

Hi Martin,

I Have the same problem as you had with the error:

" an invalid terminal property of the contex..."

I tried to do your suggestion but I am still stuck at the same point

I don't think that me service is even running, I don't see any of the log statements I put inside the function

What it might be ?

second, You mention the iView field call CustomerExit.ParameterProvider , I don't see this property field in my iView.

I'm using the com.sap.portal.appintegrator.sap.Generic type iView.

My portal version is EP6.0 SP2

If you have any suggestion how can I continue solving this problem, Please let me know

Thanks

Ami

Former Member
0 Kudos

Hi Ami,

please navigate to the portal registry browser and see if your service is registered correctly.

Support Browser -> Portal Runtime -> Portal Registry Browser

There, your service has to be registered in the path:

ROOT/com.sap.portal.appintegrator/customer_exits/parameter_provider

Regards, Karsten

Former Member
0 Kudos

Hi Karsten,

Thanks for your reply,

I've done it and my service is registered correctly.

What I tried to do is in the get_parameter method

I set the function to return a NON Null value

I set it to return the hardcoded string "CUSTOMER_NAME" value.

However, when I call the iView I'm getting the following error:

An exception occurred while processing a request for :

iView : N/A

Component Name : N/A

Exception in Application Integrator: Unable to load class &#39;CUSTOMER_NAME&#39;..

Do you have any idea what it maight be the reason ?

It seems like the service was triggered (although non of my debug statements were written to the log)

Thanks

Ami

Former Member
0 Kudos

Hi,

After looking invastigate the log file

I saw that in addition to the error I'm getting that mention in the above meesage I'm also getting the following warning before:

Warning Unable to retrieve property file for layer 'CUSTOMER_NAME' - IGNORED and null returned!

java.io.FileNotFoundException: Property file '/property/CUSTOMER_NAME.properties' not found

Does anyone has any idea why the app. integrator looks for file in same name of the parameter value I return from the function get_parameter ?

Thanks

Ami

Former Member
0 Kudos

Just a link for all others facing problems with the customer exit:

Regards, Karsten

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello,

where can i find the "Application Integrator HOWTO", where Martin referenced to in his first posting.

Thanks,

Claus

Former Member
0 Kudos

Hello Claus

You'll find it under http://service.sap.com/ep60howtoguides. It's in the bottom of the list - "Using the Application Integrator".

-martin