DATA : OUTPUT_OPTIONS TYPE SSFCOMPOP,
CONTROL_PARAMETERS TYPE SSFCTRLOP.
CLEAR: CONTROL_PARAMETERS, OUTPUT_OPTIONS, TSP03.
CONTROL_PARAMETERS-NO_DIALOG = 'X'.
" "otf 전환***
CONTROL_PARAMETERS-GETOTF = 'X'.
CONTROL_PARAMETERS-LANGU = SY-LANGU.
CONTROL_PARAMETERS-DEVICE = 'PRINTER'.
OUTPUT_OPTIONS-TDSENDDATE = SY-DATLO.
OUTPUT_OPTIONS-TDSENDTIME = SY-TIMLO.
OUTPUT_OPTIONS-TDDEST = 'LP01'.
OUTPUT_OPTIONS-TDNEWID = 'X'.
CALL FUNCTION P_FUNC_MOD_NAME
EXPORTING
CONTROL_PARAMETERS = CONTROL_PARAMETERS
OUTPUT_OPTIONS = OUTPUT_OPTIONS
G_ITAB02_T = G_ITAB02_T
IMPORTING
JOB_OUTPUT_INFO = G_JOB_OUTPUT_INFO
JOB_OUTPUT_OPTIONS = G_JOB_OUTPUT_OPTIONS
TABLES
G_ITAB03_T = G_ITAB03_T
G_ITAB08_T = G_ITAB08_T
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
LEAVE PROGRAM.
ENDIF.
*&
DATA : OTF_TAB TYPE TSFOTF.
OTF_TAB[] = G_JOB_OUTPUT_INFO-OTFDATA[].
*&
DATA: GS_HEAD LIKE SODOCCHGI1,
GT_OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,
GT_OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
GT_OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
GT_OBJCON LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
GT_RECEIVER LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
GV_LINES LIKE SY-TABIX,
GV_DOC_SIZE LIKE SY-TABIX.
*&
DATA: LT_PDF TYPE STANDARD TABLE OF TLINE WITH HEADER LINE,
L_SIZE TYPE I,
L_REG_VALUE(128) TYPE C.
data: L_FILE TYPE XSTRING.
*& OTF 파일을 PDF 파일로 CONVERT.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
TABLES
OTF = P_OTF[]
LINES = LT_PDF
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
DATA: I TYPE I,N TYPE I.
DATA: L_TXT(1000).
* Convert pdf(134) to binary(255) file.
LOOP AT LT_PDF.
L_TXT+I = LT_PDF.
ADD 134 TO I.
IF I >= 255.
GT_OBJBIN = L_TXT.
APPEND GT_OBJBIN.
SUBTRACT 255 FROM I.
L_TXT = L_TXT+255.
ENDIF.
ENDLOOP.
IF I <> 0.
GT_OBJBIN = L_TXT.
APPEND GT_OBJBIN.
ENDIF.
*& 메일 수신자 관련
GT_RECEIVER-RECEIVER = 'mychoi@lgcns.com'.
"수신메일주소
GT_RECEIVER-REC_TYPE = 'U'.
GT_RECEIVER-EXPRESS = 'X'.
APPEND GT_RECEIVER. CLEAR GT_RECEIVER.
*& 메일 내용
GT_OBJCON-LINE = 'Smartforms Mail 확인바랍니다.'.
APPEND GT_OBJCON. CLEAR GT_OBJCON.
*&
GT_OBJCON-LINE = '감사합니다'.
APPEND GT_OBJCON. CLEAR GT_OBJCON.
*&
*& 메일 내용 관련된 사항을 PACKING_LIST에 APPEND
DESCRIBE TABLE GT_OBJCON LINES GV_LINES.
*& 메일 HEADER
GS_HEAD-OBJ_NAME = 'MESSAGE'.
GS_HEAD-OBJ_DESCR = '>>SMART PDF MAIL 확인바랍니다.'. "메일 제목
GS_HEAD-OBJ_LANGU = 'E'.
GS_HEAD-SENSITIVTY = 'O'. "'O' : Standard 'P': Confidential
GS_HEAD-OBJ_PRIO = '1'.
GS_HEAD-NO_CHANGE = 'X'.
GS_HEAD-PRIORITY = '1'.
* gs_head-doc_size = gv_lines * 255.
GT_OBJPACK-HEAD_START = 1.
GT_OBJPACK-HEAD_NUM = 0.
GT_OBJPACK-BODY_START = 1.
GT_OBJPACK-BODY_NUM = GV_LINES.
GT_OBJPACK-DOC_TYPE = 'RAW'.
APPEND GT_OBJPACK. CLEAR GT_OBJPACK.
*& 메일 첨부파일에 관련된 사항을 PACKING LIST에 저장
DESCRIBE TABLE GT_OBJBIN LINES GV_LINES.
GT_OBJPACK-TRANSF_BIN = 'X'.
GT_OBJPACK-HEAD_START = 1.
GT_OBJPACK-HEAD_NUM = 1.
GT_OBJPACK-BODY_START = 1.
GT_OBJPACK-BODY_NUM = GV_LINES.
GT_OBJPACK-DOC_TYPE = 'PDF'.
* GT_OBJPACK-FILE_EXT = 'PDF'.
GT_OBJPACK-OBJ_NAME = 'Attachment'.
GT_OBJPACK-OBJ_DESCR = 'ATT_SMART'.
READ TABLE GT_OBJBIN INDEX GV_LINES.
GV_DOC_SIZE = GV_LINES * 255.
* GV_DOC_SIZE = ( GV_LINES - 1 ) * 255 + STRLEN( GT_OBJBIN ).
GT_OBJPACK-DOC_SIZE = GV_DOC_SIZE.
APPEND GT_OBJPACK. CLEAR GT_OBJPACK.
*& 메일을 전송하는 Function.....
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = GS_HEAD "메일TITLE
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = GT_OBJPACK
CONTENTS_BIN = GT_OBJBIN "첨부파일
CONTENTS_TXT = GT_OBJCON "메일내용
RECEIVERS = GT_RECEIVER "수신정보
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.
ELSE.
MESSAGE S002 WITH '메일이 전송 되었습니다.'.
ENDIF.
CONTROL_PARAMETERS TYPE SSFCTRLOP.
CLEAR: CONTROL_PARAMETERS, OUTPUT_OPTIONS, TSP03.
CONTROL_PARAMETERS-NO_DIALOG = 'X'.
" "otf 전환***
CONTROL_PARAMETERS-GETOTF = 'X'.
CONTROL_PARAMETERS-LANGU = SY-LANGU.
CONTROL_PARAMETERS-DEVICE = 'PRINTER'.
OUTPUT_OPTIONS-TDSENDDATE = SY-DATLO.
OUTPUT_OPTIONS-TDSENDTIME = SY-TIMLO.
OUTPUT_OPTIONS-TDDEST = 'LP01'.
OUTPUT_OPTIONS-TDNEWID = 'X'.
CALL FUNCTION P_FUNC_MOD_NAME
EXPORTING
CONTROL_PARAMETERS = CONTROL_PARAMETERS
OUTPUT_OPTIONS = OUTPUT_OPTIONS
G_ITAB02_T = G_ITAB02_T
IMPORTING
JOB_OUTPUT_INFO = G_JOB_OUTPUT_INFO
JOB_OUTPUT_OPTIONS = G_JOB_OUTPUT_OPTIONS
TABLES
G_ITAB03_T = G_ITAB03_T
G_ITAB08_T = G_ITAB08_T
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
LEAVE PROGRAM.
ENDIF.
*&
DATA : OTF_TAB TYPE TSFOTF.
OTF_TAB[] = G_JOB_OUTPUT_INFO-OTFDATA[].
*&
DATA: GS_HEAD LIKE SODOCCHGI1,
GT_OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,
GT_OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
GT_OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
GT_OBJCON LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
GT_RECEIVER LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
GV_LINES LIKE SY-TABIX,
GV_DOC_SIZE LIKE SY-TABIX.
*&
DATA: LT_PDF TYPE STANDARD TABLE OF TLINE WITH HEADER LINE,
L_SIZE TYPE I,
L_REG_VALUE(128) TYPE C.
data: L_FILE TYPE XSTRING.
*& OTF 파일을 PDF 파일로 CONVERT.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
TABLES
OTF = P_OTF[]
LINES = LT_PDF
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
DATA: I TYPE I,N TYPE I.
DATA: L_TXT(1000).
* Convert pdf(134) to binary(255) file.
LOOP AT LT_PDF.
L_TXT+I = LT_PDF.
ADD 134 TO I.
IF I >= 255.
GT_OBJBIN = L_TXT.
APPEND GT_OBJBIN.
SUBTRACT 255 FROM I.
L_TXT = L_TXT+255.
ENDIF.
ENDLOOP.
IF I <> 0.
GT_OBJBIN = L_TXT.
APPEND GT_OBJBIN.
ENDIF.
*& 메일 수신자 관련
GT_RECEIVER-RECEIVER = 'mychoi@lgcns.com'.
"수신메일주소
GT_RECEIVER-REC_TYPE = 'U'.
GT_RECEIVER-EXPRESS = 'X'.
APPEND GT_RECEIVER. CLEAR GT_RECEIVER.
*& 메일 내용
GT_OBJCON-LINE = 'Smartforms Mail 확인바랍니다.'.
APPEND GT_OBJCON. CLEAR GT_OBJCON.
*&
GT_OBJCON-LINE = '감사합니다'.
APPEND GT_OBJCON. CLEAR GT_OBJCON.
*&
*& 메일 내용 관련된 사항을 PACKING_LIST에 APPEND
DESCRIBE TABLE GT_OBJCON LINES GV_LINES.
*& 메일 HEADER
GS_HEAD-OBJ_NAME = 'MESSAGE'.
GS_HEAD-OBJ_DESCR = '>>SMART PDF MAIL 확인바랍니다.'. "메일 제목
GS_HEAD-OBJ_LANGU = 'E'.
GS_HEAD-SENSITIVTY = 'O'. "'O' : Standard 'P': Confidential
GS_HEAD-OBJ_PRIO = '1'.
GS_HEAD-NO_CHANGE = 'X'.
GS_HEAD-PRIORITY = '1'.
* gs_head-doc_size = gv_lines * 255.
GT_OBJPACK-HEAD_START = 1.
GT_OBJPACK-HEAD_NUM = 0.
GT_OBJPACK-BODY_START = 1.
GT_OBJPACK-BODY_NUM = GV_LINES.
GT_OBJPACK-DOC_TYPE = 'RAW'.
APPEND GT_OBJPACK. CLEAR GT_OBJPACK.
*& 메일 첨부파일에 관련된 사항을 PACKING LIST에 저장
DESCRIBE TABLE GT_OBJBIN LINES GV_LINES.
GT_OBJPACK-TRANSF_BIN = 'X'.
GT_OBJPACK-HEAD_START = 1.
GT_OBJPACK-HEAD_NUM = 1.
GT_OBJPACK-BODY_START = 1.
GT_OBJPACK-BODY_NUM = GV_LINES.
GT_OBJPACK-DOC_TYPE = 'PDF'.
* GT_OBJPACK-FILE_EXT = 'PDF'.
GT_OBJPACK-OBJ_NAME = 'Attachment'.
GT_OBJPACK-OBJ_DESCR = 'ATT_SMART'.
READ TABLE GT_OBJBIN INDEX GV_LINES.
GV_DOC_SIZE = GV_LINES * 255.
* GV_DOC_SIZE = ( GV_LINES - 1 ) * 255 + STRLEN( GT_OBJBIN ).
GT_OBJPACK-DOC_SIZE = GV_DOC_SIZE.
APPEND GT_OBJPACK. CLEAR GT_OBJPACK.
*& 메일을 전송하는 Function.....
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = GS_HEAD "메일TITLE
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = GT_OBJPACK
CONTENTS_BIN = GT_OBJBIN "첨부파일
CONTENTS_TXT = GT_OBJCON "메일내용
RECEIVERS = GT_RECEIVER "수신정보
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.
ELSE.
MESSAGE S002 WITH '메일이 전송 되었습니다.'.
ENDIF.
댓글 6
-
mudfish
2007.05.24 08:36
-
skna
2007.07.11 23:14
안녕하세요?
위의 인터넷 메일을 사용하기 위해서 BC단에서
어떤 사항들을 셋팅해야 하는 궁금합니다. 고수님들의 고견 부탁드립니다.
-
드라곤
2008.12.02 19:06
감사합니다.
-
GKS518
2011.08.19 02:50
감사합니다.~ 좋은 자료네요!
-
lullu20
2012.07.13 01:09
감사합니다.
-
지구별원숭이
2012.09.17 20:17
좋은 자료에 대해 진심으로 감사드립니다^^
정말 좋은 자료입니다
감사합니다 *^^*