Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
vikas2
Active Participant

This blog documents the solution I had worked on to automate user registration in SUP. We use a mobile solution for sales force automation providing SAP functionality on the mobile device. It's an iOS native app using SUP as data cache and is authenticated against SAP. Hence, we need SAP users to be present in SUP. Usually the task of provisioning and controlling a user in SUP  is done by a MDM solution but our MDM solution ( it's not Afaria ) was not able to handle our iOS app which is around 500MB . Apart from being a sales force automation app allowing sales reps to work on the go, it has lot of picture contents about products which bloated the app size.

Here's the landscape diagram relevant for the issue.

CUA system: Central User Administration. The users are created here and replicated to SAP ECC.

Problem: How to automate user registration in SUP? It is error prone to register them manually in Sybase Control Center - I've made mistakes myself and then tried to spent better part of a day trying to figure out what went wrong. Debugging iOS code was definitely not fun in this case even .And even if a person is not careless like me, it's not feasible if the number of user is in hundreds and new users need to be added regularly.


I used Unwired Server Management APIs to automate the use registration. Approach at a high level :

                - Develop a java program that will be executed as a daily batch job for user registration.

                - The program will perform the following steps:

                                - Read list of users from SAP (e.g. all users of a defined role)

                                - Read list of users in already registered in SUP.

                - For any new user found, perform registration using server management APIs.

I'm not pasting the entire code  here but github link at the bottom of the page can be referred to look at the code . I'll mention the basic building blocks in understanding the solution.


ABAP development:

We'll need a RFC enabled function module which returns table of users which should be  registered in SUP. The below code uses roles set in a custom table which is populated in lt_sup_roles.

Main part in ABAP code will be to get users based on SAP roles, which is in AGR_USERS table.


    select uname

    from agr_users into table users

    for all entries in lt_sup_roles

    where agr_name = lt_sup_roles-value.

Java Development :

We'll need a Java program which will be executed as a daily batch job.

- The program needs to communicate to SAP ECC server to get the list of users and hence we'll need to have JCo libraries added to the Java project.


- For communicating to SUP, some library files are needed . Here's the link for the list and where to get them from:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01332.0210/doc/html/title...

This is required even if the program is run on SUP app server itself .


From experience, Juno version of Eclipse makes it really easy to export the project as a single jar file. Indigo required more work when trying to export the project as a jar with required libraries ( JCO, SUP libs and jar for property file ) .

The java program has the following overall steps:

  • Create a property file so that the settings are configurable for dev, QA and prod.It has connection settings for SAP and SUP servers. You may create a   jar file.

  • Attach JCO and SUP library files.


  • The basic structure of code is as follows:

          Create three lists holding users in SAP , SUP and one for users to be added ( who are present in SAP but not yet in SUP ).

List<String> SAPUserlist = new ArrayList<String>();

List<String> SUPUserlist = new ArrayList<String>();

List<String> UserAddSAPlist = new ArrayList<String>();

Get the list of SAP users . Simple JCo call.

                              JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME2);

                                JCoFunction function = destination.getRepository().getFunction(

                                                                "ZSD_SUP_GET_USER_LIST");

                                JCoTable codes = function.getTableParameterList().getTable("USERS");

                                for (int i = 0; i < codes.getNumRows(); i++) {

                                                codes.setRow(i);

                                                SAPUserlist.add(codes.getString("BNAME")); }

Get the list of SUP users :


ServerContext serverContext = new ServerContext(host, intserverPort,admin, password, true);

String noll = "";

ClusterContext clusterContext = new ClusterContext(serverContext, noll);

SUPApplication app = SUPObjectFactory.getSUPApplication(clusterContext);

PaginationResult<ApplicationConnectionVO> pag = new PaginationResult<ApplicationConnectionVO>();

AppConnectionFilterSortVO filter = new AppConnectionFilterSortVO();

int a = 0;

Long a1 = new Long(a);

int max = 200;

Integer max1 = new Integer(max);

pag = app.getApplicationConnections(filter, a1, max1);

int i = pag.getTotalAvailableRecords();

List&lt;ApplicationConnectionVO> SUPlist = new ArrayList<ApplicationConnectionVO>();

SUPlist = pag.getItems();

for (int j = 0; j < SUPlist.size(); j++) {

  1. SUPUserlist.add(SUPlist.get(j).getApplicationUser().toUpperCase());

}

Now, create a new list for users to add the ones missing in SUP which are present in SAP.


            for (int j = 0; j < SAPUserlist.size(); j++) {

                  if (SUPUserlist.contains(SAPUserlist.get(j)) == false) {

                       UserAddSAPlist.add(SAPUserlist.get(j));

                  }

            }

Register the users in SUP.


AppConnectionRegistrationRequestVO acrrvo1 = new AppConnectionRegistrationRequestVO();

Collection<AppConnectionRegistrationRequestVO> vos = new ArrayList<AppConnectionRegistrationRequestVO>();

Map<APPCONNECTION_REGISTRATION, Object> req1 = new HashMap<APPCONNECTION_REGISTRATION, Object>();

req1.put(APPCONNECTION_REGISTRATION.USER_ID, UserAddSAPlist.get(j));

req1.put(APPCONNECTION_REGISTRATION.ACTIVATION_CODE, intactivationCode);

req1.put(APPCONNECTION_REGISTRATION.EXPIRATION_HOUR, intexpirationTime);

acrrvo1.setRequest(req1);

  • vos.add(acrrvo1);

AppConnectionSettingVO settings = new AppConnectionSettingVO();

Map<APPCONNECTION_SETTING_FIELD, Object> settingMap = new HashMap<APPCONNECTION_SETTING_FIELD, Object>();

     settingMap.put(APPCONNECTION_SETTING_FIELD.SERVER_NAME, host);

     settings.setSetting(settingMap);

     app.registerApplicationConnections(templateName, vos, settings);


Create a jar file for the project and use it to schedule a windows task on SUP server ( it should also work on any other server which has visibility to both SAP and SUP servers ).


The development can be further enhanced by removing users who are no longer active. For this to happen, the following could be checked:

                - In ABAP : USR02 lock status as 32 or 64 ( i.e. locked by admin and not due to incorrect logins ) to get users to be removed.

                - Update java program to add step for removal of users as well for the list derived above.

There was no real need in our case but could be useful depending on the business case and can be easily extended using above steps.

I've put the entire code on github:  https://github.com/viksingh/SUPUserregn .

3 Comments
Labels in this area