SAP 发送带附件邮件示例

公西飞鸾
2023-12-01

示例代码:

  • 代码
    DATA: GV_FILE TYPE CHAR50.    "Like SO_OBJ_DES
    
    PARAMETERS : P_FILE TYPE CHAR100 OBLIGATORY.
    
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      PERFORM FRM_GET_FIELDNAME.
    
    START-OF-SELECTION.
      PERFORM FRM_SEND_MAIL.
    
    
    FORM FRM_GET_FIELDNAME .
    
      DATA: LV_RC TYPE I.
      DATA: LT_FILE_TABLE TYPE FILETABLE.
    
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
        EXPORTING
          WINDOW_TITLE = '打开文件'
        CHANGING
          FILE_TABLE   = LT_FILE_TABLE
          RC           = LV_RC.
    
      IF SY-SUBRC = 0.
        READ TABLE LT_FILE_TABLE INTO DATA(WA_FILE_TABLE) INDEX 1.
        P_FILE = WA_FILE_TABLE-FILENAME.
      ENDIF.
    
      CALL FUNCTION 'STPU1_EXTRACT_FILENAME'
        EXPORTING
          FILE_AND_PATH = P_FILE
        IMPORTING
          FILE          = GV_FILE
    *     PATHNAME      =
        .
    
    ENDFORM.
    
    FORM FRM_SEND_MAIL .
    
    *File Object Definition
      
 类似资料: