<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Get all the users with some attributes in Spend Management Q&amp;A</title>
    <link>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583779#M134236</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use ''O-O_DOWN''. Values come from table &lt;STRONG&gt;T778A&lt;/STRONG&gt; (evaluation patch).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Laurent.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jan 2012 14:17:32 GMT</pubDate>
    <dc:creator>laurent_burtaire</dc:creator>
    <dc:date>2012-01-31T14:17:32Z</dc:date>
    <item>
      <title>Get all the users with some attributes</title>
      <link>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaq-p/8583775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know any FM to obtain all the users with some attribute? &lt;/P&gt;&lt;P&gt;For example, I want to get all the users with the attribute Company Code (BUK) equal to '0180' or i want to know all the users with the attribute Cost Center (CNT) equal to 1000000000, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I usually use the FM BBP_READ_ATTRIBUTES for read the attributes of one specific user in PPOSA_BBP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know if exits some FM or other way to obtain it or if I need to create a FM to do some selects statements to the tables HRP1001, HRV1222A, etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ricardo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 11:10:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaq-p/8583775</guid>
      <dc:creator>RicardoRomero_1</dc:creator>
      <dc:date>2012-01-30T11:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get all the users with some attributes</title>
      <link>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583776#M134233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ricardo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;there is no standard function module covering your request.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One solution could be :&lt;/P&gt;&lt;P&gt;1-Get objects O and S having attributeu2019s value you look for by selection from &lt;EM&gt;HRV1222A&lt;/EM&gt; view&lt;/P&gt;&lt;P&gt;1.1 For object type u2018Ou2019, get all organizational units below current organizational unit using &lt;STRONG&gt;RH_STRUCT_GET&lt;/STRONG&gt; function module&lt;/P&gt;&lt;P&gt;a- Get users from each OU found above using &lt;STRONG&gt;BBP_OM_STRUC_GET_USER_FROM_ORG&lt;/STRONG&gt; function module&lt;/P&gt;&lt;P&gt;b- For each user, get attribute values using &lt;STRONG&gt;HR_GENAT_READ_ATTRIBUTES&lt;/STRONG&gt; function module.&lt;/P&gt;&lt;P&gt;c- Check useru2019s attribute values are not excluded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.2 For object type u2018Su2019, do steps b and c from paragraph 1.1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Laurent.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 13:35:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583776#M134233</guid>
      <dc:creator>laurent_burtaire</dc:creator>
      <dc:date>2012-01-30T13:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get all the users with some attributes</title>
      <link>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583777#M134234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Laurent ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm going to create a test report for test your solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This morning I did a sql trace for know the tables used, and I did another test report and It seems that works fine.&lt;/P&gt;&lt;P&gt;But, I don't like my solution so much. There are too many nested selects statements and loops...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  ztest_ricardo.
TABLES: but000, hrp1001, hrv1222a.

PARAMETERS: p_attrib LIKE hrv1222a-attrib OBLIGATORY DEFAULT 'BUK',
            p_value  LIKE hrv1222a-low OBLIGATORY DEFAULT 'EC1CLNT200\0180'.

START-OF-SELECTION.

  DATA: lt_hrv1222a TYPE hrv1222a OCCURS 0 WITH HEADER LINE.

  SELECT * FROM hrv1222a INTO TABLE lt_hrv1222a
    WHERE plvar EQ '01'
      AND begda LE sy-datum
      AND endda GE sy-datum
      AND istat EQ '1'
      AND attrib EQ p_attrib
      AND low EQ p_value.

  LOOP AT lt_hrv1222a.

    SELECT SINGLE * FROM hrp1001
     WHERE plvar EQ '01'
       AND otype EQ lt_hrv1222a-otype
       AND objid EQ lt_hrv1222a-objid
       AND subty EQ 'A002'
       AND istat EQ '1'
       AND begda LE sy-datum
       AND endda GE sy-datum
       AND sclas EQ 'O'.
    CHECK sy-subrc EQ 0.

    SELECT * FROM hrp1001
     WHERE plvar EQ '01'
       AND varyf EQ hrp1001-otjid
       AND subty EQ 'A003'
       AND istat EQ '1'
       AND begda LE sy-datum
       AND endda GE sy-datum
       AND sclas EQ 'O'.
      CHECK sy-subrc EQ 0.

      SELECT SINGLE * FROM hrp1001
       WHERE plvar EQ '01'
         AND varyf EQ hrp1001-otjid
         AND subty EQ 'B008'
         AND istat EQ '1'
         AND begda LE sy-datum
         AND endda GE sy-datum
         AND sclas EQ 'S'.
      CHECK sy-subrc EQ 0.

      SELECT SINGLE * FROM hrp1001
       WHERE plvar EQ '01'
         AND sclas EQ 'US'
         AND otype EQ hrp1001-otype
         AND objid EQ hrp1001-objid
         AND begda LE sy-datum
         AND endda GE sy-datum
         AND otype EQ 'CP'
         AND subty EQ 'B208'.
      IF sy-subrc EQ 0.
        WRITE: / hrp1001-sobid.
      ENDIF.
    ENDSELECT.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 15:16:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583777#M134234</guid>
      <dc:creator>RicardoRomero_1</dc:creator>
      <dc:date>2012-01-30T15:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Get all the users with some attributes</title>
      <link>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583778#M134235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Laurent,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know how to use the FM &lt;STRONG&gt;RH_STRUC_GET&lt;/STRONG&gt; . &lt;/P&gt;&lt;P&gt;What I need to pass in parameter &lt;STRONG&gt;ACT_WEGID&lt;/STRONG&gt; ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ricardo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 12:21:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583778#M134235</guid>
      <dc:creator>RicardoRomero_1</dc:creator>
      <dc:date>2012-01-31T12:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Get all the users with some attributes</title>
      <link>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583779#M134236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use ''O-O_DOWN''. Values come from table &lt;STRONG&gt;T778A&lt;/STRONG&gt; (evaluation patch).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Laurent.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 14:17:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583779#M134236</guid>
      <dc:creator>laurent_burtaire</dc:creator>
      <dc:date>2012-01-31T14:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get all the users with some attributes</title>
      <link>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583780#M134237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help. With my test report didn't works fine, Now is working perfect with your solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  ztest_ricardo.
