*--------------------------------------------------------------------*
* 처리 METHOD
*--------------------------------------------------------------------*
* IR_RESPONSE Importing Type Ref To IF_HTTP_RESPONSE
* IR_NAVIGATION Importing Type Ref To IF_BSP_NAVIGATION
* IR_MESSAGES Importing Type Ref To CL_BSP_MESSAGES
*--------------------------------------------------------------------*
TYPES:
BEGIN OF TS_CONTENT,
FNAME TYPE STRING,
CONTENT TYPE XSTRING,
END OF TS_CONTENT .
DATA : LT_CONTENT TYPE TT_CONTENT.
DATA : LS_CONTENT TYPE TS_CONTENT.
DATA : LCL_ZIP TYPE REF TO CL_ABAP_ZIP.
DATA : L_ZIPPED_CONTENT TYPE XSTRING.
DATA : L_CONDITION TYPE STRING.
DATA : L_DOWNLOAD_FNAME TYPE STRING.
DATA : LX_ERROR TYPE REF TO CX_ROOT.
*-- LT_CONTENT에 파일 BINARY 정보를 넣음
* FNAME : 각각 파일명
* CONTENT : 파일에 대한 XSTRING값
*-- append binary data to zip object
LOOP AT LT_CONTENT INTO LS_CONTENT.
LCL_ZIP->ADD( NAME = LS_CONTENT-FNAME
CONTENT = LS_CONTENT-CONTENT ).
ENDLOOP.
*-- Compress and get zip binary data
IF LCL_ZIP->FILES IS NOT INITIAL.
TRY.
L_ZIPPED_CONTENT = LCL_ZIP->SAVE( ).
CATCH CX_ROOT INTO LX_ERROR.
*-- Error
E_RC = 4.
L_CONDITION = 'FailtoCompressFiles'.
CALL METHOD IR_MESSAGES->ADD_MESSAGE_FROM_EXCEPTION
EXPORTING
CONDITION = L_CONDITION
EXCEPTION = LX_ERROR
SEVERITY = IR_MESSAGES->CO_SEVERITY_WARNING.
* CALL METHOD IR_MESSAGES->ADD_MESSAGE_FROM_T100
* EXPORTING
* CONDITION = L_CONDITION
* MSGID = 'ZTMG' "MESSAGE GROUP
* MSGNO = '000' "MESSAGE NUMBER
* MSGTY = 'E'. "MESSAGE TYPE
RETURN.
ENDTRY.
ENDIF.
*-- ZIP File's Name Create
CONCATENATE 'attachment; filename='
'파일이름'
'.zip'
INTO L_DOWNLOAD_FNAME.
*-- File DownLoad
CALL METHOD CL_BSP_UTILITY=>DOWNLOAD
EXPORTING
OBJECT_S = L_ZIPPED_CONTENT
CONTENT_DISPOSITION = L_DOWNLOAD_FNAME
CONTENT_TYPE = 'application/x-zip-compressed'
RESPONSE = IR_RESPONSE
NAVIGATION = IR_NAVIGATION.
*--------------------------------------------------------------------*
* 호출 하는쪽
*--------------------------------------------------------------------*
DATA : IR_RESPONSE TYPE REF TO IF_HTTP_RESPONSE.
IR_RESPONSE = PAGE->GET_RESPONSE( ).
CALL METHOD TEST->TEST_METHOD
EXPORTING
IR_RESPONSE = IR_RESPONSE
IR_NAVIGATION = NAVIGATION
IR_MESSAGES = PAGE->MESSAGES
IMPORTING
E_RC = SY-SUBRC.
파일 XSTRING은 엑셀다운로드 혹은 엑셀 다운로드 예시 참조하시거나
각자의 방법으로..
* 처리 METHOD
*--------------------------------------------------------------------*
* IR_RESPONSE Importing Type Ref To IF_HTTP_RESPONSE
* IR_NAVIGATION Importing Type Ref To IF_BSP_NAVIGATION
* IR_MESSAGES Importing Type Ref To CL_BSP_MESSAGES
*--------------------------------------------------------------------*
TYPES:
BEGIN OF TS_CONTENT,
FNAME TYPE STRING,
CONTENT TYPE XSTRING,
END OF TS_CONTENT .
DATA : LT_CONTENT TYPE TT_CONTENT.
DATA : LS_CONTENT TYPE TS_CONTENT.
DATA : LCL_ZIP TYPE REF TO CL_ABAP_ZIP.
DATA : L_ZIPPED_CONTENT TYPE XSTRING.
DATA : L_CONDITION TYPE STRING.
DATA : L_DOWNLOAD_FNAME TYPE STRING.
DATA : LX_ERROR TYPE REF TO CX_ROOT.
*-- LT_CONTENT에 파일 BINARY 정보를 넣음
* FNAME : 각각 파일명
* CONTENT : 파일에 대한 XSTRING값
*-- append binary data to zip object
LOOP AT LT_CONTENT INTO LS_CONTENT.
LCL_ZIP->ADD( NAME = LS_CONTENT-FNAME
CONTENT = LS_CONTENT-CONTENT ).
ENDLOOP.
*-- Compress and get zip binary data
IF LCL_ZIP->FILES IS NOT INITIAL.
TRY.
L_ZIPPED_CONTENT = LCL_ZIP->SAVE( ).
CATCH CX_ROOT INTO LX_ERROR.
*-- Error
E_RC = 4.
L_CONDITION = 'FailtoCompressFiles'.
CALL METHOD IR_MESSAGES->ADD_MESSAGE_FROM_EXCEPTION
EXPORTING
CONDITION = L_CONDITION
EXCEPTION = LX_ERROR
SEVERITY = IR_MESSAGES->CO_SEVERITY_WARNING.
* CALL METHOD IR_MESSAGES->ADD_MESSAGE_FROM_T100
* EXPORTING
* CONDITION = L_CONDITION
* MSGID = 'ZTMG' "MESSAGE GROUP
* MSGNO = '000' "MESSAGE NUMBER
* MSGTY = 'E'. "MESSAGE TYPE
RETURN.
ENDTRY.
ENDIF.
*-- ZIP File's Name Create
CONCATENATE 'attachment; filename='
'파일이름'
'.zip'
INTO L_DOWNLOAD_FNAME.
*-- File DownLoad
CALL METHOD CL_BSP_UTILITY=>DOWNLOAD
EXPORTING
OBJECT_S = L_ZIPPED_CONTENT
CONTENT_DISPOSITION = L_DOWNLOAD_FNAME
CONTENT_TYPE = 'application/x-zip-compressed'
RESPONSE = IR_RESPONSE
NAVIGATION = IR_NAVIGATION.
*--------------------------------------------------------------------*
* 호출 하는쪽
*--------------------------------------------------------------------*
DATA : IR_RESPONSE TYPE REF TO IF_HTTP_RESPONSE.
IR_RESPONSE = PAGE->GET_RESPONSE( ).
CALL METHOD TEST->TEST_METHOD
EXPORTING
IR_RESPONSE = IR_RESPONSE
IR_NAVIGATION = NAVIGATION
IR_MESSAGES = PAGE->MESSAGES
IMPORTING
E_RC = SY-SUBRC.
파일 XSTRING은 엑셀다운로드 혹은 엑셀 다운로드 예시 참조하시거나
각자의 방법으로..
'SAP > BSP' 카테고리의 다른 글
BSP - 브라우저 우측 상단 X버튼에 관해 (0) | 2010.07.15 |
---|---|
BSP - Process bar (0) | 2010.04.13 |
BSP - 엑셀 다운로드 예시 (0) | 2010.04.08 |
BSP - 엑셀다운로드 (0) | 2010.04.08 |
Table View에 사용되는 스타일 시트 (0) | 2008.06.05 |