Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 머니플랜
- UTF-8
- fi
- FI 용어정리
- SAP
- selection screen
- sapa
- ole
- badi
- ABAP
- KOSA
- Java
- Enhancement
- 가계부
- 방화벽
- Smart Forms
- 이명박
- List box
- alv 정형화
- 스마트폼
- function
- 동적 쿼리
- EXIT
- gimp
- 오라클 함수
- ALV
- 유닉스
- 엑소버드
- Standard Function
- EUC-kr
Archives
- Today
- Total
Drunken Lion
처음짠 ALV 본문
REPORT ZPIM4001 .
* Data 선언
TYPE-POOLS: SLIS.
DATA: L_POS TYPE I VALUE 0.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF FIELDCAT .
DATA : BEGIN OF PF_EXTAB OCCURS 0,
FCODE LIKE RSMPE-FUNC,
END OF PF_EXTAB.
TABLES : EKPO.
DATA: BEGIN OF UPLOAD OCCURS 0,
EBELN LIKE EKPO-EBELN ,
EBELP LIKE EKPO-EBELP ,
END OF UPLOAD.
DATA: BEGIN OF DOWNLOAD OCCURS 0,
EBELN LIKE EKPO-EBELN ,
EBELP LIKE EKPO-EBELP ,
TXZ01 LIKE EKPO-TXZ01 ,
END OF DOWNLOAD.
* Set PF-status
SET PF-STATUS 'ZALV_STANDARD'.
* Selection-screen
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME .
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME
DEFAULT 'C:\TEMP\EBELN.TXT' OBLIGATORY.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN COMMENT /4(40) TEXT-001.
SELECTION-SCREEN COMMENT /4(40) TEXT-002.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN COMMENT /4(40) TEXT-003.
SELECTION-SCREEN COMMENT /4(40) TEXT-004.
SELECTION-SCREEN END OF BLOCK BL1.
TYPE-POOLS: SLIS.
DATA: L_POS TYPE I VALUE 0.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF FIELDCAT .
DATA : BEGIN OF PF_EXTAB OCCURS 0,
FCODE LIKE RSMPE-FUNC,
END OF PF_EXTAB.
TABLES : EKPO.
DATA: BEGIN OF UPLOAD OCCURS 0,
EBELN LIKE EKPO-EBELN ,
EBELP LIKE EKPO-EBELP ,
END OF UPLOAD.
DATA: BEGIN OF DOWNLOAD OCCURS 0,
EBELN LIKE EKPO-EBELN ,
EBELP LIKE EKPO-EBELP ,
TXZ01 LIKE EKPO-TXZ01 ,
END OF DOWNLOAD.
* Set PF-status
SET PF-STATUS 'ZALV_STANDARD'.
* Selection-screen
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME .
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME
DEFAULT 'C:\TEMP\EBELN.TXT' OBLIGATORY.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN COMMENT /4(40) TEXT-001.
SELECTION-SCREEN COMMENT /4(40) TEXT-002.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN COMMENT /4(40) TEXT-003.
SELECTION-SCREEN COMMENT /4(40) TEXT-004.
SELECTION-SCREEN END OF BLOCK BL1.
* Value Request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM GET_FILE_NAME USING P_FILE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM GET_FILE_NAME USING P_FILE.
* START-OF-SELECTION.
START-OF-SELECTION.
PERFORM UPLOAD.
PERFORM DATA_SELECT.
PERFORM ALV_REPORT.
START-OF-SELECTION.
PERFORM UPLOAD.
PERFORM DATA_SELECT.
PERFORM ALV_REPORT.
*&---------------------------------------------------------------------*
*& Form GET_FILE_NAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_FILE text *
*----------------------------------------------------------------------*
FORM GET_FILE_NAME USING P_FILENAME.
*& Form GET_FILE_NAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_FILE text *
*----------------------------------------------------------------------*
FORM GET_FILE_NAME USING P_FILENAME.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_PATH = 'c:\'
MASK = ',*.*,*.*.'
MODE = '0'
IMPORTING
FILENAME = P_FILENAME
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
EXPORTING
DEF_PATH = 'c:\'
MASK = ',*.*,*.*.'
MODE = '0'
IMPORTING
FILENAME = P_FILENAME
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
ENDFORM. " GET_FILE_NAME
*&---------------------------------------------------------------------*
*& Form UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD.
*& Form UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = UPLOAD
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
EXPORTING
FILENAME = P_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = UPLOAD
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
ENDFORM. " UPLOAD
*&---------------------------------------------------------------------*
*& Form DATA_SELECT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_SELECT.
*& Form DATA_SELECT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_SELECT.
SELECT * INTO CORRESPONDING FIELDS OF TABLE DOWNLOAD
FROM EKPO FOR ALL ENTRIES IN UPLOAD
WHERE EBELN = UPLOAD-EBELN
AND EBELP = UPLOAD-EBELP.
FROM EKPO FOR ALL ENTRIES IN UPLOAD
WHERE EBELN = UPLOAD-EBELN
AND EBELP = UPLOAD-EBELP.
ENDFORM. " DATA_SELECT
*&---------------------------------------------------------------------*
*& Form ALV_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_REPORT.
*& Form ALV_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_REPORT.
PERFORM FIELDCAT.
PERFORM EVENTCAT.
PERFORM ALV_WRITE.
PERFORM EVENTCAT.
PERFORM ALV_WRITE.
ENDFORM. " ALV_REPORT
*&---------------------------------------------------------------------*
*& Form FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FIELDCAT.
PERFORM BUILD_FIELDCAT USING 'EBELN' 'PO번호' 10.
PERFORM BUILD_FIELDCAT USING 'EBELP' 'PO항번' 10.
PERFORM BUILD_FIELDCAT USING 'TXZ01' 'Short_Text' 40.
PERFORM BUILD_FIELDCAT USING 'EBELP' 'PO항번' 10.
PERFORM BUILD_FIELDCAT USING 'TXZ01' 'Short_Text' 40.
ENDFORM. " FIELDCAT
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0218 text *
* -->P_0219 text *
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT USING FIELDNAME FIELDTXT LEN.
*& Form BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0218 text *
* -->P_0219 text *
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT USING FIELDNAME FIELDTXT LEN.
L_POS = L_POS + 1.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-COL_POS = L_POS.
FIELDCAT_LN-FIELDNAME = FIELDNAME.
FIELDCAT_LN-REPTEXT_DDIC = FIELDTXT.
FIELDCAT_LN-OUTPUTLEN = LEN.
APPEND FIELDCAT_LN TO FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-COL_POS = L_POS.
FIELDCAT_LN-FIELDNAME = FIELDNAME.
FIELDCAT_LN-REPTEXT_DDIC = FIELDTXT.
FIELDCAT_LN-OUTPUTLEN = LEN.
APPEND FIELDCAT_LN TO FIELDCAT.
ENDFORM. " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form ALV_WRITE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_WRITE.
*& Form ALV_WRITE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_WRITE.
DATA: PGM LIKE SY-REPID.
DATA G_STATUS TYPE SLIS_FORMNAME VALUE 'SET_PF_STATUS' .
PGM = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = PGM
I_CALLBACK_PF_STATUS_SET = G_STATUS
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_STRUCTURE_NAME =
* IS_LAYOUT =
IT_FIELDCAT = FIELDCAT
* it_excluding = pf_extab
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT = ' '
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = DOWNLOAD
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
DATA G_STATUS TYPE SLIS_FORMNAME VALUE 'SET_PF_STATUS' .
PGM = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = PGM
I_CALLBACK_PF_STATUS_SET = G_STATUS
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_STRUCTURE_NAME =
* IS_LAYOUT =
IT_FIELDCAT = FIELDCAT
* it_excluding = pf_extab
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT = ' '
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = DOWNLOAD
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " ALV_WRITE
*&---------------------------------------------------------------------*
*& Form EVENTCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
*&---------------------------------------------------------------------*
*& Form EVENTCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'BACK' OR 'RW' OR '%EX'.
* LEAVE TO SCREEN 0.
WHEN 'DOWN'.
PERFORM DATA_DOWNLOAD.
ENDCASE.
ENDFORM. " EVENTCAT
WHEN 'BACK' OR 'RW' OR '%EX'.
* LEAVE TO SCREEN 0.
WHEN 'DOWN'.
PERFORM DATA_DOWNLOAD.
ENDCASE.
ENDFORM. " EVENTCAT
*&---------------------------------------------------------------------*
*& Form DATA_DOWNLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_DOWNLOAD.
*& Form DATA_DOWNLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_DOWNLOAD.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
* BIN_FILESIZE = ' '
* CODEPAGE = ' '
* FILENAME =
FILETYPE = 'DAT'
* ITEM = ' '
* MODE = ' '
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* FILEMASK_MASK = ' '
* FILEMASK_TEXT = ' '
* FILETYPE_NO_CHANGE = ' '
* FILEMASK_ALL = ' '
* FILETYPE_NO_SHOW = ' '
* SILENT = 'S'
* COL_SELECT = ' '
* COL_SELECTMASK = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* ACT_FILENAME =
* ACT_FILETYPE =
* FILESIZE =
* CANCEL =
TABLES
DATA_TAB = DOWNLOAD
* FIELDNAMES =
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
EXPORTING
* BIN_FILESIZE = ' '
* CODEPAGE = ' '
* FILENAME =
FILETYPE = 'DAT'
* ITEM = ' '
* MODE = ' '
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* FILEMASK_MASK = ' '
* FILEMASK_TEXT = ' '
* FILETYPE_NO_CHANGE = ' '
* FILEMASK_ALL = ' '
* FILETYPE_NO_SHOW = ' '
* SILENT = 'S'
* COL_SELECT = ' '
* COL_SELECTMASK = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* ACT_FILENAME =
* ACT_FILETYPE =
* FILESIZE =
* CANCEL =
TABLES
DATA_TAB = DOWNLOAD
* FIELDNAMES =
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
ENDFORM. " DATA_DOWNLOAD
*&---------------------------------------------------------------------*
*& Form EVENTCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EVENTCAT.
*& Form EVENTCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EVENTCAT.
ENDFORM. " EVENTCAT
*&---------------------------------------------------------------------*
*& Form SET_PF_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SET_PF_STATUS USING LT_EXTAB LIKE PF_EXTAB[].
SET PF-STATUS 'ZALV_STANDARD' EXCLUDING LT_EXTAB.
ENDFORM. " SET_PF_STAUTS
*& Form SET_PF_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SET_PF_STATUS USING LT_EXTAB LIKE PF_EXTAB[].
SET PF-STATUS 'ZALV_STANDARD' EXCLUDING LT_EXTAB.
ENDFORM. " SET_PF_STAUTS
4.0B 기반이긴 하지만 드디어 ALV 를 처음으로 해봤다..
이제 어떻게 하는건지 슬슬 감이 온다..
이번 프로그램에서 고생한점..
1. PF-STATUS 셋팅 실패
2. 각 필드 사용법에 대한 지식 부족으로 Copy & Paste 로 작성됨..
정리되면 차근 차근.. 올려봐야지 ^^
'SAP > ALV' 카테고리의 다른 글
I_STRUCTURE_NAME (0) | 2007.10.04 |
---|---|
I_CALLBACK_PF_STATUS_SET (0) | 2007.10.02 |
I_callback_program (0) | 2007.09.27 |
Interface Consistency Check (0) | 2007.09.27 |
ALV 기본사항 (0) | 2007.09.27 |