cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete a support group

andershpedersen
Explorer
0 Kudos

Hi,

we had a restructuring of our support group structure in E-rec, and therefore I am tasked with deleting the old ones.

When trying to do this, though, I am met with an error, that this support group is still in use and can't be deleted.

Now - is there an easy way, to figure out where this support group is still used?

I could go through all requisitions, but with 1000+ I don't whish to do that.

I guess I could also do some table gymnastics and find the NG numbers in HRP5151, find the name of those through class CL_HRRCF_HRKWF_STORAGE and then somehow figure out which requisitions/groups they are related to.

But that also looks like quite a big job with low output. 😕

So - anyone has an idea? 🙂

/Anders

Accepted Solutions (1)

Accepted Solutions (1)

romanweise
Active Contributor
0 Kudos

Hi Anders,

it is in deed a bit unfortunate that the title of the support group is not stored in IT 5151. Otherwise it would be much easier to get the information you need. The fastest way is a quick program which gathers the data. I threw together some lines of code which should do the trick (they are not optimizes are will win a beauty contest 😞

REPORT  zroweis_get_sugr_usage.
* local data declaration
DATA:
  lo_requ_hdl  TYPE REF TO            cl_hrrcf_requi_bl,
  lo_sugr_hdl  TYPE REF TO            cl_hrrcf_supp_group_bl,

  ls_sugr_key  TYPE                   hrobject,
  ls_requ_key  TYPE                   hrobject,
  lt_requ_key  TYPE                   hrobject_tab,

  ls_rel_key   TYPE                   rcf_s_rel_object,

  ls_requ_info TYPE                   p5125,
  ls_sugr_info TYPE                   rcf_s_sgr_info_txt,

  ls_agency    TYPE                   t77rcf_agency,
  lv_agency    TYPE                   bu_nameor1,

  ls_p5151     TYPE                   hrp5151,
  lt_p5151     TYPE STANDARD TABLE OF hrp5151.

* get instance of handle classes
lo_requ_hdl = cl_hrrcf_requi_bl=>get_instance( ).
lo_sugr_hdl = cl_hrrcf_supp_group_bl=>get_instance( ).

* get list of all support groups defined in the system
SELECT * FROM hrp5151 INTO TABLE lt_p5151
  WHERE
    endda = '99991231'.

* check the usage in support teams of requisition
WRITE: / 'USAGE OF SUPPORT GROUPS IN SUPPORT TEAMS:'. ULINE.

LOOP AT lt_p5151 INTO ls_p5151.
  CLEAR:
    ls_sugr_key,
    ls_sugr_info,
    ls_requ_key,
    lt_requ_key.

  ls_sugr_key-plvar = ls_p5151-plvar.
  ls_sugr_key-otype = ls_p5151-otype.
  ls_sugr_key-objid = ls_p5151-objid.

  SELECT plvar otype objid FROM hrp5131 INTO TABLE lt_requ_key
    WHERE
      otype EQ 'NB'              AND
      sclas EQ ls_sugr_key-otype AND
      sobid EQ ls_sugr_key-objid.

  SORT lt_requ_key BY objid.
  DELETE ADJACENT DUPLICATES FROM lt_requ_key COMPARING objid.

  IF lt_requ_key IS NOT INITIAL.
    lo_sugr_hdl->get_supp_group_info(
      EXPORTING
        ps_supp_group   = ls_sugr_key
      IMPORTING
        ps_sgr_info_txt = ls_sugr_info ).

    WRITE: / 'Usage of Support Group', ls_sugr_key-objid, ls_sugr_info-title_txt.
  ELSE.
    CONTINUE.
  ENDIF.

  LOOP AT lt_requ_key INTO ls_requ_key.
    CLEAR ls_requ_info.

    lo_requ_hdl->get_req_basic_info(
      EXPORTING
        ps_req_hrobject   = ls_requ_key
      IMPORTING
        ps_req_basic_info = ls_requ_info ).

    WRITE: /5 ls_requ_key-objid, ls_requ_info-header.
  ENDLOOP.

  SKIP.
ENDLOOP.

* check assignment to agencies
WRITE: / 'USAGE OF SUPPORT GROUPS FOR AGENCIES:'. ULINE.

LOOP AT lt_p5151 INTO ls_p5151.
  CLEAR:
    ls_agency,
    lv_agency,
    ls_rel_key,
    ls_sugr_key,
    ls_sugr_info.

  ls_sugr_key-plvar =              ls_p5151-plvar.
  ls_sugr_key-otype = ls_rel_key = ls_p5151-otype.
  ls_sugr_key-objid = ls_rel_key = ls_p5151-objid.

  lo_sugr_hdl->get_supp_group_info(
    EXPORTING
      ps_supp_group   = ls_sugr_key
    IMPORTING
      ps_sgr_info_txt = ls_sugr_info ).

  IF ls_sugr_info-role = '09'.
    cl_hrrcf_agency_bl=>check_rel_object_assignment(
      EXPORTING
        ps_rel_object = ls_rel_key
      IMPORTING
        ps_agency     = ls_agency ).

    IF ls_agency IS NOT INITIAL.
      cl_hrrcf_agency_bl=>get_agency_name(
        EXPORTING
          p_agency_id   = ls_agency-agency
        IMPORTING
          p_agency_name = lv_agency ).

      WRITE:/ 'Usage of Support Group', ls_sugr_key-objid, ls_sugr_info-title_txt,
              '-', ls_agency-agency, lv_agency.
    ENDIF.
  ENDIF.
ENDLOOP.

Hope that helps.

Kind regards

Roman

andershpedersen
Explorer
0 Kudos

Hi Roman,

thanks for your answer! I'll need some time to try your suggestion out - will get back to you when I done that. 🙂

/Anders

Answers (0)