cancel
Showing results for 
Search instead for 
Did you mean: 

assign portal role to user with SPML

ivy_li
Active Contributor
0 Kudos

Dear All,

I have one query:

assign unique id of one portal role to SRM role with /SAPSRM/EP_SRM_ROLES in personalization via trx pfcg.

Then assign this SRM role to one user.

However later if I check this user in user administration, I can't find this portal role in assigned role part.

Is this method available? Or missing any configuration.

Best regards,

Ivy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Dear Ivy,

Although its quite late but might it could help others who are looking for same kind of solution.

Below is the code which we used to assign a portal role through SPML

IV_PORTAL_USER = User name on Portal

IV_AGRNAME=  SRM Role ( e.g. /SAPSRM/EP_SRM_ROLES )

FUNCTION zassign_ume_roles.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IV_PORTAL_USER) TYPE  XUBNAME
*"     VALUE(IV_AGRNAME) TYPE  AGR_NAME
*"----------------------------------------------------------------------

DATA: lo_spml_wrpr   TYPE REF TO /sapsrm/if_spml_srvc_wrapper,
lr_cust_reader
TYPE REF TO /sapsrm/if_spml_cust_reader,
lt_srm_roles  
TYPE STANDARD TABLE OF bapiagr,
ls_srm_roles  
TYPE bapiagr,
lt_ep_roles   
TYPE /sapsrm/t_ep_roles,
lt_return     
TYPE STANDARD TABLE OF bapiret2,
lv_rfcdest    
TYPE rfcdest.

*Get bidder's SRM roles and add new SRM role
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username      
= iv_portal_user
TABLES
activitygroups
= lt_srm_roles
return         = lt_return.

*Check if role Z_CUSTOM_ROLE is already assigned, if not then assign
READ TABLE lt_srm_roles INTO ls_srm_roles WITH KEY agr_name = iv_agrname.
IF sy-subrc NE 0.

ls_srm_roles
-agr_name = iv_agrname.
APPEND ls_srm_roles TO lt_srm_roles.
CALL FUNCTION 'BAPI_USER_ACTGROUPS_ASSIGN'
EXPORTING
username      
= iv_portal_user
TABLES
activitygroups
= lt_srm_roles
return         = lt_return.

ENDIF.

CREATE OBJECT lr_cust_reader
TYPE
/sapsrm/cl_spml_cust_reader
.

TRY.
CALL METHOD lr_cust_reader->get_ep_role
EXPORTING
iv_srm_role
= iv_agrname
RECEIVING
rt_ep_roles
= lt_ep_roles.
CATCH /sapsrm/cx_spml_pers_data.
ENDTRY.

*get portal RFC Destination
CALL METHOD /sapsrm/cl_spml_configuration=>get_spml_destination
RECEIVING
rv_spml_destination
= lv_rfcdest.

*Obtain wrapper instance and change UME user
lo_spml_wrpr
= /sapsrm/cl_spml_wrpr_factory=>get_spml_wrapper( lv_rfcdest ).

TRY.
CALL METHOD lo_spml_wrpr->add_role_ume_user
EXPORTING
iv_logon_id
= iv_portal_user
it_roles   
= lt_ep_roles.

CATCH /sapsrm/cx_spml_connection.
CATCH /sapsrm/cx_spml_service.
ENDTRY.

ENDFUNCTION.

Answers (1)

Answers (1)

ivy_li
Active Contributor
0 Kudos

Hi,

Anyone have idea about this?

Thanks a lot.

Best regards,

Ivy