Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Hello, attached an example to see the photo of employee by number of personnel in a DYNPRO.Variable "PERNR" is the number of personnel.

You have to create a container in the DYNPRO with the name of "PHOTO" and call the form.


CODE:

DATA: PERNR TYPE PERNR_D.

DATA: URI LIKE  TOAURI-URI.

DATA: G_RESULT TYPE I.

DATA: H_PICTURE       TYPE REF TO CL_GUI_PICTURE.
DATA: H_PIC_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

FORM PHOTO.

CLEAR URI.

CALL FUNCTION 'HRWPC_RFC_EP_READ_PHOTO_URI'
EXPORTING
PERNR =   PERNR
IMPORTING
   URI = URI
EXCEPTIONS
  NOTHING_FOUND = 1
  NO_AUTHORIZATION = 2
  INTERNAL_ERROR = 3.

IF SY-SUBRC = 0.
      IF H_PIC_CONTAINER IS INITIAL.
       CREATE OBJECT H_PIC_CONTAINER
           EXPORTING CONTAINER_NAME 'PHOTO'.
       CREATE OBJECT H_PICTURE EXPORTING PARENT = H_PIC_CONTAINER.
    ENDIF.

    CALL METHOD H_PICTURE->LOAD_PICTURE_FROM_URL
         EXPORTING URL    = URI
         IMPORTING RESULT = G_RESULT.

    CALL METHOD H_PICTURE->SET_DISPLAY_MODE
       EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
       CALL METHOD H_PICTURE->SET_DISPLAY_MODE
       EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
      CALL METHOD CL_GUI_CFW=>FLUSH.

ELSEIF H_PICTURE IS NOT INITIAL.
        CALL METHOD H_PICTURE->CLEAR_PICTURE.
ENDIF.

ENDFORM.

Regards.