메뉴 건너뛰기

SAP 한국 커뮤니티



파일 메일(e-mail) 첨부로 보내기

sapjoy 2014.10.10 10:38 조회 수 : 6662

REPORT  zemail.

DATAc(50).
DATAsent LIKE sonv-flag.
DATAemail_id LIKE sofolenti1-object_id.
DATABEGIN OF email_data.
        INCLUDE STRUCTURE sodocchgi1.
DATAEND OF email_data.
DATABEGIN OF email_send OCCURS 10.
        INCLUDE STRUCTURE somlreci1.
DATAEND OF email_send.
DATABEGIN OF email_text OCCURS 10.
        INCLUDE STRUCTURE solisti1.
DATAEND OF email_text.
DATAftab LIKE solisti1  OCCURS WITH HEADER LINE.
DATA act_filetype LIKE  rlgrap-filetype.
DATA act_filename LIKE  rlgrap-filename.

SELECT-OPTIONS send_to FOR NO INTERVALS LOWER CASE.
SELECTION-SCREEN SKIP.
PARAMETERSsubject(30).
SELECTION-SCREEN SKIP.
PARAMETERSfile LIKE rlgrap-filename DEFAULT 'c:temp'.
SELECTION-SCREEN SKIP.
PARAMETERSl1(84).
PARAMETERSl2(84).
PARAMETERSl3(84).
PARAMETERSl4(84).
PARAMETERSl5(84).
PARAMETERSl6(84).
PARAMETERSl7(84).
PARAMETERSl8(84).
PARAMETERSl9(84).

INITIALIZATION.
  send_to-low '@.'.
  APPEND send_to.

START-OF-SELECTION.
  PERFORM upload.
  PERFORM send.

END-OF-SELECTION.

*---------------------------------------------------------------------*
*       FORM SEND                                                     *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM send.
  email_text-line l1.
  APPEND email_text.
  email_text-line l2.
  APPEND email_text.
  email_text-line l3.
  APPEND email_text.
  email_text-line l4.
  APPEND email_text.
  email_text-line l5.
  APPEND email_text.
  email_text-line l6.
  APPEND email_text.
  email_text-line l7.
  APPEND email_text.
  email_text-line l8.
  APPEND email_text.
  email_text-line l9.
  APPEND email_text.

  email_data-obj_name 'MESSAGE'.
  email_data-obj_descr subject.
  email_data-obj_langu 'E'.
  email_data-sensitivty 'P'.
  email_data-obj_prio '1'.
  email_data-no_change 'X'.
  email_data-priority '1'.

  LOOP AT send_to.
    email_send-receiver send_to-low.
    email_send-rec_type 'U'.
    email_send-com_type 'INT'.
    email_send-express 'X'.
    APPEND email_send.
  ENDLOOP.

  WRITE:'End of program'.

*****************************************************

  DATA lines TYPE i,
         f_lines TYPE i.
  DATA e_packing_tab LIKE sopcklsti1 OCCURS WITH HEADER LINE.

*
  DESCRIBE TABLE email_text LINES lines.
  e_packing_tab-transf_bin space.
  e_packing_tab-head_start 1.
  e_packing_tab-head_num   0.
  e_packing_tab-body_start 1.
  e_packing_tab-body_num   lines.
  e_packing_tab-doc_type   'RAW'.
  APPEND e_packing_tab.

  DESCRIBE TABLE ftab LINES f_lines.
  DATA doc_size TYPE i.
  doc_size f_lines * 255.

  DATAobjhead LIKE solisti1 OCCURS WITH HEADER LINE.
  objhead act_filenameAPPEND objhead.


  DATAdoc_type(3).
  SPLIT act_filename AT '.' INTO act_filename doc_type.

  e_packing_tab-transf_bin 'X'.
  e_packing_tab-head_start 1.
  e_packing_tab-head_num   1.
  e_packing_tab-body_start 1.
  e_packing_tab-body_num   f_lines.
  e_packing_tab-doc_type   doc_type.
  e_packing_tab-obj_name   'obj name'.
  e_packing_tab-obj_descr  'obj desc'.
  e_packing_tab-doc_size   doc_size.
  APPEND e_packing_tab.





  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data                    email_data
      put_in_outbox                    'X'
      commit_work 'X'
    IMPORTING
      sent_to_all                      sent
      new_object_id                    email_id
    TABLES
      packing_list                     e_packing_tab
      object_header                    objhead
      contents_bin                     ftab
      contents_txt                     email_text
