Skip to Content



Dear All,


I got stuck as i need to download the photos from sap which uploaded earlier and are stored in archive link or content server.

The employee photo are visible in pa20 and can be saved from extras > facimiles .


But there is no dirct program available to download the image files in SAP.


Also i have searched earlier in SAP and found some links but not useful.


I have developed the following program and will help you download the image files as per your file name (employee number) and folder in local PC.



Thanks —


Syed Sameer.


Rewards Points if find useful.



>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


REPORT ZTESTPHOTODOWNLOAD  MESSAGE-ID ZDEV.

TABLES : PA0001.

TYPES : BEGIN OF TY_PA0001,

           PERNR TYPE PA0001PERNR,

           ENDDA TYPE PA0001ENDDA,

         END OF TY_PA0001.

DATA : IT_PA0001 TYPE TABLE OF TY_PA0001,

        WA_PA0001 TYPE TY_PA0001.

DATA: URL(255)       TYPE C,

       P_CONNECT_INFO LIKE TABLE OF TOAV0 WITH HEADER LINE,

       HANDLE         TYPE I,

       V_PERNR        TYPE PA0001PERNR.

DATA L_CURRENT TYPE XSTRING.

DATA : EX_DOCUMENT TYPE TABLE OF  TBL1024,

        EX_LENGTH   TYPE INT4.

DATA : BINARY_TAB TYPE TABLE OF TBL1024,

        BUFFER     TYPE XSTRING.

DATA : V_FILENAME TYPE STRING.

TYPES : BEGIN OF TY_BINARY,

           BINARY_FIELD(1000) TYPE C,

         END OF TY_BINARY.

DATA : LI_DATA TYPE TABLE OF TY_BINARY WITH HEADER LINE.

***selection screen ***

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT001.

SELECT-OPTIONS : S_PERNR FOR PA0001PERNR  MATCHCODE OBJECT PREM.

PARAMETERS: P_PATH  TYPE STRING OBLIGATORY.

SELECTION-SCREEN END OF BLOCK B1.

INITIALIZATION.

   REFRESH : LI_DATA , EX_DOCUMENT , BINARY_TAB.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PATH.

   CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE

     EXPORTING

       WINDOW_TITLE    = ‘Select Directory’

     CHANGING

       SELECTED_FOLDER = P_PATH

     EXCEPTIONS

       CNTL_ERROR      = 1.

   CALL METHOD CL_GUI_CFW=>FLUSH

     EXCEPTIONS

       CNTL_SYSTEM_ERROR = 1

       CNTL_ERROR        = 2.

START-OF-SELECTION.

   SELECT PERNR ENDDA

     FROM PA0001

     INTO TABLE IT_PA0001

     WHERE PERNR IN S_PERNR

     AND   ENDDA EQ ‘99991231’ .

   IF SYSUBRC EQ 0.

     SORT IT_PA0001 BY PERNR.

     DELETE ADJACENT DUPLICATES FROM IT_PA0001 COMPARING PERNR.

   ENDIF.

   IF IT_PA0001 IS INITIAL.

     MESSAGE S001 WITH ‘No Data exist’.

   ELSE.

     LOOP AT IT_PA0001 INTO WA_PA0001.

       REFRESH : LI_DATA , EX_DOCUMENT , BINARY_TAB.

       CLEAR   : P_CONNECT_INFO, BUFFER , V_FILENAME.

       CALL FUNCTION ‘HR_IMAGE_EXISTS’

         EXPORTING

           P_PERNR        = WA_PA0001PERNR

         IMPORTING

           P_CONNECT_INFO = P_CONNECT_INFO

         EXCEPTIONS

           OTHERS         = 2.

       IF SYSUBRC EQ 0.

         CALL FUNCTION ‘ALINK_RFC_TABLE_GET’

           EXPORTING

             IM_DOCID    = P_CONNECT_INFOARC_DOC_ID

             IM_CREPID   = P_CONNECT_INFOARCHIV_ID

*           IM_COMPID   =

           IMPORTING

             EX_LENGTH   = EX_LENGTH

*           EX_MESSAGE  =

           TABLES

             EX_DOCUMENT = EX_DOCUMENT.

         BINARY_TAB[] = EX_DOCUMENT[].

         IF EX_LENGTH IS INITIAL.

           CONTINUE.

         ENDIF.

         CALL FUNCTION ‘SCMS_BINARY_TO_XSTRING’

           EXPORTING

             INPUT_LENGTH = EX_LENGTH

*           FIRST_LINE   = 0

*           LAST_LINE    = 0

           IMPORTING

             BUFFER       = BUFFER

           TABLES

             BINARY_TAB   = BINARY_TAB

           EXCEPTIONS

             FAILED       = 1

             OTHERS       = 2.

         IF SYSUBRC <> 0.

* Implement suitable error handling here

         ENDIF.

         CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’

           EXPORTING

             BUFFER     = BUFFER

*           APPEND_TO_TABLE       = ‘ ‘

* IMPORTING

*           OUTPUT_LENGTH         =

           TABLES

             BINARY_TAB = LI_DATA.

         CONCATENATE P_PATH ‘\’ ’90’ WA_PA0001PERNR ‘.jpg’ INTO V_FILENAME.

         CONDENSE V_FILENAME.

         CALL FUNCTION ‘GUI_DOWNLOAD’

           EXPORTING

*           BIN_FILESIZE                    =

             FILENAME = V_FILENAME

             FILETYPE = ‘BIN’

* IMPORTING

*           FILELENGTH                      =

           TABLES

             DATA_TAB = LI_DATA.

       ENDIF.

       CLEAR WA_PA0001.

     ENDLOOP.

   ENDIF.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply