Creating User roles and profiles in SAP system

This can be done using Legacy Systems Migration Workbench (LSMW) transaction. This workbench works like a sort of macro recorder and allows you to record the steps in a transaction and you can replay that record multiple times as per the requirement. This also allows you to replace the values you used in your recorded transaction with new values.

A more complex option would be to write ABAP code and this is more flexible to add different privileges to different roles.

Methods for Creating User Roles and Profiles

Method 1: Using LSMW (Legacy Systems Migration Workbench)

LSMW is ideal for bulk creation of users with similar role assignments. Follow these steps ?

Transaction: LSMW
1. Create Project, Subproject, and Object
2. Maintain Object Attributes
3. Maintain Source Structures
4. Maintain Source Fields
5. Maintain Target Structures
6. Maintain Field Mapping and Conversion Rules
7. Maintain Fixed Values, Translations, User-Defined Routines
8. Specify Files
9. Assign Files
10. Read Data
11. Display Read Data
12. Convert Data
13. Display Converted Data
14. Create Batch Input Session
15. Run Batch Input Session

Method 2: Using Transaction PFCG (Role Maintenance)

For individual role creation and profile assignment ?

Transaction: PFCG
1. Enter Role Name
2. Go to Menu tab ? Add transactions/programs
3. Go to Authorizations tab ? Generate profile
4. Go to User tab ? Assign users to role
5. Save and transport the role

Method 3: Custom ABAP Program

This approach provides maximum flexibility for complex role assignments ?

REPORT Z_CREATE_USER_ROLES.

DATA: lo_user TYPE REF TO cl_identity,
      lv_role TYPE agr_name VALUE 'Z_CUSTOM_ROLE'.

* Create user object
CREATE OBJECT lo_user
  EXPORTING
    iv_user_id = 'TEST_USER'.

* Assign role to user
CALL FUNCTION 'BAPI_USER_CHANGE'
  EXPORTING
    username = 'TEST_USER'
    password = 'InitialPass123'
  TABLES
    activitygroups = lt_roles.

COMMIT WORK.

User Role Profile assigned to generates creates

Conclusion

Creating user roles and profiles in SAP can be accomplished through LSMW for bulk operations, PFCG for individual role management, or custom ABAP programs for complex requirements. Choose the method that best fits your specific use case and technical expertise.

Updated on: 2026-03-13T19:18:47+05:30

427 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements