I got one requirement to assigned / revoked roles basis on the below logic,
logic to identify org heads and roles auto assigned / revoked.
select all P_Head from table zhr_* where zactive EQ "x" and Zcomp EQ "WSM1".
Delete duplicate values of p_head.
result is employee id of org heads.
select userid from pa* for the above result where suby eq 001 and endda eq 31.12.9999.
logic for provisioning and de-provisioning
Select all UNAME from Agr* where Agr_name eq **** and to_dat ge sy-datum.