HR函数及参数

记录一下用过的几个HR函数,备忘

信息类型获取:适用于单个人员编号查询,并且涉及权限。

  CALL FUNCTION 'HR_READ_INFOTYPE'
    EXPORTING
*     TCLAS           = 'A'
      pernr           = ps_zpernr "人员编号
      infty           = ps_field "信息类型
      begda           = ps_bdate "开始时间
      endda           = ps_edate "结束时间
*     BYPASS_BUFFER   = ' '
*     LEGACY_MODE     = ' '
    IMPORTING
      subrc           = lv_subrc
    TABLES
      infty_tab       = pt_tab ”查询结果内表
    EXCEPTIONS
      infty_not_found 1
      OTHERS          2.
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.

信息类型修改:单个人员编号单个信息类型修改

                              CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'  "锁定人员编号
                  EXPORTING
                    number = lt_pa0022-pernr.

                CALL FUNCTION 'HR_INFOTYPE_OPERATION'
                  EXPORTING
                    infty         '0022'
                    number        = lt_pa0022-pernr "人员编号
                    record        = lt_pa0022 "修改内容,需要参考p****结构,不能参考pa表
                    operation     = lv_actio "操作方式(INS/MOD/DEL) 
                    validityend   = ls_pa0022-endda
                    validitybegin = ls_pa0022-begda
                  IMPORTING
                    return        = lt_bapireturn. "返回消息

                 

                CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'  "解锁人员编号
                  EXPORTING
                    number = lt_pa0022-pernr.

 人员,职位,部门信息获取函数

RH_STRUC_GET 根据 act_otype、act_wegid 参数不同作用不同

eg:

'P' 'P-S-O'  : 人-职位-部门

'P' 'P-S-O-O'  : 人-职位-部门-上层部门(查到最上层部门)

'S' 'PEGET_P' :根据职位查找人员

        CALL FUNCTION 'RH_STRUC_GET'
          EXPORTING
            act_otype       'P'
            act_objid       = it_rsbd-pernr
            act_wegid       'P-S-O'
*           ACT_INT_FLAG    =
*           ACT_PLVAR       = ' '
            act_begda       = it_rsbd-begda
            act_endda       = it_rsbd-endda
*           ACT_TDEPTH      = 0
            act_tflag       'X'
            act_vflag       'X'
            authority_check 'X'
*           TEXT_BUFFER_FILL       =
*           BUFFER_MODE     =
*     IMPORTING
*           ACT_PLVAR       =
          TABLES
*           RESULT_TAB      =
            result_objec    = lt_objec
*           RESULT_STRUC    =
          EXCEPTIONS
            no_plvar_found  1
            no_entry_found  2
            OTHERS          3.

 获取工作日历

    CALL FUNCTION 'DAY_ATTRIBUTES_GET'
      EXPORTING
        factory_calendar           'CN'
        holiday_calendar           'CN'
        date_from                  = ls_input-bdate
        date_to                    = ls_input-edate
*       language                   = sy-langu
        non_iso                    ''
      IMPORTING
        year_of_valid_from         = year_of_valid_from
        year_of_valid_to           = year_of_valid_to
        returncode                 = returncode
      TABLES
        day_attributes             = lt_day_attributes
      EXCEPTIONS
        factory_calendar_not_found 1
        holiday_calendar_not_found 2
        date_has_invalid_format    3
        date_inconsistency         4
        OTHERS                     5.

获取工作日(也可以查表T552A)

      CALL FUNCTION 'HR_GENERATE_WORK_SCHEDULE'
        EXPORTING
          zeity         '2'
          mofid         'CN'
          mosid         '01'
          schkz         'NORM'
          begjahr       = ls_input-bdate(4)
          begmonat      = ls_input-bdate+4(2)
          endjahr       = ls_input-edate(4)
          endmonat      = ls_input-edate+4(2)
        TABLES
          int552a       = lt_t552a
        EXCEPTIONS
          error_occured 1
          OTHERS        2.

你可能感兴趣的:(HR函数及参数)