cancel
Showing results for 
Search instead for 
Did you mean: 

Question regarding implementation of Portal Service

Former Member
0 Kudos

Hello,

I want to create a portal service that calls our R/3 system and comes back with customer master data. For that I have to hand over the userid to the portal service.

The Interface looks like that:


import com.sapportals.portal.prt.service.IService;
import com.lgs.model.CustomerDataBean;

public interface IR3CustDataService extends IService
{
    public static final String KEY = "R3CustDataService";
    
    // returns an object with all customer master data from R/3
	public CustomerDataBean getCustomerData(String userid); 
}

The implementation of the method in the corresponding class is:


CustomerDataBean cdb = new CustomerDataBean();

public CustomerDataBean getCustomerData(String userid) {
		return cdb;
}

Now I would implement the program logic (accessing R/3 and fill the CustomerDataBean) in the init method of the portal service class.


public void init(IServiceContext serviceContext) {
                mm_serviceContext = serviceContext;

                implementation of program logic, usage of userid necessary

}

My question is now how I can use the String userid in the init method? How can I hand over the userid to the init method so that I can use it?

Any hint is really appreciated!

Thanks a lot.

Arno

Accepted Solutions (0)

Answers (4)

Answers (4)

ravindra_bollapalli2
Active Contributor
0 Kudos

hi

MY level of understandind u r problem is

by application u r sending the username and password to the portal and getting the required data by beans

if so

check this it may be usefull foru

bvr

Former Member
0 Kudos

Hi Arno,

You can create a method where you can get the userid and then call this method in the init().

Make the userid as Global Variable by declaring it in others.

Regards.

Rajat

Former Member
0 Kudos

You cannot pass any additional parameters in the init method. This is a method that gets automatically called by the portal itself and not by you. The init method is not thought for performing any complex logic, it's just there to set up the service itself and maybe also some of your own members.

You have to provide an own init method to which you can pass the userid (and maybe also other attributes that may be needed) that can afterwards be saved as class members. You can define an own boolean flag for assuring that your own init method gets called only once (if this is needed... but for your scenario this may not be needed, because I think you want to have the possibility to pass severeal different userids?).

Former Member
0 Kudos

Hi Arno,

declare the userId as class variable so that you can use it in any method of the class.

Regards

Narendra