员工简历-获取多个人的照片及信息

FUNCTION ZHR_PA02.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     VALUE(IN_OBJID) TYPE  HROBJID OPTIONAL
*"     VALUE(IN_PERNR) TYPE  PERSNO OPTIONAL
*"     VALUE(IN_NACHN) TYPE  NACHN OPTIONAL
*"  TABLES
*"      RESULT_PA02 STRUCTURE  ZAPP_PA02
*"----------------------------------------------------------------------
  IF IN_OBJID IS NOT INITIAL.

    DATA:LT_STRUC LIKE TABLE OF STRUC WITH HEADER LINE,
         LT_OBJEC LIKE TABLE OF OBJEC WITH HEADER LINE.

    DATA:GT_STRUC LIKE TABLE OF STRUC WITH HEADER LINE,
         GT_OBJEC LIKE TABLE OF OBJEC WITH HEADER LINE,
         WT_OBJEC LIKE TABLE OF OBJEC WITH HEADER LINE.

    DATA:LS_CONNECT_INFO TYPE  TOAV0.
    DATA:LT_EX_DOCUMENT TYPE TABLE OF TBL1024,
         LS_EX_DOCUMENT TYPE TBL1024,
         LV_LEN         TYPE INT4.
    DATA:L_STRING  TYPE STRING,L_STRING1 TYPE STRING.
    DATA LV_IMAGE TYPE XSTRING.
    DATA:LENGTH  TYPE I,L_IMAGE TYPE XSTRING.

    DATA:URL             TYPE STRING,
         GUID            TYPE GUID_32,
         CACHED_RESPONSE TYPE REF TO IF_HTTP_RESPONSE.

    DATA:L_USRID LIKE PA0105-USRID.
    DATA:LINES TYPE I,NUM TYPE I.

    CALL FUNCTION 'RH_STRUC_GET'
      EXPORTING
        ACT_OTYPE      = 'O'
        ACT_OBJID      = IN_OBJID
        ACT_WEGID      = 'PERS-O'
*       ACT_INT_FLAG   =
        ACT_PLVAR      = '01'
        ACT_BEGDA      = SY-DATUM
        ACT_ENDDA      = SY-DATUM
      TABLES
*       RESULT_TAB     =
        RESULT_OBJEC   = LT_OBJEC
        RESULT_STRUC   = LT_STRUC
      EXCEPTIONS
        NO_PLVAR_FOUND = 1
        NO_ENTRY_FOUND = 2
        OTHERS         = 3.
    IF SY-SUBRC <> 0.
