cancel
Showing results for 
Search instead for 
Did you mean: 

Passing customer id(logged in user) to BAPI

Former Member
0 Kudos

Hi,

I am creating a sales order application where in i have to pass the user id (customer logged in through portal) .

I have made the MODEL RFC as ticket, and meta data as user id password where i have passed the service user and password.

Now my problem is that there will be 'N' customer ids in Portal but we are not creating any customer ids in SAP ECC. We are planning to pass the user id of portal logged in user to ECC (which will be customer id) and get the data based on the customer id passed.

Question is how do i pass customer id to BAPI, ? Do i have to make the MODEL JCO as user/password or ticket should be fine as i am getting information for only customer logged in Portal ?

How and where do i write the the following piece of code ? Should it be in wdDo init() or in the execute method of Controller ?

try{ 
IUser user = WDClientUser.getLoggedInClientUser().getSAPUser();
IUserAccount[] acct = user.getUserAccounts();

if(acct[0] != null) 
{
String strUserid = acct[0].getLogonUid(); 
customer=strUserid.substring(0,strUserid.indexOf("."));

if(customer.equalsIgnoreCase(customer))
wdContext.currentYOURRFC_InputElement().setCustomer(customer);
}
}catch(Exception ex)
{
ex.getMessage();
}

Should the above code be in the component controller before i execute the BAPI ?

your help is appreciated.

Regards

PN

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Portal Newbie,

Your tickets and userid/password works as following:

Tickets: When u select SAP logon ticket (SLT), EP generates a ticket with the user id of the logged in user, attached to the ticket. Now when it reaches R/3 it will check for the same user id. If no such user id is exits it will throw an error. To over come this u can define a reference system where u can do the user mapping.

UIDPD: When u select this option u have to manually enter the user id and password in JCo. So when a EP user logs in the UID and password mentioned in JCo will be passed, not the EP user id, and R/3 will look for that user and execute the BAPI. And i guess u dont want that.

Solution:

As far as i have understood u dont want the same number of users in EP and R/3, (might be a licensing issue) and want only a few user IDs in R/3.

1. Select UIDPD in JCo, and in your BAPI add another field like "user_id" through which u can send the user id to R/3 and execute a query which shall return the value corresponding to that particular user. [issue: there is a limit to the JCo connections created for a user.] Also there is an api to handle JCo connection in webdynpro. There u can set the user id, password and client number. But here also the user id that you set should be present in R/3.

2. Select SLT in JCo and configure a reference system. You have to perform user mapping for every user. Now when a user logs in the ticket will contain the user id of EP and also the one u have mapped, ie the R/3 user. Make sure the R/3 user id exists in R/3. Now the sy-unam in BAPI will contain the R/3 user id. I guess there is an option to retrieve the EP user id from the ticket, but im not sure.

In your kind of scenario its always recommended to have same number of user ids in EP and R/3. If user names are same then there is no need to configure reference system.

Regards,

Piyush.

ps: reference system is just a system that we create in EP but in UME settings we have to specify this system as the reference system.

Former Member
0 Kudos

Hi Piyush/Abhilash

Thanks for the replies. As far as i can gather here are the steps which i need to do

1) Modify BAPI to accept user parameters.,- this part is ok

2) Pass logged in user in Portal to BAPI and retrieve data for that user only - This part is ok

3) make the model and meta data JCO destinations as uid/password (service user /pwd) - Got some doubts on this

I have some doubts

1) As piyiush said about number of JCO connection per user, would that be a constraint, bcos i have lakhs of customers , how do i avoid that ?

Can i create service users in R/3 for 'N' number of customers with same id as portal ( as portal licences are free,are service users free ? ) ansd use tickets in MODEL JCO destinations ?

What is the best practice for customer facing portal ? My aim is to avoid paying for licenses for SAP R.3 users as there are lacs of customers.

Appreciate your help

Regards

PN

Former Member
0 Kudos

Hi Newbie,

As far as i know license is not free for EP and R/3, unless you are not on production server.

1. It might be a problem if you have lakhs of users. While creating the JCo connections u have to specify the pool size and the connection details. You have to do performance tuning of ur server and also some load balancing. Your basis team has to take care of such things.

2. SLT is used when u have same number of users in EP and R/3. (license is not free for any kind of users in SAP).

The best practice is to have the same number of users in EP and R/3. For your problem you have to go with UIDPD but make sure you do load balancing of your server and define pool size and connections.

Regards,

Piyush.

Former Member
0 Kudos

hi Piyush,

Thanks for the inputs..

Regards

PN

Answers (1)

Answers (1)

former_member182294
Active Contributor
0 Kudos

Hi,

First thing is you should modify your BAPI logic to accept User ID as import parameter and it should return data related to that User only.

Then pass the current user login id to the BAPI as import parameter. You can set import parameter only once in wdInit() of Component Controller as the value is always same for current User.

Executing the BAPI is as per your requirement..

Regards

Abhilash