ABAP--通过'ARCHIV_CREATE_FILE'上传员工照片(代码摘抄OAOH)

1) Store the Photograph of the Employee as the PERNR.JPG (PERNR = EMPLPYEES PERSONNEL NUMBER) at a predifined location.

2) Have a text file with all the pernr for whom you want to upload the photo and the JPGs you have in the folder.

3) Use this Function module with the loop for all the PERNR

* Function module to update Tran OAAD

* Create file path (Directory)-(Employee No.).JPG

CONCATENATE 'dir where the file is stored' wa_pernr-pernr '.' 'jpg' INTO lw_path.
************************************************************************
* Copyright 2004 C-Bons Wuhan *
* All Rights Reserved *
*----------------------------------------------------------------------*
* Program Name : ZHRIPHOTO *
* Project : SAP Implementation Project *
* Program Title: 照片导入 *
* Created by : DEV01 *
* Created on : 2007/09/15 *
* Version : 1.0 *
*----------------------------------------------------------------------*
* Function Description: *
* 照片导入 *
*----------------------------------------------------------------------*
* Data Table List: *
* *
*----------------------------------------------------------------------*
* Refrence Table List: *
* *
*----------------------------------------------------------------------*
* Modification Log: *
* Date Programmer Correction Number *
************************************************************************
REPORT zhriphoto NO STANDARD PAGE HEADING LINE-SIZE 255
MESSAGE-ID zdev .
*I N T E R N A L T A B L E S
DATA : BEGIN OF gt_photo OCCURS 0,
pernr(8),
END OF gt_photo.
DATA: g_path LIKE draw-filep,
g_sapobjid LIKE sapb-sapobjid,
g_filename TYPE string,
g_sappfad LIKE sapb-sappfad.

PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY. " 文件路径

************************************************************************
*& Initialization
************************************************************************
INITIALIZATION.
* CONCATENATE sy-uname sy-datum+4(4) INTO group.
************************************************************************
* START-OF-SELECTION
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING " DEF_FILENAME = ' '
def_path = 'C:/'
mask = ',Text Files,*.txt;*.prn,All Files,*.*.'
mode = 'O'
title = '选取导入文件'(100)
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0 AND sy-subrc <> 3.
MESSAGE e102(zdev) WITH 'Error Selecting File'(007).
ENDIF.

************************************************************************
* START-OF-SELECTION
************************************************************************
START-OF-SELECTION.
g_path = p_file.
CALL FUNCTION 'CV120_SPLIT_PATH'
EXPORTING
pf_path = g_path
IMPORTING
pfx_path = g_path.
g_filename = p_file.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = g_filename
* FILETYPE = 'ASC'
* has_field_separator = 'X'
* dat_mode = 'X'
TABLES
data_tab = gt_photo
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.

IF sy-subrc <> 0.
MESSAGE s306 .
ENDIF.

LOOP AT gt_photo.
CONCATENATE g_path gt_photo-pernr '.JPG' INTO g_sappfad.
CONCATENATE gt_photo-pernr '0002' INTO g_sapobjid.
CALL FUNCTION 'ARCHIV_CREATE_FILE'
EXPORTING
ar_object = 'HRICOLFOTO'
object_id = g_sapobjid
sap_object = 'PREL'
doc_type = 'JPG'
path = g_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.
ENDIF.
CLEAR g_filename.
ENDLOOP.

************************************************************************
* END-OF-SELECTION
************************************************************************
END-OF-SELECTION.
WRITE / '执行完毕!'.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值