* Implement suitable error handling here
    ENDIF.

    DELETE LT_OBJEC WHERE OTYPE <> 'P'.
    SORT LT_OBJEC BY OBJID.
    DELETE ADJACENT DUPLICATES FROM LT_OBJEC COMPARING OBJID.

    LOOP AT LT_OBJEC.
      CLEAR:L_USRID.
      RESULT_PA02-PERNR = LT_OBJEC-OBJID.
      RESULT_PA02-NACHN = LT_OBJEC-SHORT.
      SELECT SINGLE GESCH INTO RESULT_PA02-GESCH FROM PA0002
        WHERE PERNR = RESULT_PA02-PERNR.
      SELECT SINGLE USRID INTO L_USRID FROM PA0105 WHERE PERNR = RESULT_PA02-PERNR
        AND USRTY = '0004'.
      RESULT_PA02-FLAG1 =  L_USRID.
      CONDENSE  RESULT_PA02-FLAG1.
      "职位
      CLEAR:GT_OBJEC,GT_OBJEC[],GT_STRUC,GT_STRUC[].
      CALL FUNCTION 'RH_STRUC_GET'
        EXPORTING
          ACT_OTYPE       = 'P'
          ACT_OBJID       = RESULT_PA02-PERNR
          ACT_WEGID       = 'ZPSCOO'
          ACT_PLVAR       = '01'
          ACT_BEGDA       = SY-DATUM
          ACT_ENDDA       = SY-DATUM
          AUTHORITY_CHECK = ''
        TABLES
          RESULT_OBJEC    = GT_OBJEC
          RESULT_STRUC    = GT_STRUC
        EXCEPTIONS
          NO_PLVAR_FOUND  = 1
          NO_ENTRY_FOUND  = 2
          OTHERS          = 3.
      WT_OBJEC[] = GT_OBJEC[].
      DELETE WT_OBJEC WHERE OTYPE NE 'S'.
      CLEAR:NUM.
      DESCRIBE TABLE WT_OBJEC LINES NUM.
      IF NUM > 1.    "如果有多个职位
        LOOP AT WT_OBJEC.
          SEARCH WT_OBJEC-STEXT FOR '党委'.
          IF SY-SUBRC = 0.
            WT_OBJEC-OBJID = 1.
            MODIFY WT_OBJEC.CLEAR WT_OBJEC.CONTINUE.
          ENDIF.
          IF WT_OBJEC-STEXT = '董事长'.
            WT_OBJEC-OBJID = 2.
            MODIFY WT_OBJEC.CLEAR WT_OBJEC.CONTINUE.
          ENDIF.
          SEARCH WT_OBJEC-STEXT FOR '集团董事'.
          IF SY-SUBRC = 0.
            WT_OBJEC-OBJID = 3.
            MODIFY WT_OBJEC.CLEAR WT_OBJEC.CONTINUE.
          ENDIF.
          SEARCH WT_OBJEC-STEXT FOR '集团监事'.
          IF SY-SUBRC = 0.
            WT_OBJEC-OBJID = 4.
            MODIFY WT_OBJEC.CLEAR WT_OBJEC.CONTINUE.
          ENDIF.
          SEARCH WT_OBJEC-STEXT FOR '集团'.
          IF SY-SUBRC = 0.
            WT_OBJEC-OBJID = 5.
            MODIFY WT_OBJEC.CLEAR WT_OBJEC.CONTINUE.
          ENDIF.
          SEARCH WT_OBJEC-STEXT FOR '股份公司董事长'.
          IF SY-SUBRC = 0.
            WT_OBJEC-OBJID = 6.
            MODIFY WT_OBJEC.CLEAR WT_OBJEC.CONTINUE.
          ENDIF.
          SEARCH WT_OBJEC-STEXT FOR '股份公司董事'.
          IF SY-SUBRC = 0.
            WT_OBJEC-OBJID = 7.
            MODIFY WT_OBJEC.CLEAR WT_OBJEC.CONTINUE.
          ENDIF.
          SEARCH WT_OBJEC-STEXT FOR '股份公司监事'.
          IF SY-SUBRC = 0.
            WT_OBJEC-OBJID = 8.
            MODIFY WT_OBJEC.CLEAR WT_OBJEC.CONTINUE.
          ENDIF.
          SEARCH WT_OBJEC-STEXT FOR '股份公司总经理'.
          IF SY-SUBRC = 0.
            WT_OBJEC-OBJID = 9.
            MODIFY WT_OBJEC.CLEAR WT_OBJEC.CONTINUE.
          ENDIF.
          SEARCH WT_OBJEC-STEXT FOR '股份公司副总经理'.
          IF SY-SUBRC = 0.
            WT_OBJEC-OBJID = 10.
            MODIFY WT_OBJEC.CLEAR WT_OBJEC.CONTINUE.
          ENDIF.
          SEARCH GT_OBJEC-STEXT FOR '事业部'.
          IF SY-SUBRC = 0.
            GT_OBJEC-OBJID = 11.
            MODIFY GT_OBJEC.CLEAR GT_OBJEC.CONTINUE.
          ENDIF.
        ENDLOOP.
      ENDIF.

      SORT WT_OBJEC BY OBJID.

      LOOP AT WT_OBJEC WHERE OTYPE = 'S'.
        IF RESULT_PA02-ZHIWEI IS INITIAL.
          RESULT_PA02-ZHIWEI = WT_OBJEC-STEXT.
        ELSE.
          CONCATENATE RESULT_PA02-ZHIWEI '/' WT_OBJEC-STEXT INTO RESULT_PA02-ZHIWEI.
        ENDIF.
*        delete WT_OBJEC.
*        SORT WT_OBJEC by begda.
      ENDLOOP.

      "读取照片地址
      CLEAR:LS_CONNECT_INFO.
      CALL FUNCTION 'HR_IMAGE_EXISTS'   "检查照片是否存在
        EXPORTING
          P_PERNR               = RESULT_PA02-PERNR
          P_TCLAS               = 'A'
          P_BEGDA               = '18000101'
          P_ENDDA               = '99991231'
        IMPORTING
*         P_EXISTS              =
          P_CONNECT_INFO        = LS_CONNECT_INFO
        EXCEPTIONS
          ERROR_CONNECTIONTABLE = 1
          OTHERS                = 2.

      CLEAR:LV_LEN,LT_EX_DOCUMENT,LT_EX_DOCUMENT[].
      CALL FUNCTION 'ALINK_RFC_TABLE_GET'   "获取照片LINK
        EXPORTING
          IM_DOCID    = LS_CONNECT_INFO-ARC_DOC_ID
          IM_CREPID   = 'A2'
*         IM_COMPID   =
        IMPORTING
          EX_LENGTH   = LV_LEN
