Tuesday, May 28, 2013

Steps to get Reporting manager 

  • Method 1: Use function module RH_STRUC_GET with evaluation path 'BOSSONLY'
  • Method 2: Use function module RH_READ_INFTY_1001 with Subtype 'B012'(Is managed by).

Method 1:


  CALL FUNCTION 'RH_STRUC_GET'
    EXPORTING
      ACT_OTYPE      = 'O'
      ACT_OBJID      = ORGEH
      ACT_WEGID      = 'BOSSONLY'
      ACT_PLVAR      = '01'
      ACT_BEGDA      = SY-DATUM
      ACT_ENDDA      = SY-DATUM
*     ACT_TDEPTH     = 0
    TABLES
*     result_tab     = lt_result_tab
      RESULT_OBJEC   = LT_RESULT_OBJEC
*     result_struc   = lt_result_struc
    EXCEPTIONS
      NO_PLVAR_FOUND = 1
      NO_ENTRY_FOUND = 2.

Method 2:

  1. Get position of manager using Employee Org.unit.
  2. *&-------------------------------------------------------------------*
    *&      Form  GET_POS_OF_MANAGER
    *&-------------------------------------------------------------------*
    FORM GET_POS_OF_MANAGER  USING    P_ORGEH
                                      P_BEGDA
                                      P_ENDDA
                             CHANGING P_PLANS P_SUBRC.
    
      DATA:LT_1001 TYPE STANDARD TABLE OF P1001 WITH HEADER LINE.
      "Get Position >Who manages Org.Unit
      CALL FUNCTION 'RH_READ_INFTY_1001'
        EXPORTING
          AUTHORITY        = 'DISP'
          WITH_STRU_AUTH   = 'X'
          PLVAR            = '01'
          OTYPE            = 'O'
          OBJID            = P_ORGEH
          ISTAT            = '1'
          SUBTY            = 'B012'
          BEGDA            = P_BEGDA
          ENDDA            = P_ENDDA
        TABLES
          I1001            = LT_1001
        EXCEPTIONS
          NOTHING_FOUND    = 1
          WRONG_CONDITION  = 2
          WRONG_PARAMETERS = 3
          OTHERS           = 4.
      P_SUBRC = SY-SUBRC.
      SORT LT_1001 DESCENDING BY ENDDA.
      DELETE LT_1001 WHERE SCLAS <> 'S'.
      READ TABLE LT_1001 INDEX 1.
      CHECK SY-SUBRC = 0.
      P_PLANS = LT_1001-SOBID.
    
    ENDFORM.                    " GET_POS_OF_MANAGER
  3. If manager position is not found,
    1. Get next level org.Unit to whom employee org.unit is reporting to.
      *&--------------------------------------------------------------*
      *&      Form  GET_NEXTLVL_ORGUNIT
      *&--------------------------------------------------------------*
      FORM GET_NEXTLVL_ORGUNIT  USING    P_ORGEH
                                         P_BEGDA
                                         P_ENDDA
                                CHANGING P_ORGEH_N
                                         P_SUBRC.
      
        DATA:LT_1001 TYPE STANDARD TABLE OF P1001 WITH HEADER LINE.
      
        CALL FUNCTION 'RH_READ_INFTY_1001'
          EXPORTING
            AUTHORITY        = 'DISP'
            WITH_STRU_AUTH   = 'X'
            PLVAR            = '01'
            OTYPE            = 'O'
            OBJID            = P_ORGEH
            ISTAT            = '1'
            SUBTY            = 'A002'
            BEGDA            = P_BEGDA
            ENDDA            = P_ENDDA
          TABLES
            I1001            = LT_1001
          EXCEPTIONS
            NOTHING_FOUND    = 1
            WRONG_CONDITION  = 2
            WRONG_PARAMETERS = 3
            OTHERS           = 4.
        P_SUBRC = SY-SUBRC.
        SORT LT_1001 DESCENDING BY BEGDA ENDDA.
        DELETE LT_1001 WHERE SCLAS <> 'O'.
        READ TABLE LT_1001 INDEX 1.
        CHECK SY-SUBRC = 0.
        P_ORGEH_N = LT_1001-SOBID.
      
      ENDFORM.                    " GET_NEXTLVL_ORGUNIT
    2. Get position of manager using Org.unit which we got in the last step.
      *&-------------------------------------------------------------*
      *&      Form  GET_POS_OF_MANAGER
      *&-------------------------------------------------------------*
      FORM GET_POS_OF_MANAGER  USING    P_ORGEH
                                        P_BEGDA
                                        P_ENDDA
                               CHANGING P_PLANS P_SUBRC.
      
        DATA:LT_1001 TYPE STANDARD TABLE OF P1001 WITH HEADER LINE.
        "Get Position >Who manages Org.Unit
        CALL FUNCTION 'RH_READ_INFTY_1001'
          EXPORTING
            AUTHORITY        = 'DISP'
            WITH_STRU_AUTH   = 'X'
            PLVAR            = '01'
            OTYPE            = 'O'
            OBJID            = P_ORGEH
            ISTAT            = '1'
            SUBTY            = 'B012'
            BEGDA            = P_BEGDA
            ENDDA            = P_ENDDA
          TABLES
            I1001            = LT_1001
          EXCEPTIONS
            NOTHING_FOUND    = 1
            WRONG_CONDITION  = 2
            WRONG_PARAMETERS = 3
            OTHERS           = 4.
        P_SUBRC = SY-SUBRC.
        SORT LT_1001 DESCENDING BY ENDDA.
        DELETE LT_1001 WHERE SCLAS <> 'S'.
        READ TABLE LT_1001 INDEX 1.
        CHECK SY-SUBRC = 0.
        P_PLANS = LT_1001-SOBID.
      
      ENDFORM.                    " GET_POS_OF_MANAGER
    3. Use steps (I) and (II) until we find the position of manager. 
  4. If manager position is found.
  5. Get Manager Employee number.
    CALL FUNCTION 'RH_READ_INFTY_1001'
        EXPORTING
          AUTHORITY        = 'DISP'
          WITH_STRU_AUTH   = 'X'
          PLVAR            = '01'
          OTYPE            = 'S'
          OBJID            = P_PLANS
          ISTAT            = '1'
          SUBTY            = 'A008'
          BEGDA            = P_BEGDA
          ENDDA            = P_ENDDA
        TABLES
          I1001            = LT_1001
        EXCEPTIONS
          NOTHING_FOUND    = 1
          WRONG_CONDITION  = 2
          WRONG_PARAMETERS = 3
          OTHERS           = 4.
      SORT LT_1001 DESCENDING BY ENDDA.
      DELETE LT_1001 WHERE SCLAS <> 'P'.
      READ TABLE LT_1001 INDEX 1.
      CHECK SY-SUBRC = 0.
      P_PERNR    = LT_1001-SOBID.
    

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.