Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any BAPI returning the affected organisational units to users?

Former Member
0 Kudos

Dear all,

I would like to ask a question about organizational units. Whenever I want to affect a user to a given unit I

use PPOME transaction. If I want to do this in ABAP level I use the function module RH_RELATION_WRITE.

I would like to know, is there any BAPI returning the affected organizational unit to a given user?

Thanks in advance,

Kind Regards,

Dariyoosh

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You can use Function Module RH_STRUC_GET


CALL FUNCTION 'RH_STRUC_GET'
  EXPORTING
     ACT_OTYPE = 'US'
     ACT_OBJID = user_name
     ACT_WEGID = 'US_CP_O'
  TABLES
       RESULT_TAB = LT_RESULT_TAB.

You will get the related org units in LT_RESULT_TAB. There are other two table parameters in that function module that you may find useful.

If the function does not return any valid data you may try with other values for WEGID. You will find all the possible evaluation paths in transaction OOAW.

Kind regards

3 REPLIES 3

Former Member
0 Kudos

You can use Function Module RH_STRUC_GET


CALL FUNCTION 'RH_STRUC_GET'
  EXPORTING
     ACT_OTYPE = 'US'
     ACT_OBJID = user_name
     ACT_WEGID = 'US_CP_O'
  TABLES
       RESULT_TAB = LT_RESULT_TAB.

You will get the related org units in LT_RESULT_TAB. There are other two table parameters in that function module that you may find useful.

If the function does not return any valid data you may try with other values for WEGID. You will find all the possible evaluation paths in transaction OOAW.

Kind regards

0 Kudos

You can use Function Module RH_STRUC_GET

>

>


> CALL FUNCTION 'RH_STRUC_GET'
>   EXPORTING
>      ACT_OTYPE = 'US'
>      ACT_OBJID = user_name
>      ACT_WEGID = 'US_CP_O'
>   TABLES
>        RESULT_TAB = LT_RESULT_TAB.
> 

>

> You will get the related org units in LT_RESULT_TAB. There are other two table parameters in that function module that you may find useful.

>

> If the function does not return any valid data you may try with other values for WEGID. You will find all the possible evaluation paths in transaction OOAW.

>

> Kind regards

Dear Alberto,

Thank you very much for your answer. I didn't know this FM and it solved my problem.

For those who may be intered here is exactly I proceed. Suppose that in the table HRP1000 you have an

structure (type S) with ObjID = 50000342 and you wish to have the SapUserID of the affected persons.


DATA:
      affected_users TYPE STANDARD TABLE OF swhactor,
      user LIKE LINE OF affected_users.

START-OF-SELECTION.


  CALL FUNCTION 'RH_STRUC_GET'
    EXPORTING
      act_otype              = 'S'
      act_objid              = '50000342'
      act_wegid              = 'A008'
      act_plvar              = '01'
      act_begda              = sy-datum
      act_endda              = sy-datum
      act_tdepth             = 0

   TABLES
     result_tab             = affected_users

 EXCEPTIONS
   NO_PLVAR_FOUND         = 1
   NO_ENTRY_FOUND         = 2
   OTHERS                 = 3
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


  LOOP AT affected_users INTO user.
    WRITE: / user-objid.
  ENDLOOP.

Also in transaction OOAW we can have all possible values for the third argument of the module function (act_wegid).

For those who are interested, here are a few among many possible values which seem to be intesting for my

problem.

DFPS_DG1----


Organizational Unit of User

DFPS_DG3----


All Org. Units Above a User

ORGAS----


Closest Organizational Unit and structure

ORGASS----


Closest Organizational Unit and structure

PPLEORG -


Organizational unit of an employee or position

SAP_ORGP----


Organizational assignments of a user/person

SAP_USOG----


Organizational Assignments of a User

SAP_US_S----


Positions and Personnel Number of a User

US_S_S_C----


All positions and jobs of a user

WFM_ORGU----


Organizational Assignment of User

WF_ORGUN----


Organizational unit of a user/person (module id Ben./Pers.)

For example, let's say we have a userid named MYUSER01 and we would like to find all structures to which the user

is affected. Here is how I proceed.


DATA:
      itab_user_structures TYPE STANDARD TABLE OF swhactor,
      row_user_structures LIKE LINE OF itab_user_structures.


START-OF-SELECTION.

CALL FUNCTION 'RH_STRUC_GET'
    EXPORTING
      act_otype              = 'US'
      act_objid              = 'MYUSER01'
      act_wegid              = 'US_S_S_C'
      act_plvar              = '01'
      act_begda              = sy-datum
      act_endda              = sy-datum
      act_tdepth             = 0

   TABLES
     result_tab             = itab_user_structures

 EXCEPTIONS
   NO_PLVAR_FOUND         = 1
   NO_ENTRY_FOUND         = 2
   OTHERS                 = 3


            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


  LOOP AT itab_user_structures INTO row_user_structures.
    WRITE: / row_user_structures-objid.
  ENDLOOP.

Thank you very much for your help.

Kind Regards,

Dariyoosh

gabriel_pill-kahan
Active Participant
0 Kudos

Hi,

You can try BAPI_USR01DOHR_GETEMPLOYEE to get the employee number from the user id. Then BAPI_EMPLOYEE_GETDATA to get the org assignment.