*         EX_MESSAGE  =
        TABLES
          EX_DOCUMENT = LT_EX_DOCUMENT.

      CLEAR:LS_EX_DOCUMENT,L_STRING1,L_STRING,LV_IMAGE,L_IMAGE,LENGTH.
      LOOP AT LT_EX_DOCUMENT INTO LS_EX_DOCUMENT.
        L_STRING1 = LS_EX_DOCUMENT-LINE.
        CONCATENATE L_STRING L_STRING1 INTO L_STRING.
      ENDLOOP.
      LV_IMAGE = L_STRING.
      L_IMAGE = LV_IMAGE.
      LENGTH = XSTRLEN( L_IMAGE ).

      CLEAR:URL,GUID,CACHED_RESPONSE.
      CREATE OBJECT CACHED_RESPONSE
        TYPE
        CL_HTTP_RESPONSE
        EXPORTING
          ADD_C_MSG = 1.

      CACHED_RESPONSE->SET_DATA( LV_IMAGE ).
      CACHED_RESPONSE->SET_HEADER_FIELD(
      NAME = IF_HTTP_HEADER_FIELDS=>CONTENT_TYPE
      VALUE = 'image/pjpeg' ).

      CACHED_RESPONSE->SET_STATUS( CODE = 200 REASON = 'OK' ).
      CACHED_RESPONSE->SERVER_CACHE_EXPIRE_REL( EXPIRES_REL =
      180 ).

      CALL FUNCTION 'GUID_CREATE'
        IMPORTING
          EV_GUID_32 = GUID.

      CL_WD_UTILITIES=>CONSTRUCT_WD_URL( EXPORTING
      APPLICATION_NAME = 'ZPROTAL_PHOTO'
      IMPORTING OUT_LOCAL_URL = URL ).

      CONCATENATE URL '/' GUID SY-UZEIT INTO URL.
      CL_HTTP_SERVER=>SERVER_CACHE_UPLOAD(
      URL = URL
      RESPONSE = CACHED_RESPONSE ).

      RESULT_PA02-PIC_ID = URL.
      SHIFT RESULT_PA02-PIC_ID LEFT DELETING LEADING '0'.

      APPEND RESULT_PA02. CLEAR RESULT_PA02.
    ENDLOOP.
******************测试临时使用
    LOOP AT RESULT_PA02.
      IF IN_OBJID = '11000007'.
        IF RESULT_PA02-PERNR = '00000225' OR RESULT_PA02-PERNR = '00022240'.
          DELETE RESULT_PA02.
          CLEAR RESULT_PA02.
          CONTINUE.
        ENDIF.
      ENDIF.
    ENDLOOP.
*****************
    DESCRIBE TABLE RESULT_PA02 LINES LINES.
    IF LINES > 1.
      LOOP AT RESULT_PA02.
        READ TABLE LT_STRUC WITH KEY OBJID = RESULT_PA02-PERNR.
        IF SY-SUBRC = 0.
          RESULT_PA02-INDEX1 = LT_STRUC-SEQNR.
        ELSE.
          RESULT_PA02-INDEX1 = 99999.
        ENDIF.
        MODIFY RESULT_PA02.CLEAR RESULT_PA02.
      ENDLOOP.
      SORT RESULT_PA02 BY INDEX1.
    ENDIF.
  ELSE.
