Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata
*&---------------------------------------------------------------------*
*& Report ZEMPLOYEE
*& Created By : Shaveta Prabhakar
*&---------------------------------------------------------------------*
*& Function Modules: HR_GET_EMPLOYEE_DATA
*& HR_IMAGE_EXISTS
*& SCMS_DOC_URL_READ
*& HR_IMAGE_RESET
*& Class & Methods : CL_GUI_DOCKING_CONTAINER
*& CL_GUI_PICTURE->SET_POSITION
*& CL_GUI_PICTURE->SET_DISPLAY_MODE
*& CL_GUI_PICTURE->DISPLAY_MODE_FIT
*& CL_GUI_PICTURE->LOAD_PICTURE_FROM_URL_ASYNC
*&---------------------------------------------------------------------*
REPORT zemployee.
TABLES: pa0001, person.
DATA: docking_cont TYPE REF TO cl_gui_docking_container, " Custom Container
      picture TYPE REF TO cl_gui_picture.
DATA: itab_empdata LIKE TABLE OF person.
DATA: itab_data LIKE TABLE OF person WITH HEADER LINE.
DATA: p_connect_info LIKE TABLE OF toav0 WITH HEADER LINE.
DATA: p_document_type LIKE toav0-reserve.
DATA: url(255) TYPE c.
DATA: handle TYPE i.
DATA: ppernr TYPE pa0001-pernr.
SELECTION-SCREEN BEGIN OF BLOCK b1 .
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN COMMENT 40(25) text-010 .
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 20(15) text-002 FOR FIELD pernr.
PARAMETERS pernr TYPE pa0001-pernr.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 20(15) text-008 FOR FIELD ename.
PARAMETERS ename TYPE pa0001-ename.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 20(15) text-003 FOR FIELD persg.
PARAMETERS persg TYPE pa0001-persg.
SELECTION-SCREEN COMMENT 45(15) text-009 FOR FIELD werks.
PARAMETERS werks TYPE pa0001-werks.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 20(15) text-004 FOR FIELD persk.
PARAMETERS persk TYPE pa0001-persk.
SELECTION-SCREEN COMMENT 45(15) text-005 FOR FIELD kostl.
PARAMETERS kostl TYPE pa0001-kostl.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 20(15) text-006 FOR FIELD orgeh.
PARAMETERS orgeh TYPE pa0001-orgeh.
PARAMETERS orgehtxt TYPE person-orgeh_txt .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 20(15) text-007 FOR FIELD plans.
PARAMETERS plans TYPE pa0001-plans.
PARAMETERS planstxt TYPE person-plans_txt .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
***********************************************************************
*AT SELECTION-SCREEN OUTPUT.
************************************************************************
AT SELECTION-SCREEN OUTPUT .
  LOOP AT SCREEN.
    IF screen-name = 'ENAME'
    OR screen-name = 'PERSG'
    OR screen-name = 'PERSK'
    OR screen-name = 'KOSTL'
    OR screen-name = 'WERKS'
    OR screen-name = 'ORGEH'
    OR screen-name = 'PLANS'
    OR screen-name = 'ORGEHTXT'
    OR screen-name = 'PLANSTXT'.
      screen-input = '0'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
  LOOP AT SCREEN.
    IF screen-name = 'ORGEHTXT'
    OR screen-name = 'PLANSTXT'.
      screen-output = '1'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
  PERFORM get_pic.
***********************************************************************
*AT SELECTION-SCREEN .
************************************************************************
AT SELECTION-SCREEN .
  ppernr = pernr.
  CALL FUNCTION 'HR_GET_EMPLOYEE_DATA'
    EXPORTING
      person_id             = ppernr
      selection_begin       = sy-datum
      selection_end         = sy-datum
    IMPORTING
      personal_data         = itab_data
    EXCEPTIONS
      person_not_found      = 1
      no_active_integration = 2
      OTHERS                = 3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  ename = itab_data-ename.
  persg = itab_data-persg.
  persk = itab_data-persk.
  orgeh = itab_data-orgeh.
  plans = itab_data-plans.
  kostl = itab_data-kostl.
  werks = itab_data-werks.
  orgehtxt = itab_data-orgeh_txt.
  planstxt = itab_data-plans_txt.
*Function Module To check Existance of Image
  CALL FUNCTION 'HR_IMAGE_EXISTS'
    EXPORTING
      p_pernr        = ppernr
    IMPORTING
      p_connect_info = p_connect_info
    EXCEPTIONS
      OTHERS         = 2.
  p_document_type = p_connect_info-reserve.
*Function Module To Get the URL of Image
  CALL FUNCTION 'SCMS_DOC_URL_READ'
    EXPORTING
      stor_cat    = space
      crep_id     = p_connect_info-archiv_id
      doc_id      = p_connect_info-arc_doc_id
      comp_id     = 'DATA'
      dp_url_only = 'X'
    IMPORTING
      url         = url
    EXCEPTIONS
      OTHERS      = 10.
  IF sy-subrc <> 0.
  ENDIF.
*Method To load Image from URL
  CALL METHOD picture->load_picture_from_url_async
    EXPORTING
      url = url.
  IF sy-subrc NE 0.
  ENDIF.
  IF ppernr NE pernr.
*Function Module To Reset Image
    CALL FUNCTION 'HR_IMAGE_RESET'
      EXPORTING
        handle         = handle
      EXCEPTIONS
        invalid_handle = 1
        OTHERS         = 2.
    IF sy-subrc <> 0.
    ENDIF.
  ENDIF.
*&---------------------------------------------------------------------*
*& Form Get_Pic
*&---------------------------------------------------------------------*
FORM get_pic.
  DATA: repid LIKE sy-repid.

  repid = sy-repid.
  IF picture IS INITIAL.
*Object To Create the Custom Container
    CREATE OBJECT picture
      EXPORTING
        parent = docking_cont.
    CHECK sy-subrc = 0.
*Method To Set Position of Image
    CALL METHOD picture->set_position
      EXPORTING
        height = 47
        left   = 610
        top    = 25
        width  = 70.
*Method To Set Display Mode Fit to Container
    CALL METHOD picture->set_display_mode
      EXPORTING
        display_mode = cl_gui_picture=>display_mode_fit.
  ELSE.
*Function Module To Reset Image
    CALL FUNCTION 'HR_IMAGE_RESET'
      EXPORTING
        handle         = handle
      EXCEPTIONS
        invalid_handle = 1
        OTHERS         = 2.
    IF sy-subrc <> 0.
    ENDIF.
  ENDIF.
ENDFORM. "Get_pic
 

1 Comment

  1. Guest

    hi ,

    The employee Image is not stays in the screen more that 1/2  a second .. any idea why is this ??