*&---------------------------------------------------------------------*
*& Report ZDOWNLOAD_TABLE_DATA
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZDOWNLOAD_TABLE_DATA
NO STANDARD PAGE HEADING
LINE-SIZE 1000.
TYPE-POOLS : SLIS.
TABLES:
DD02L,
DD02T,
ZCASCRCHIF.
DATA:
GR_TABNAME TYPE RANGE OF TABNAME WITH HEADER LINE.
*..... Process log
DATA: BEGIN OF GS_LOG,
SEQNO(4) TYPE N,
STATU_ICON LIKE ICON-ID,
STATU_MSG(256),
TABNAME LIKE DD02L-TABNAME,
DDTEXT LIKE DD02T-DDTEXT,
DBCNT LIKE SY-DBCNT,
FILELENGTH TYPE I,
END OF GS_LOG.
DATA:
GT_LOG LIKE GS_LOG OCCURS 0 WITH HEADER LINE.
CONSTANTS:
C_INDXKEY LIKE INDX-SRTFD VALUE 'ZDOWNLOAD_TABLE_DATA'.
*&---------------------------------------------------------------------*
*& Macro SET_RANGE_VALUE
*&---------------------------------------------------------------------*
DEFINE SET_RANGE_VALUE.
&1-SIGN = &2.
&1-OPTION = &3.
&1-LOW = &4.
&1-HIGH = &5.
APPEND &1.
CLEAR &1.
END-OF-DEFINITION.
*----------------------------------------------------------------------*
* SELECTION-SCREEN
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TX_B1.
* 작업선택
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) TX_CBOX1.
*SELECTION-SCREEN POSITION 33.
* 일반테이블
PARAMETER RB_NORM RADIOBUTTON GROUP RB1
USER-COMMAND RB1
DEFAULT 'X'.
SELECTION-SCREEN COMMENT (20) TX_RBNOR FOR FIELD RB_NORM.
* DDIC 테이블
PARAMETER RB_DDIC RADIOBUTTON GROUP RB1.
SELECTION-SCREEN COMMENT (20) TX_RBDDI FOR FIELD RB_DDIC.
SELECTION-SCREEN END OF LINE.
* 파일경로
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) TX_FPATH FOR FIELD P_FPATH.
PARAMETER P_FPATH TYPE TXT1024
* OBLIGATORY
DEFAULT 'C:\TEMP'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TX_B2.
*----------------------------------------------------------*
* 일반테이블 선택시 추가선택조건
*----------------------------------------------------------*
* 테이블
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (30) TX_TABNM FOR FIELD S_TABNM
MODIF ID NOR.
SELECT-OPTIONS S_TABNM FOR DD02L-TABNAME
* OBLIGATORY
MEMORY ID ZTABNM
MODIF ID NOR.
SELECTION-SCREEN END OF LINE.
* 생성일
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (30) TX_CRDAT FOR FIELD S_CRDAT
MODIF ID NOR.
SELECT-OPTIONS S_CRDAT FOR ZCASCRCHIF-CRDAT
MEMORY ID ZCRDAT
MODIF ID NOR.
SELECTION-SCREEN END OF LINE.
* 최대적중수
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) TX_TBMAX FOR FIELD P_TBMAX
MODIF ID NOR.
PARAMETER P_TBMAX TYPE RSEUMOD-TBMAXSEL
MEMORY ID ZTBMAX
MODIF ID NOR.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
INITIALIZATION.
PERFORM INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
PERFORM AT_SELECTION_SCREEN_OUTPUT.
AT SELECTION-SCREEN.
PERFORM AT_SELECTION_SCREEN.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FPATH.
PERFORM F4_HELP_FOR_FOLDER
USING
'P_FPATH'
CHANGING
P_FPATH.
START-OF-SELECTION.
PERFORM START_OF_SELECTION.
END-OF-SELECTION.
PERFORM END_OF_SELECTION.
************************************************************************
* S U B R O U T I N E S *
* S U B R O U T I N E S *
* S U B R O U T I N E S *
************************************************************************
*&---------------------------------------------------------------------*
*& Form INITIALIZATION
*&---------------------------------------------------------------------*
FORM INITIALIZATION.
TX_B1 = '기본선택조건'.
TX_B2 = '추가선택조건'.
TX_CBOX1 = '작업선택'.
TX_RBNOR = '일반테이블'.
TX_RBDDI = 'DDIC 테이블'.
* 일반테이블
TX_TABNM = '테이블이름'.
TX_CRDAT = '생성일자'.
TX_TBMAX = '최대적중수'.
TX_FPATH = '파일경로'.
ENDFORM. "INITIALIZATION
*&---------------------------------------------------------------------*
*& Form AT_SELECTION_SCREEN_OUTPUT
*&---------------------------------------------------------------------*
FORM AT_SELECTION_SCREEN_OUTPUT.
PERFORM MODIFY_SCREEN.
ENDFORM. " AT_SELECTION_SCREEN_OUTPUT
*&---------------------------------------------------------------------*
*& Form MODIFY_SCREEN
*&---------------------------------------------------------------------*
FORM MODIFY_SCREEN.
CASE 'X'.
WHEN RB_NORM. "일반테이블
LOOP AT SCREEN.
IF SCREEN-GROUP1 EQ 'DDI'.
SCREEN-ACTIVE = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
WHEN RB_DDIC. "DDIC 테이블
LOOP AT SCREEN.
IF SCREEN-GROUP1 EQ 'NOR'.
SCREEN-ACTIVE = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDCASE.
ENDFORM. " MODIFY_SCREEN
*&---------------------------------------------------------------------*
*& Form AT_SELECTION_SCREEN
*&---------------------------------------------------------------------*
FORM AT_SELECTION_SCREEN.
CASE SY-UCOMM.
WHEN 'ONLI'.
IF P_FPATH IS INITIAL.
MESSAGE E000(DB) WITH
'파일경로는 필수입력입니다.'.
ENDIF.
CASE 'X'.
WHEN RB_NORM. "일반테이블
IF S_TABNM[] IS INITIAL.
MESSAGE E000(DB) WITH
'일반테이블 선택시 테이블명은 필수입력입니다.'.
ENDIF.
WHEN RB_DDIC. "DDIC 테이블
ENDCASE.
ENDCASE.
ENDFORM. "AT_SELECTION_SCREEN
*&---------------------------------------------------------------------*
*& Form F4_HELP_FOR_FOLDER
*&---------------------------------------------------------------------*
FORM F4_HELP_FOR_FOLDER
USING
P_FIELDNAME
CHANGING
P_FOLDER.
DATA:
L_FOLDER TYPE STRING, " LIKE RLGRAP-FILENAME,
* OBJFILE TYPE REF TO CL_GUI_FRONTEND_SERVICES,
L_SELECTED_FOLDER TYPE STRING,
L_INITIAL_FOLDER TYPE STRING,
LT_DYNPFIELDS LIKE DYNPREAD OCCURS 0 WITH HEADER LINE.
LT_DYNPFIELDS-FIELDNAME = P_FIELDNAME.
APPEND LT_DYNPFIELDS.
CLEAR LT_DYNPFIELDS.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = LT_DYNPFIELDS.
READ TABLE LT_DYNPFIELDS
WITH KEY
FIELDNAME = P_FIELDNAME.
IF SY-SUBRC EQ 0.
L_FOLDER = LT_DYNPFIELDS-FIELDVALUE.
ENDIF.
* CREATE OBJECT OBJFILE.
IF NOT L_FOLDER IS INITIAL.
L_INITIAL_FOLDER = L_FOLDER.
ELSE.
* CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_DESKTOP_DIRECTORY
* CHANGING
* DESKTOP_DIRECTORY = L_INITIAL_FOLDER
** EXCEPTIONS
** CNTL_ERROR = 1
** ERROR_NO_GUI = 2
** NOT_SUPPORTED_BY_GUI = 3
** OTHERS = 4
* .
* IF SY-SUBRC <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.
ENDIF.
CALL METHOD CL_GUI_CFW=>FLUSH.
CALL METHOD CL_GUI_CFW=>UPDATE_VIEW.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE
EXPORTING
* WINDOW_TITLE =
INITIAL_FOLDER = L_INITIAL_FOLDER
CHANGING
SELECTED_FOLDER = L_SELECTED_FOLDER
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* OBJFILE->DIRECTORY_BROWSE( EXPORTING INITIAL_FOLDER = L_INITIAL_FOLDER
* CHANGING SELECTED_FOLDER = L_SELECTED_FOLDER
* EXCEPTIONS CNTL_ERROR = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3 ).
IF SY-SUBRC = 0.
P_FOLDER = L_SELECTED_FOLDER.
ELSE.
WRITE: / 'An error has occured picking a folder'.
ENDIF.
ENDFORM. "F4_HELP_FOR_FOLDER
*&---------------------------------------------------------------------*
*& Form START_OF_SELECTION
*&---------------------------------------------------------------------*
FORM START_OF_SELECTION.
DATA:
L_DDLANGUAGE TYPE DD02V-DDLANGUAGE,
L_GUBUN TYPE CHAR4.
* 초기값설정
PERFORM SET_INITIAL_VALUES
CHANGING
L_DDLANGUAGE
L_GUBUN.
* 데이터처리
PERFORM DATA_PROCESSING
USING
L_DDLANGUAGE
L_GUBUN.
ENDFORM. "START_OF_SELECTION
*&---------------------------------------------------------------------*
*& Form SET_INITIAL_VALUES
*&---------------------------------------------------------------------*
FORM SET_INITIAL_VALUES
USING
P_DDLANGUAGE TYPE DD02V-DDLANGUAGE
P_GUBUN.
CASE 'X'.
WHEN RB_NORM. "일반테이블
GR_TABNAME[] = S_TABNM[].
P_DDLANGUAGE = SY-LANGU.
P_GUBUN = 'NORM'.
WHEN RB_DDIC. "DDIC 테이블
SET_RANGE_VALUE GR_TABNAME 'I' 'EQ':
'DD01L' SPACE,
'DD01T' SPACE,
'DD02L' SPACE,
'DD02T' SPACE,
'DD03L' SPACE,
'DD04L' SPACE,
'DD04T' SPACE,
'DD05S' SPACE,
'DD07L' SPACE,
'DD07T' SPACE,
'DD08L' SPACE,
'DD08T' SPACE,
'DD09L' SPACE,
'DD12L' SPACE,
'DD12T' SPACE,
'DD25L' SPACE,
'DD25T' SPACE,
'DD26S' SPACE,
'DD27S' SPACE,
'DD28S' SPACE,
'DD29L' SPACE,
'DD30L' SPACE,
'DD30T' SPACE,
'DD31S' SPACE,
'DD32S' SPACE,
'DD33S' SPACE,
'DD35L' SPACE,
'DD36S' SPACE,
'T100A' SPACE,
'T100T' SPACE,
'T100' SPACE,
'TSTC' SPACE,
'TSTCT' SPACE,
'TSTCP' SPACE,
'TPARA' SPACE,
'TFDIR' SPACE,
'TFTIT' SPACE,
'FUNCT' SPACE,
'FUPARAREF' SPACE,
'ENLFDIR' SPACE.
P_DDLANGUAGE = 'EN'.
P_GUBUN = 'DDIC'.
ENDCASE.
ENDFORM. " SET_INITIAL_VALUES
*&---------------------------------------------------------------------*
*& Form DATA_PROCESSING
*&---------------------------------------------------------------------*
FORM DATA_PROCESSING
USING
P_DDLANGUAGE TYPE DD02V-DDLANGUAGE
P_GUBUN.
DATA: BEGIN OF LT_DD02V OCCURS 0,
TABNAME TYPE DD02V-TABNAME,
DDTEXT TYPE DD02V-DDTEXT,
END OF LT_DD02V.
DATA:
L_SEQNO(4) TYPE N.
SELECT
TABNAME
DDTEXT
FROM DD02V
INTO TABLE LT_DD02V
WHERE TABNAME IN GR_TABNAME
AND DDLANGUAGE EQ P_DDLANGUAGE
AND TABCLASS EQ 'TRANSP'.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
SORT LT_DD02V BY
TABNAME.
* 테이블데이터 다운로드
LOOP AT LT_DD02V.
EXPORT
FILEPATH = P_FPATH
CRDAT = S_CRDAT
TBMAXSEL = P_TBMAX
TO MEMORY ID C_INDXKEY.
SUBMIT ZSUBMIT_DOWNLOAD_TABLE_DATA
WITH P_GUBUN EQ P_GUBUN
WITH P_TABNM EQ LT_DD02V-TABNAME
WITH P_TABTX EQ LT_DD02V-DDTEXT
AND RETURN.
IMPORT
LOG = GS_LOG
FROM MEMORY ID C_INDXKEY.
FREE MEMORY ID C_INDXKEY.
IF GS_LOG IS NOT INITIAL.
L_SEQNO = L_SEQNO + '1'.
GS_LOG-SEQNO = L_SEQNO.
APPEND GS_LOG TO GT_LOG.
CLEAR GS_LOG.
ENDIF.
* PERFORM DOWNLOAD_TABLE_DATA
* USING
* LT_DD02V-TABNAME
* LT_DD02V-DDTEXT.
CLEAR:
LT_DD02V.
ENDLOOP.
ENDFORM. " DATA_PROCESSING
*&---------------------------------------------------------------------*
*& Form END_OF_SELECTION
*&---------------------------------------------------------------------*
FORM END_OF_SELECTION.
* IF GT_LOG[] IS INITIAL.
* MESSAGE S000(DB) DISPLAY LIKE 'E' WITH
* '조건에 맞는 데이터가 없습니다.'.
* ELSE.
PERFORM ALV_FC_GRID_DISPLAY_PROCESS.
* ENDIF.
ENDFORM. "END_OF_SELECTION
*&---------------------------------------------------------------------*
*& Form ALV_FC_GRID_DISPLAY_PROCESS
*&---------------------------------------------------------------------*
FORM ALV_FC_GRID_DISPLAY_PROCESS .
DATA:
LT_ALV_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV ,
LT_ALV_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE,
LT_ALV_FILTER TYPE SLIS_T_FILTER_ALV WITH HEADER LINE,
LT_ALV_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV,
LT_ALV_EVENTS TYPE SLIS_T_EVENT,
LT_ALV_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
LT_ALV_GRIDSET TYPE LVC_S_GLAY,
LT_ALV_PRINT TYPE SLIS_PRINT_ALV,
LT_ALV_EXCLUDING TYPE SLIS_T_EXTAB WITH HEADER LINE,
LS_ALV_LAYOUT TYPE SLIS_LAYOUT_ALV,
LS_ALV_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
LS_ALV_SPEC_VARIANT TYPE DISVARIANT, "specific variant
LS_ALV_VARIANT TYPE DISVARIANT, "finally chosen variant.
L_ALV_REPID LIKE SY-REPID,
L_ALV_SAVE TYPE C,
L_ALV_EXIT TYPE C,
LV_ALVBUFFER(11) TYPE C,
L_TABIX TYPE SY-TABIX.
L_ALV_SAVE = 'A'.
LS_ALV_VARIANT-HANDLE = 'LIST'.
LS_ALV_VARIANT-REPORT = SY-REPID.
L_ALV_REPID = SY-REPID.
LS_ALV_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
LS_ALV_LAYOUT-ZEBRA = 'X'.
LS_ALV_LAYOUT-CELL_MERGE = 'X'.
* LS_ALV_LAYOUT-BOX_TABNAME = 'GT_LOG'.
* LS_ALV_LAYOUT-BOX_FIELDNAME = 'MARK'.
* ALV BUFFER Init
LV_ALVBUFFER = 'BFOFF EUOFF'.
SET PARAMETER ID 'ALVBUFFER' FIELD LV_ALVBUFFER.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = L_ALV_REPID
I_INTERNAL_TABNAME = 'GS_LOG'
* I_STRUCTURE_NAME = 'ZECS0171'
I_INCLNAME = L_ALV_REPID
I_BYPASSING_BUFFER = 'X'
CHANGING
CT_FIELDCAT = LT_ALV_FIELDCAT[]
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
LOOP AT LT_ALV_FIELDCAT INTO LS_ALV_FIELDCAT.
L_TABIX = SY-TABIX.
LS_ALV_FIELDCAT-KEY = SPACE.
LS_ALV_FIELDCAT-FIX_COLUMN = SPACE.
* CASE LS_ALV_FIELDCAT-FIELDNAME.
** WHEN 'MARK'.
** LS_ALV_FIELDCAT-EMPHASIZE = 'C000'.
* WHEN 'MATNR'.
* LS_ALV_FIELDCAT-EMPHASIZE = 'C410'.
* ENDCASE.
* 고정컬럼설정
* CASE LS_ALV_FIELDCAT-FIELDNAME.
* WHEN 'MARK'.
* LS_ALV_FIELDCAT-FIX_COLUMN = 'X'.
* ENDCASE.
* 숨김컬럼설정
* CASE LS_ALV_FIELDCAT-FIELDNAME.
* WHEN 'MARK'.
* LS_ALV_FIELDCAT-NO_OUT = 'X'.
* ENDCASE.
* 체크박스컬럼설정
* CASE LS_ALV_FIELDCAT-FIELDNAME.
* WHEN 'MARK'.
* LS_ALV_FIELDCAT-CHECKBOX = 'X'.
* ENDCASE.
* 아이콘
CASE LS_ALV_FIELDCAT-FIELDNAME.
WHEN 'STATU_ICON'.
LS_ALV_FIELDCAT-ICON = 'X'.
ENDCASE.
* 열너비설정
* CASE LS_ALV_FIELDCAT-FIELDNAME.
* WHEN ' '.
* LS_ALV_FIELDCAT-OUTPUTLEN = 256.
* ENDCASE.
CASE LS_ALV_FIELDCAT-FIELDNAME.
WHEN 'SEQNO'.
LS_ALV_FIELDCAT-SELTEXT_S =
LS_ALV_FIELDCAT-SELTEXT_M =
LS_ALV_FIELDCAT-SELTEXT_L =
LS_ALV_FIELDCAT-REPTEXT_DDIC = '순번'.
WHEN 'STATU_ICON'.
LS_ALV_FIELDCAT-SELTEXT_S =
LS_ALV_FIELDCAT-SELTEXT_M =
LS_ALV_FIELDCAT-SELTEXT_L =
LS_ALV_FIELDCAT-REPTEXT_DDIC = '상태'.
WHEN 'STATU_MSG'.
LS_ALV_FIELDCAT-SELTEXT_S =
LS_ALV_FIELDCAT-SELTEXT_M =
LS_ALV_FIELDCAT-SELTEXT_L =
LS_ALV_FIELDCAT-REPTEXT_DDIC = '상태 메세지'.
WHEN 'DDTEXT'.
LS_ALV_FIELDCAT-SELTEXT_S =
LS_ALV_FIELDCAT-SELTEXT_M =
LS_ALV_FIELDCAT-SELTEXT_L =
LS_ALV_FIELDCAT-REPTEXT_DDIC = '테이블 내역'.
WHEN 'DBCNT'.
LS_ALV_FIELDCAT-SELTEXT_S =
LS_ALV_FIELDCAT-SELTEXT_M =
LS_ALV_FIELDCAT-SELTEXT_L =
LS_ALV_FIELDCAT-REPTEXT_DDIC = '레코드 건수'.
WHEN 'FILELENGTH'.
LS_ALV_FIELDCAT-SELTEXT_S =
LS_ALV_FIELDCAT-SELTEXT_M =
LS_ALV_FIELDCAT-SELTEXT_L =
LS_ALV_FIELDCAT-REPTEXT_DDIC = '파일크기'.
ENDCASE.
MODIFY LT_ALV_FIELDCAT FROM LS_ALV_FIELDCAT INDEX L_TABIX.
CLEAR LS_ALV_FIELDCAT.
ENDLOOP.
* ALV DISPLAY
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_BACKGROUND_ID = 'ALV_BACKGROUND' " BACK GROUND 무늬
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = L_ALV_REPID
* I_CALLBACK_PF_STATUS_SET = 'ALV_FC_PF_STATUS'
* I_CALLBACK_USER_COMMAND = 'ALV_FC_USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = C_ALV_TOP_OF_PAGE
IS_LAYOUT = LS_ALV_LAYOUT
IT_FIELDCAT = LT_ALV_FIELDCAT[]
* IT_EXCLUDING =
* IT_SORT = LT_ALV_SORT[]
* I_DEFAULT = 'X'
I_SAVE = L_ALV_SAVE
IS_VARIANT = LS_ALV_VARIANT
* IT_EVENTS = LT_ALV_EVENTS[]
* IS_PRINT = LT_ALV_PRINT
* I_SCREEN_START_COLUMN = L_SCREEN_START_COLUMN
* I_SCREEN_START_LINE = L_SCREEN_START_LINE
* I_SCREEN_END_COLUMN = L_SCREEN_END_COLUMN
* I_SCREEN_END_LINE = L_SCREEN_END_LINE
TABLES
T_OUTTAB = GT_LOG.
ENDFORM. " ALV_FC_GRID_DISPLAY_PROCESS
댓글 없음:
댓글 쓰기