首页 > 代码库 > HR函数学习02——分配组织单位

HR函数学习02——分配组织单位

REPORT ZLYHR01."创建组织单元  成功DATA:LS_OBJ    TYPE OBJEC,     LV_STU    TYPE GDSTR-SVECT,     LV_TIT    TYPE CHAR20,     LV_SUBTYP TYPE SUBTYP,     LS_P1000  TYPE P1000,     LT_P1000  TYPE TABLE OF P1000.DATA:LT_HRI1001 TYPE TABLE OF HRI1001,     LS_HRI1001 TYPE HRI1001.LS_OBJ-OTYPE = O."对象类型LS_OBJ-PLVAR = 01."计划版本"创建组织单元CALL FUNCTION RH_OBJECT_CREATE  EXPORTING*   LANGU               = SY-LANGU    PLVAR               = LS_OBJ-PLVAR    OTYPE               = LS_OBJ-OTYPE*   EXT_NUMBER          = ‘00000000‘    SHORT               = 测试组织单1元    STEXT               = 测试组织单1元*   BEGDA               = SY-DATUM*   ENDDA               = ‘99991231‘*   OSTAT               = ‘1‘*   VTASK               = ‘D‘*   GUID                =*   KEEP_LUPD           = ‘ ‘  IMPORTING    OBJID               = LS_OBJ-OBJID  EXCEPTIONS    TEXT_REQUIRED       = 1    INVALID_OTYPE       = 2    INVALID_DATE        = 3    ERROR_DURING_INSERT = 4    ERROR_EXT_NUMBER    = 5    UNDEFINED           = 6.IF SY-SUBRC = 0.  CALL FUNCTION BAPI_TRANSACTION_COMMIT    EXPORTING      WAIT = X.  LS_HRI1001-PLVAR = 01.  LS_HRI1001-OTYPE = O.  LS_HRI1001-OBJID = LS_OBJ-OBJID.  LS_HRI1001-INFTY = A002.  LS_HRI1001-RSIGN = A.  LS_HRI1001-RELAT = 002.  LS_HRI1001-ISTAT = 1.  LS_HRI1001-BEGDA = SY-DATUM.  LS_HRI1001-ENDDA = 99991231.  LS_HRI1001-SCLAS = O.  LS_HRI1001-SOBID = 50000101.  CONCATENATE O 50000101 INTO LS_HRI1001-VARYF."上级节点  APPEND LS_HRI1001 TO LT_HRI1001.  "创建组织单元与上级组织单元的关系  CALL FUNCTION RH_RELATION_WRITE*   EXPORTING*     VTASK                      = ‘D‘*     KEEP_LUPD                  = ‘ ‘    TABLES      RELATION             = LT_HRI1001*     ERR_RELATION         =    EXCEPTIONS      NO_AUTHORITY         = 1      RELATION_NOT_ALLOWED = 2      OBJECT_NOT_FOUND     = 3      WRONG_DATE_FORMAT    = 4      TIME_NOT_VALID       = 5      ERROR_DURING_INSERT  = 6      UNDEFINED            = 7.  IF SY-SUBRC = 0.    CALL FUNCTION BAPI_TRANSACTION_COMMIT      EXPORTING        WAIT = X.    WRITE LS_OBJ-OBJID.  ELSE.    CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.    WRITE: FAILD RELA , LS_OBJ-OBJID.  ENDIF.ELSE.  CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.ENDIF.

 

HR函数学习02——分配组织单位