*    DATA:L_NACHN LIKE PA0002-NACHN.
*    CLEAR L_NACHN.
*    CONCATENATE '%' IN_NACHN '%' INTO L_NACHN.
*    IF IN_PERNR IS INITIAL .
*      SELECT PERNR NACHN INTO CORRESPONDING FIELDS OF TABLE RESULT_PA02
*        FROM PA0002 WHERE NACHN LIKE L_NACHN.
*    ELSE.
*      RESULT_PA02-PERNR = IN_PERNR.
*      SELECT SINGLE NACHN INTO RESULT_PA02-NACHN FROM PA0002
*        WHERE PERNR = RESULT_PA02-PERNR.
*      APPEND RESULT_PA02. CLEAR RESULT_PA02.
*    ENDIF.
*
*    LOOP AT RESULT_PA02.
*      "职位
*      CLEAR:GT_OBJEC,GT_OBJEC[],GT_STRUC,GT_STRUC[].
*      CALL FUNCTION 'RH_STRUC_GET'
*        EXPORTING
*          ACT_OTYPE       = 'P'
*          ACT_OBJID       = RESULT_PA02-PERNR
*          ACT_WEGID       = 'ZPSCOO'
*          ACT_PLVAR       = '01'
*          ACT_BEGDA       = SY-DATUM
*          ACT_ENDDA       = SY-DATUM
*          AUTHORITY_CHECK = ''
*        TABLES
*          RESULT_OBJEC    = GT_OBJEC
*          RESULT_STRUC    = GT_STRUC
*        EXCEPTIONS
*          NO_PLVAR_FOUND  = 1
*          NO_ENTRY_FOUND  = 2
*          OTHERS          = 3.
*      LOOP AT GT_OBJEC WHERE OTYPE = 'S'.
*        IF RESULT_PA02-ZHIWEI IS INITIAL.
*          RESULT_PA02-ZHIWEI = GT_OBJEC-STEXT.
*        ELSE.
*          CONCATENATE RESULT_PA02-ZHIWEI '/' GT_OBJEC-STEXT INTO RESULT_PA02-ZHIWEI.
*        ENDIF.
*      ENDLOOP.
*
*      "读取照片地址
*      CLEAR:LS_CONNECT_INFO.
*      CALL FUNCTION 'HR_IMAGE_EXISTS'   "检查照片是否存在
*        EXPORTING
*          P_PERNR               = RESULT_PA02-PERNR
*          P_TCLAS               = 'A'
*          P_BEGDA               = '18000101'
*          P_ENDDA               = '99991231'
*        IMPORTING
**         P_EXISTS              =
*          P_CONNECT_INFO        = LS_CONNECT_INFO
*        EXCEPTIONS
*          ERROR_CONNECTIONTABLE = 1
*          OTHERS                = 2.
*
*      CLEAR:LV_LEN,LT_EX_DOCUMENT,LT_EX_DOCUMENT[].
*      CALL FUNCTION 'ALINK_RFC_TABLE_GET'   "获取照片LINK
*        EXPORTING
*          IM_DOCID    = LS_CONNECT_INFO-ARC_DOC_ID
*          IM_CREPID   = 'A2'
**         IM_COMPID   =
*        IMPORTING
*          EX_LENGTH   = LV_LEN
**         EX_MESSAGE  =
*        TABLES
*          EX_DOCUMENT = LT_EX_DOCUMENT.
*
*      CLEAR:LS_EX_DOCUMENT,L_STRING1,L_STRING,LV_IMAGE,L_IMAGE,LENGTH.
*      LOOP AT LT_EX_DOCUMENT INTO LS_EX_DOCUMENT.
*        L_STRING1 = LS_EX_DOCUMENT-LINE.
*        CONCATENATE L_STRING L_STRING1 INTO L_STRING.
*      ENDLOOP.
*      LV_IMAGE = L_STRING.
*      L_IMAGE = LV_IMAGE.
*      LENGTH = XSTRLEN( L_IMAGE ).
*
*      CLEAR:URL,GUID,CACHED_RESPONSE.
*      CREATE OBJECT CACHED_RESPONSE
*        TYPE
*        CL_HTTP_RESPONSE
*        EXPORTING
*          ADD_C_MSG = 1.
*
*      CACHED_RESPONSE->SET_DATA( LV_IMAGE ).
*      CACHED_RESPONSE->SET_HEADER_FIELD(
*      NAME = IF_HTTP_HEADER_FIELDS=>CONTENT_TYPE
*      VALUE = 'image/pjpeg' ).
*
*      CACHED_RESPONSE->SET_STATUS( CODE = 200 REASON = 'OK' ).
*      CACHED_RESPONSE->SERVER_CACHE_EXPIRE_REL( EXPIRES_REL =
*      180 ).
*
*      CALL FUNCTION 'GUID_CREATE'
*        IMPORTING
*          EV_GUID_32 = GUID.
*
*      CL_WD_UTILITIES=>CONSTRUCT_WD_URL( EXPORTING
*      APPLICATION_NAME = 'ZPROTAL_PHOTO'
*      IMPORTING OUT_LOCAL_URL = URL ).
*
*      CONCATENATE URL '/' GUID SY-UZEIT INTO URL.
*      CL_HTTP_SERVER=>SERVER_CACHE_UPLOAD(
*      URL = URL
*      RESPONSE = CACHED_RESPONSE ).
*
*      RESULT_PA02-PIC_ID = URL.
*      SHIFT RESULT_PA02-PIC_ID LEFT DELETING LEADING '0'.
*      MODIFY RESULT_PA02.CLEAR RESULT_PA02.
*    ENDLOOP.
  ENDIF.
  LOOP AT  RESULT_PA02 .
    IF RESULT_PA02-NACHN IS INITIAL.
      DELETE RESULT_PA02.CLEAR RESULT_PA02.
    ENDIF.

  ENDLOOP.




ENDFUNCTION.

,

posted @ 2019-11-08 13:25  蜡哲图  阅读(208)  评论(0编辑  收藏  举报
目录内容