TABLES: hrv1222a.

PARAMETERS: p_attrib LIKE hrv1222a-attrib OBLIGATORY DEFAULT 'BUK',
            p_value  LIKE hrv1222a-low OBLIGATORY DEFAULT 'EC1CLNT200\0176'.

START-OF-SELECTION.

   DATA: lt_hrv1222a     TYPE hrv1222a OCCURS 0 WITH HEADER LINE,
        lt_result_struc TYPE struc OCCURS 0 WITH HEADER LINE,
        lt_result_obj   TYPE objec OCCURS 0 WITH HEADER LINE,
        lt_start_obj    TYPE hrtb_object WITH HEADER LINE,
        lt_users        TYPE hrbcitb_user WITH HEADER LINE,
        lt_user_tab     TYPE hrbcitb_user WITH HEADER LINE,
        lt_attributes   TYPE hrtb_attrib WITH HEADER LINE,
        lt_attrib_ext   TYPE hrtb_attvalrt WITH HEADER LINE,
        lv_realo        TYPE realo.

  SELECT * FROM hrv1222a INTO TABLE lt_hrv1222a
    WHERE plvar EQ '01'
      AND begda LE sy-datum
      AND endda GE sy-datum
      AND istat EQ '1'
      AND attrib EQ p_attrib
      AND low EQ p_value.

  LOOP AT lt_hrv1222a.

    IF lt_hrv1222a-otype EQ 'O'.

      REFRESH: lt_result_struc.
      CALL FUNCTION 'RH_STRUC_GET'
        EXPORTING
          act_otype      = lt_hrv1222a-otype
          act_objid      = lt_hrv1222a-objid
          act_wegid      = 'O-O_DOWN'
        TABLES
          result_struc   = lt_result_struc[]
        EXCEPTIONS
          no_plvar_found = 1
          no_entry_found = 2
          OTHERS         = 3.
      CHECK lt_result_struc[] IS NOT INITIAL.

      LOOP AT lt_result_struc.
        REFRESH: lt_start_obj, lt_user_tab.
        lt_start_obj-otype = lt_result_struc-otype.
        lt_start_obj-objid = lt_result_struc-objid.
        APPEND lt_start_obj.
        CALL FUNCTION 'BBP_OM_STRUC_GET_USER_FROM_ORG'
          EXPORTING
            start_objects           = lt_start_obj[]
          IMPORTING
            user_tab                = lt_user_tab[]
          EXCEPTIONS
            path_not_found          = 1
            error_reading_structure = 2
            no_roots                = 3
            invalid_roots           = 4
            internal_error          = 5
            OTHERS                  = 6.
        APPEND LINES OF lt_user_tab TO lt_users.
      ENDLOOP.

    ELSE. "S

      REFRESH: lt_result_obj.
      CALL FUNCTION 'RH_STRUC_GET'
        EXPORTING
          act_otype      = lt_hrv1222a-otype
          act_objid      = lt_hrv1222a-objid
          act_wegid      = 'O-O_DOWN'
        TABLES
          result_objec   = lt_result_obj[]
        EXCEPTIONS
          no_plvar_found = 1
          no_entry_found = 2
          OTHERS         = 3.
      LOOP AT lt_result_obj.
        lt_users-orgobjid-otype = lt_result_obj-otype.
        lt_users-orgobjid-objid = lt_result_obj-objid.
        lt_users-uname          = lt_result_obj-short.
        APPEND lt_users. CLEAR lt_users.
      ENDLOOP.

    ENDIF.

  ENDLOOP.

  SORT lt_users.
  DELETE ADJACENT DUPLICATES FROM lt_users.
  APPEND p_attrib TO lt_attributes.
  LOOP AT lt_users.

    AT NEW orgobjid-objid.
      REFRESH: lt_attrib_ext.
      lv_realo = lt_users-orgobjid-objid.
      CALL FUNCTION 'HR_GENAT_READ_ATTRIBUTES'
        EXPORTING
          scenario          = 'BBP'
          otype             = lt_users-orgobjid-otype
          realo             = lv_realo
          attributes        = lt_attributes[]
        IMPORTING
          attrib_ext        = lt_attrib_ext[]
        EXCEPTIONS
          internal_error    = 1
          invalid_object    = 2
          invalid_scenario  = 3
          invalid_attribute = 4
          no_authority      = 5
          OTHERS            = 6.
    ENDAT.
    READ TABLE lt_attrib_ext WITH KEY low = p_value.
    IF sy-subrc EQ 0.
       WRITE:/ lt_users-uname.
    ENDIF.
  ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 16:19:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/get-all-the-users-with-some-attributes/qaa-p/8583780#M134237</guid>
      <dc:creator>RicardoRomero_1</dc:creator>
      <dc:date>2012-01-31T16:19:36Z</dc:date>
    </item>
  </channel>
</rss>