*     CONTENTS_HEX                     =
*     OBJECT_PARA                      =
*     OBJECT_PARB                      =
      receivers                        email_send
    EXCEPTIONS
      too_many_receivers               1
      document_not_sent                2
      document_type_not_exist          3
      operation_no_authorization       4
      parameter_error                  5
      x_error                          6
      enqueue_error                    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.



  WRITE:/ email_id.
  WRITE:/ sent.
  WRITE:/ sy-subrc.

ENDFORM.                    " SEND
*---------------------------------------------------------------------*
*       FORM UPLOAD                                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM upload.

  CALL FUNCTION 'UPLOAD'
    EXPORTING
*     CODEPAGE                      = ' '
      filename                      file
      filetype                      'BIN'
*     ITEM                          = ' '
*     FILEMASK_MASK                 = ' '
*     FILEMASK_TEXT                 = ' '
*     FILETYPE_NO_CHANGE            = ' '
*     FILEMASK_ALL                  = ' '
*     FILETYPE_NO_SHOW              = ' '
*     LINE_EXIT                     = ' '
*     USER_FORM                     = ' '
*     USER_PROG                     = ' '
*     SILENT                        = 'S'
    IMPORTING
*     FILESIZE                      =
*     CANCEL                        =
      act_filename                  act_filename
      act_filetype                  act_filetype
    TABLES
      data_tab                      ftab
*   EXCEPTIONS
*     CONVERSION_ERROR              = 1
*     INVALID_TABLE_WIDTH           = 2
*     INVALID_TYPE                  = 3
*     NO_BATCH                      = 4
*     UNKNOWN_ERROR                 = 5
*     GUI_REFUSE_FILETRANSFER       = 6
*     OTHERS                        = 7
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  DATATYPE i,
        j TYPE i.
  STRLENact_filename ).
  DO TIMES.
    j sy-index 1.
    IF act_filename+j(1''.
      j j + 1.
      act_filename act_filename+j.
      EXIT.
    ENDIF.
  ENDDO.
  WRITE:/ act_filename,
          act_filetype.

ENDFORM.                    " UPLOAD
번호 제목 글쓴이 날짜 조회 수
107 KR_POSTCODE : 한국주소입력 Version 2.0 대략나 2021.03.31 221
106 HTTP 통신하는 로직 [3] 대략나 2016.12.20 4134
105 XML 을 아밥 스트럭쳐 또는 인터널테이블로 변경시키는 로직 [1] 대략나 2016.12.20 3258
104 ALV EDIT 샘플 프로그램 sapjoy 2015.06.26 8969
» 파일 메일(e-mail) 첨부로 보내기 [2] sapjoy 2014.10.10 6662
102 데이터 이메일(e-mail) xls 파일로 보내기 [2] sapjoy 2014.10.10 6366
101 Tree ALV 샘플 [5] 양키(이경환) 2014.02.05 9746
100 Split 의 사용 [1] 양키(이경환) 2014.02.05 8227
99 소수점 뒷자리 0 제거 로직 file 양키(이경환) 2014.01.19 8789
98 10이하의 홀수 마방진 은미짱 2013.10.18 6661
97 [Module pool] Container에 webpage 넣기. [2] 냥냥 2013.03.19 11052
96 COMAPY CODE에 할당된 Fiscal variant에 대한 calendar date 변환 paran 2013.02.28 10336
95 멀 어떻게 해야 하는건질 몰라 질문 드립니다 [5] 쏠라맨 2012.10.12 11479
94 nugg 프로그램을 sap 에 생성하기.. [3] file MadMax 2012.10.11 10601
93 인터널 테이블을 사용한 구구단 출력 두가지 입니다 - WRITE, ALV 이용 [1] kofnhuge 2012.10.10 13512
92 Search For Program/Function/Table Desc&Name [8] file 초짜 2011.09.30 9750
91 스크린에서 버튼을 tree 처럼 만들기. [32] file Jenny 2011.08.11 17434
90 통화단위, krw, usd 일반 필드에 변환시 로직(소수점, 자리수) [4] sapjoy 2011.07.19 15381
89 Dynamic Select 소스 [5] 떡밥 2011.06.03 17544
88 [onepaper] 참고자료 Archiving 세팅에 필요한 파일소스입니다. [7] file 원니컴 2011.03.22 13713