스마트폼을 pdf 처리해서 메일링 해주는 프로그램을 짜는 중입니다.
현재 470에서는 성공했습니다.
그 소스를 그대로 ecc6.0에서 실행했을 때 이상하게 변환이 돼서 pdf 파일로 인식을 하지 못합니다.
정확한 에러를 떨어뜨리면 변환된 pdf 파일을 열면 '파일이 %PDF-'로 시작하지 않습니다.'라고 나옵니다.
디버깅 쫒아가봤을 때는 ecc6.0과 470 사이의 차이점을 들자면 ecc6.0이 시스템 코드 페이지를 unicode로 설치했다는 점입니다.
pdf 파일의 변환 형식을 보면
470 : %P |DF-1.3##%栒鞠##2 0 obj##<<##/Type /FontDescriptor##/Ascent 752##
6.0 : 倥䙄 |ㄭ㌮쿣ී㈊〠漠橢㰼启灹䘯湯䑴獥牣灩潴൲⼊獁散瑮㜠㈵䌯灡效杩瑨㜠㜳䐯獥散瑮ⴠ㜲റ⼊汆条ശ⼊潆瑮䉂硯嬠㘭ⴠ㐱‵〱㌰㠠〸<
모 이런식입니다.
같은 경험을 해보고 솔루션이 있는 분들 부탁드립니다 ^^
소스는 아래와 같습니다.
===============================================================================================================
CONTROL_PARAMETERS-NO_DIALOG = 'X'.
CONTROL_PARAMETERS-GETOTF = 'X'.
OUTPUT_OPTIONS-TDNOPREV = 'X'.
CONTROL_PARAMETERS-NO_OPEN = 'X'.
* control_parameters-no_close = 'X'.
CLEAR JOB_OUTPUT_INFO.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
CONTROL_PARAMETERS = CONTROL_PARAMETERS
OUTPUT_OPTIONS = OUTPUT_OPTIONS
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
*============================================
*스마트폼이름에 대한 펑션이름을 가져오는 함수
*============================================
DATA: FM_NAME TYPE RS38L_FNAM.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'Z_HR_HC_PAY'
IMPORTING
FM_NAME = FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE S016(PN) WITH
'사용할 폼이 없습니다. 관리자에게 문의 바랍니다'.
EXIT.
ENDIF.
LOOP AT GT_PAY.
CLEAR WS_PAY.
WS_PAY = GT_PAY.
CALL FUNCTION FM_NAME
EXPORTING
CONTROL_PARAMETERS = CONTROL_PARAMETERS
OUTPUT_OPTIONS = OUTPUT_OPTIONS
USER_SETTINGS = 'X'
ITAB = WS_PAY
IMPORTING
JOB_OUTPUT_INFO = JOB_OUTPUT_INFO
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCLED = 4
OTHERS = 6.
IF G_MAIL = 'X'.
PERFORM CONVERT_PDF TABLES JOB_OUTPUT_INFO-OTFDATA.
PERFORM SEND_MAIL.
ENDIF.
ENDLOOP.
CALL FUNCTION 'SSF_CLOSE'
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
OTHERS = 4.
------------------------------------------------------------------
FORM CONVERT_PDF TABLES P_OTF_DATA STRUCTURE ITCOO.
DATA: W_ASCII LIKE TLINE OCCURS 0 WITH HEADER LINE.
DATA: IT_DOCTAB_ARCHIVE TYPE DOCS OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
ASCII_BIDI_VIS2LOG = 'X'
IMPORTING
BIN_FILESIZE = PDF_FSIZE
TABLES
OTF = P_OTF_DATA
LINES = PDF_TABLE
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
ENDFORM. " CONVERT_PDF
FORM SEND_MAIL.
DATA : WA_BUFFER TYPE STRING. "To convert from 132 to 255
* objects to send mail.
DATA: I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
* Work Area declarations
DATA: WA_OBJHEAD TYPE SOLI_TAB,
WA_DOC_CHNG TYPE SODOCCHGI1.
* Variables declarations
DATA: V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I,
V_OBJ_NAME(50),
V_OBJ_DESCR(50).
REFRESH: I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
CLEAR: I_OBJBIN[].
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
TABLES
CONTENT_IN = PDF_TABLE
CONTENT_OUT = I_OBJBIN
EXCEPTIONS
ERR_LINE_WIDTH_SRC_TOO_LONG = 1
ERR_LINE_WIDTH_DST_TOO_LONG = 2
ERR_CONV_FAILED = 3
OTHERS = 4.
* create message body
* # title and description
CONCATENATE WS_PAY-PAY_Y '년' WS_PAY-PAY_M '월 급여명세서입니다.' INTO I_OBJTXT.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
CONCATENATE '급여명세서_' WS_PAY-ENAME '_' WS_PAY-PAY_Y WS_PAY-PAY_M INTO V_OBJ_NAME.
CONCATENATE '급여명세서_' WS_PAY-ENAME '_' WS_PAY-PAY_Y WS_PAY-PAY_M INTO V_OBJ_DESCR.
WA_DOC_CHNG-OBJ_NAME = V_OBJ_NAME.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = V_OBJ_DESCR.
WA_DOC_CHNG-SENSITIVTY = 'F'.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
* # main text
CLEAR I_OBJPACK-TRANSF_BIN.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_TXT.
I_OBJPACK-DOC_TYPE = 'RAW'.
APPEND I_OBJPACK.
* # attachment
* (pdf-Attachment)
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
* L#nge des Attachment ermitteln
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = 'PDF'.
CONCATENATE 'PAY_' WS_PAY-PAY_Y WS_PAY-PAY_M INTO I_OBJPACK-OBJ_NAME.
CONCATENATE 'PAY_' WS_PAY-PAY_Y WS_PAY-PAY_M INTO I_OBJPACK-OBJ_DESCR.
APPEND I_OBJPACK.
* DATA: L_RECEIVER TYPE SO_RECNAME.
CLEAR I_RECLIST.
PERFORM GET_ADDR USING WS_PAY-PERNR
CHANGING I_RECLIST-RECEIVER.
* I_RECLIST-RECEIVER = L_RECEIVER.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = 'X'
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
RECEIVERS = I_RECLIST
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 NE '0'.
GT_RESULT-PERNR = WS_PAY-PERNR.
GT_RESULT-ENAME = WS_PAY-ENAME.
CASE SY-SUBRC.
WHEN '1'.
GT_RESULT-TEXT = 'TOO_MANY_RECEIVERS'.
WHEN '2'.
GT_RESULT-TEXT = 'DOCUMENT_NOT_SENT'.
WHEN '3'.
GT_RESULT-TEXT = 'DOCUMENT_TYPE_NOT_EXIST'.
WHEN '4'.
GT_RESULT-TEXT = 'OPERATION_NO_AUTHORIZATION'.
WHEN '5'.
GT_RESULT-TEXT = 'PARAMETER_ERROR'.
WHEN '6'.
GT_RESULT-TEXT = 'X_ERROR'.
WHEN '7'.
GT_RESULT-TEXT = 'ENQUEUE_ERROR'.
WHEN '8'.
GT_RESULT-TEXT = 'OTHERS'.
ENDCASE.
APPEND GT_RESULT. CLEAR GT_RESULT.
ELSE.
GT_RESULT-PERNR = WS_PAY-PERNR.
GT_RESULT-ENAME = WS_PAY-ENAME.
GT_RESULT-TEXT = 'SUCCESS'.
APPEND GT_RESULT. CLEAR GT_RESULT.
ENDIF.
ENDFORM. " SEND_MAIL