zoukankan      html  css  js  c++  java
  • 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 / '执行完毕!'.

  • 相关阅读:
    UART协议
    芯片时钟体系(take example as s3c2440)
    PCIe协议
    I2C协议
    SPI协议
    嵌入式相关术语列表
    TreeView控件数据绑定之:数据库数据递归绑定
    连接SQL Server 数据库的三种方式
    JS小功能之:五角星评论
    MVC学习之开发技巧总结(1)
  • 原文地址:https://www.cnblogs.com/xiaomaohai/p/6157218.html
Copyright © 2011-2022 走看看