Below is ABAP upload and download HR photo program.(via web)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
REPORT  z_barry_hr_photo_upload.
 
DATA: sapobjid LIKE sapb-sapobjid,
      sappfad LIKE sapb-sappfad.
DATA: gd_path TYPE string ,
      filetab TYPE TABLE OF file_info WITH HEADER LINE,
      count TYPE i.
DATA: filename(40) TYPE c ,
      fileext(10) TYPE c ,
      len TYPE i .
 
PARAMETERS: filepath LIKE rlgrap-filename.
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filepath.
  CALL METHOD cl_gui_frontend_services=>directory_browse
    EXPORTING
      window_title    = 'File Directory'
      initial_folder  = 'C:\'
    CHANGING
      selected_folder = gd_path.
  CALL METHOD cl_gui_cfw=>flush.
  CONCATENATE gd_path '' INTO filepath.
 
START-OF-SELECTION.
  gd_path = filepath .
  CALL METHOD cl_gui_frontend_services=>directory_list_files
    EXPORTING
      directory                   = gd_path
      filter                      = '*.jpg'
    CHANGING
      file_table                  = filetab[]
      count                       = count
    EXCEPTIONS
      cntl_error                  = 1
      directory_list_files_failed = 2
      wrong_parameter             = 3
      error_no_gui                = 4
      not_supported_by_gui        = 5
      OTHERS                      = 6.
 
  LOOP AT filetab.
    SPLIT filetab-filename AT '.' INTO filename fileext.
    len = STRLEN( filename ) .
    IF len <> 8 .
      MESSAGE e000(oo) WITH '文件名长度必须等于8位'.
    ENDIF.
  ENDLOOP.
 
  LOOP AT filetab.
    CONCATENATE gd_path '\' filetab-filename INTO sappfad.
    CONCATENATE filetab-filename+0(8) '0002' INTO sapobjid.
    CALL FUNCTION 'ARCHIV_CREATE_FILE'
      EXPORTING
        ar_object               = 'HRICOLFOTO'
        object_id               = sapobjid
        sap_object              = 'PREL'
        doc_type                = 'JPG'
        path                    = sappfad
      EXCEPTIONS
        error_conectiontable    = 1
        error_parameter         = 2
        error_archiv            = 3
        error_upload            = 4
        error_kernel            = 5
        no_entry_possible       = 6
        error_comunicationtable = 7
        OTHERS                  = 8.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
      WRITE : / 'Upload ',sappfad,'To pernr ',filetab-filename+0(8),'Sccuess!'.
    ENDIF.
  ENDLOOP.
 
 
 
REPORT  z_barry_hr_photo_down.
 
DATA: comps2 TYPE STANDARD TABLE OF scms_doinf WITH HEADER LINE,
      comp_names TYPE STANDARD TABLE OF scms_donam WITH HEADER LINE.
 
PARAMETERS p_pernr LIKE pa0001-pernr.
 
PERFORM photo_down USING p_pernr 'A' '18000101' '99991231' 'D:\abc.jpg'  .
 
*&---------------------------------------------------------------------*
*&      Form  URL_GET
*&---------------------------------------------------------------------*
FORM photo_down USING p_pernr LIKE pernr-pernr
                      p_tclas LIKE pspar-tclas
                      p_begda LIKE prelp-begda
                      p_endda LIKE prelp-endda
                      path TYPE c .
  DATA: l_connect_info LIKE toav0,
        l_exists(1) TYPE c .
  CALL FUNCTION 'HR_IMAGE_EXISTS'
    EXPORTING
      p_pernr        = p_pernr
      p_tclas        = p_tclas
      p_begda        = p_begda
      p_endda        = p_endda
    IMPORTING
      p_exists       = l_exists
      p_connect_info = l_connect_info
    EXCEPTIONS
      OTHERS         = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
    EXIT.
  ENDIF.
  CALL FUNCTION 'SCMS_DOC_READ_FILES'
    EXPORTING
      stor_cat              = space
      crep_id               = l_connect_info-archiv_id
      doc_id                = l_connect_info-arc_doc_id
      path                  = path
      frontend              = 'X'
    TABLES
      comps                 = comps2
      comp_names            = comp_names
    EXCEPTIONS
      bad_storage_type      = 1
      bad_request           = 2
      unauthorized          = 3
      not_found             = 4
      conflict              = 5
      internal_server_error = 6
      error_http            = 7
      error_signature       = 8
      error_config          = 9
      error_hierarchy       = 10
      error_download        = 11
      error_open            = 12
      error_parameter       = 13
      error                 = 14
      OTHERS                = 15.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
  ENDIF.
ENDFORM.                    "photo_down